Skip to content

Commit

Permalink
Feat: Migrated UPI Setup Module to KMP (#1811)
Browse files Browse the repository at this point in the history
  • Loading branch information
niyajali authored Nov 4, 2024
1 parent f0ff23b commit a246b70
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 105 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ that can be used as a dependency in any other wallet based project. It is develo
| :feature:saved-cards | Done ||||||
| :feature:send-money | Done ||||||
| :feature:standing-instruction | Done ||||||
| :feature:upi-setup | Not started | | | | | |
| :feature:upi-setup | Done | | | | | |
| lint | Not started ||||||

✅: Functioning properly
Expand Down
Empty file.
21 changes: 0 additions & 21 deletions feature/upi-setup/proguard-rules.pro

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,14 @@
*
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md
*/
package org.mifospay.feature.upiSetup.di
package org.mifospay.feature.upi.setup.di

import org.koin.core.module.dsl.viewModel
import org.koin.core.module.dsl.viewModelOf
import org.koin.dsl.module
import org.mifospay.feature.upiSetup.viewmodel.DebitCardViewModel
import org.mifospay.feature.upiSetup.viewmodel.SetUpUpiViewModal
import org.mifospay.feature.upi.setup.viewmodel.DebitCardViewModel
import org.mifospay.feature.upi.setup.viewmodel.SetUpUpiViewModal

val UpiSetupModule = module {

viewModel {
DebitCardViewModel()
}

viewModel {
SetUpUpiViewModal()
}
viewModelOf(::DebitCardViewModel)
viewModelOf(::SetUpUpiViewModal)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
*
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md
*/
package org.mifospay.feature.upiSetup.navigation
package org.mifospay.feature.upi.setup.navigation

import android.os.Bundle
import androidx.core.bundle.Bundle
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavType
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import com.mifospay.core.model.domain.BankAccountDetails
import org.mifospay.core.common.Constants
import org.mifospay.feature.upiSetup.screens.SetupUpiPinScreenRoute
import org.mifospay.core.model.bank.BankAccountDetails
import org.mifospay.feature.upi.setup.screens.SetupUpiPinScreenRoute

const val SETUP_UPI_PIN_ROUTE = "setup_upi_pin_route"

fun NavGraphBuilder.setupUpiPinScreen(
onBackPress: () -> Unit,
navigateBack: () -> Unit,
) {
composable(
route = "$SETUP_UPI_PIN_ROUTE/{${Constants.INDEX}}/{${Constants.TYPE}}",
Expand All @@ -31,17 +31,24 @@ fun NavGraphBuilder.setupUpiPinScreen(
navArgument(Constants.TYPE) { type = NavType.StringType },
),
) { backStackEntry ->
val bankAccountDetails =
backStackEntry.arguments?.getParcelable(Constants.BANK_ACCOUNT_DETAILS)
?: BankAccountDetails("", "", "", "", "")
val bankAccountDetails = BankAccountDetails(
accountNo = "sanctus",
bankName = null,
accountHolderName = null,
branch = null,
ifsc = null,
type = null,
isUpiEnabled = false,
upiPin = null
)
val index = backStackEntry.arguments?.getInt(Constants.INDEX) ?: 0
val type = backStackEntry.arguments?.getString(Constants.TYPE) ?: ""

SetupUpiPinScreenRoute(
type = type,
index = index,
bankAccountDetails = bankAccountDetails,
onBackPress = onBackPress,
onBackPress = navigateBack,
)
}
}
Expand All @@ -52,7 +59,7 @@ fun NavController.navigateToSetupUpiPin(
type: String,
) {
val bundle = Bundle().apply {
putParcelable(Constants.BANK_ACCOUNT_DETAILS, bankAccountDetails)
putString(Constants.BANK_ACCOUNT_DETAILS, bankAccountDetails.toString())
}
this.navigate("$SETUP_UPI_PIN_ROUTE/$index/$type") {
this.launchSingleTop = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md
*/
package org.mifospay.feature.upiSetup.screens
package org.mifospay.feature.upi.setup.screens

import androidx.annotation.VisibleForTesting
import androidx.compose.foundation.layout.Box
Expand All @@ -21,15 +21,15 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import org.koin.androidx.compose.koinViewModel
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.koin.compose.viewmodel.koinViewModel
import org.mifospay.core.designsystem.component.MifosLoadingWheel
import org.mifospay.core.designsystem.theme.MifosTheme
import org.mifospay.core.ui.VerifyStepHeader
import org.mifospay.feature.upiSetup.viewmodel.DebitCardUiState
import org.mifospay.feature.upiSetup.viewmodel.DebitCardViewModel
import org.mifospay.feature.upi.setup.viewmodel.DebitCardUiState
import org.mifospay.feature.upi.setup.viewmodel.DebitCardViewModel

@Composable
internal fun DebitCardScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md
*/
package org.mifospay.feature.upiSetup.screens
package org.mifospay.feature.upi.setup.screens

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
Expand All @@ -34,8 +34,8 @@ import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.OffsetMapping
import androidx.compose.ui.text.input.TransformedText
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.mifospay.core.designsystem.theme.MifosTheme
import org.mifospay.core.ui.ExpiryDateInput

Expand Down Expand Up @@ -138,7 +138,7 @@ private fun formatCardNumber(text: AnnotatedString): TransformedText {
return TransformedText(AnnotatedString(out), creditCardOffsetTranslator)
}

@Preview(showBackground = true)
@Preview
@Composable
private fun DebitCardScreenContentsPreview() {
MifosTheme {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md
*/
package org.mifospay.feature.upiSetup.screens
package org.mifospay.feature.upi.setup.screens

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand All @@ -20,14 +20,15 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import mobile_wallet.feature.upi_setup.generated.resources.Res
import mobile_wallet.feature.upi_setup.generated.resources.feature_upi_setup_enter_otp
import org.jetbrains.compose.resources.stringResource
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.mifospay.core.designsystem.theme.MifosTheme
import org.mifospay.core.ui.OtpTextField
import org.mifospay.core.ui.VerifyStepHeader
import org.mifospay.feature.upi_setup.R

@Composable
internal fun OtpScreen(
Expand Down Expand Up @@ -71,7 +72,7 @@ private fun OtpScreenContent(
) {
Column(modifier) {
Text(
text = stringResource(id = R.string.feature_upi_setup_enter_otp),
text = stringResource(Res.string.feature_upi_setup_enter_otp),
color = MaterialTheme.colorScheme.onSurface,
fontSize = 18.sp,
style = MaterialTheme.typography.headlineMedium,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
*
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md
*/
package org.mifospay.feature.upiSetup.screens
package org.mifospay.feature.upi.setup.screens

import android.app.Activity
import android.content.Intent
import android.widget.Toast
import androidx.annotation.VisibleForTesting
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand All @@ -25,15 +22,15 @@ import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.mifospay.core.model.domain.BankAccountDetails
import org.koin.androidx.compose.koinViewModel
import mobile_wallet.feature.upi_setup.generated.resources.Res
import mobile_wallet.feature.upi_setup.generated.resources.feature_upi_setup_back
import org.jetbrains.compose.resources.stringResource
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.koin.compose.viewmodel.koinViewModel
import org.mifospay.core.common.Constants
import org.mifospay.core.designsystem.icon.MifosIcons
import org.mifospay.feature.upiSetup.viewmodel.SetUpUpiViewModal
import org.mifospay.feature.upi_setup.R
import org.mifospay.core.model.bank.BankAccountDetails
import org.mifospay.feature.upi.setup.viewmodel.SetUpUpiViewModal

@Composable
internal fun SetupUpiPinScreenRoute(
Expand Down Expand Up @@ -69,7 +66,6 @@ internal fun SetupUpiPinScreen(
onBackPress: () -> Unit,
modifier: Modifier = Modifier,
) {
val context = LocalContext.current
Scaffold(
modifier = modifier,
topBar = {
Expand All @@ -90,7 +86,7 @@ internal fun SetupUpiPinScreen(
) {
Icon(
MifosIcons.ArrowBack,
contentDescription = stringResource(id = R.string.feature_upi_setup_back),
contentDescription = stringResource(Res.string.feature_upi_setup_back),
)
}
},
Expand All @@ -108,19 +104,6 @@ internal fun SetupUpiPinScreen(
otpText = otpText,
correctlySettingUpi = {
setupUpiPin(it)
bankAccountDetails.isUpiEnabled = true
bankAccountDetails.upiPin = it
Toast.makeText(
context,
Constants.UPI_PIN_SETUP_COMPLETED_SUCCESSFULLY,
Toast.LENGTH_SHORT,
).show()
val intent = Intent().apply {
putExtra(Constants.UPDATED_BANK_ACCOUNT, bankAccountDetails)
putExtra(Constants.INDEX, index)
}
(context as? Activity)?.setResult(Activity.RESULT_OK, intent)
(context as? Activity)?.finish()
},
)
}
Expand Down Expand Up @@ -169,10 +152,13 @@ fun PreviewForgetUpi() {

fun getBankAccountDetails(): BankAccountDetails {
return BankAccountDetails(
"SBI",
"Ankur Sharma",
"New Delhi",
"XXXXXXXX9990XXX " + " ",
"Savings",
accountNo = "SBI",
bankName = "Ankur Sharma",
accountHolderName = "New Delhi",
branch = "XXXXXXXX9990XXX " + " ",
ifsc = "Savings",
type = "Debit",
isUpiEnabled = false,
upiPin = "0000",
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@
*
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md
*/
package org.mifospay.feature.upiSetup.screens
package org.mifospay.feature.upi.setup.screens

import android.widget.Toast
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.mifospay.core.common.Constants
import org.mifospay.core.designsystem.theme.MifosTheme

Expand Down Expand Up @@ -58,7 +56,6 @@ private fun SettingAndForgotUpi(
var upiPinScreenVerified by rememberSaveable { mutableStateOf(false) }
var realOtp by rememberSaveable { mutableStateOf("") }

val context = LocalContext.current

Column(modifier) {
DebitCardScreen(
Expand All @@ -71,7 +68,7 @@ private fun SettingAndForgotUpi(
debitCardScreenVisible = false
},
onDebitCardVerificationFailed = {
Toast.makeText(context, it, Toast.LENGTH_SHORT).show()

},
)
OtpScreen(
Expand Down
Loading

0 comments on commit a246b70

Please sign in to comment.