Skip to content

Commit d059416

Browse files
feat: new ui for make transfer (#2893)
1 parent a864022 commit d059416

File tree

30 files changed

+1425
-692
lines changed

30 files changed

+1425
-692
lines changed

cmp-navigation/src/commonMain/kotlin/cmp/navigation/authenticated/AuthenticatedNavigation.kt

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import androidx.navigation.NavOptions
1717
import androidx.navigation.navigation
1818
import cmp.navigation.authenticatednavbar.AuthenticatedNavbarRoute
1919
import cmp.navigation.authenticatednavbar.authenticatedNavbarGraph
20+
import kotlinx.serialization.ExperimentalSerializationApi
21+
import kotlinx.serialization.InternalSerializationApi
2022
import kotlinx.serialization.Serializable
2123
import org.mifos.mobile.core.common.Constants
2224
import org.mifos.mobile.core.model.entity.TransferSuccessDestination
@@ -52,15 +54,15 @@ import org.mifos.mobile.feature.qr.navigation.navigateToQrImportScreen
5254
import org.mifos.mobile.feature.qr.navigation.navigateToQrReaderScreen
5355
import org.mifos.mobile.feature.qr.navigation.qrNavGraph
5456
import org.mifos.mobile.feature.recent.transaction.navigation.recentTransactionNavGraph
55-
import org.mifos.mobile.feature.savings.navigation.navigateToSavingsMakeTransfer
56-
import org.mifos.mobile.feature.savings.navigation.oldSavingsNavGraph
5757
import org.mifos.mobile.feature.savingsaccount.navigation.savingsNavGraph
5858
import org.mifos.mobile.feature.savingsaccount.savingsAccountDetails.navigateToSavingsAccountDetailsScreen
5959
import org.mifos.mobile.feature.status.navigation.StatusNavigationRoute
6060
import org.mifos.mobile.feature.status.navigation.statusDestination
6161
import org.mifos.mobile.feature.third.party.transfer.navigation.thirdPartyTransferNavGraph
62-
import org.mifos.mobile.feature.transfer.process.navigation.navigateToTransferProcessScreen
63-
import org.mifos.mobile.feature.transfer.process.navigation.transferProcessNavGraph
62+
import org.mifos.mobile.feature.transfer.process.makeTransfer.makeTransferDestination
63+
import org.mifos.mobile.feature.transfer.process.makeTransfer.navigateToMakeTransferScreen
64+
import org.mifos.mobile.feature.transfer.process.transferProcess.navigateToTransferProcessScreen
65+
import org.mifos.mobile.feature.transfer.process.transferProcess.transferProcessDestination
6466

6567
@Serializable
6668
internal data object AuthenticatedGraphRoute
@@ -69,6 +71,7 @@ internal fun NavController.navigateToAuthenticatedGraph(navOptions: NavOptions?
6971
navigate(route = AuthenticatedGraphRoute, navOptions = navOptions)
7072
}
7173

74+
@OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
7275
internal fun NavGraphBuilder.authenticatedGraph(
7376
navController: NavController,
7477
) {
@@ -118,10 +121,21 @@ internal fun NavGraphBuilder.authenticatedGraph(
118121

119122
statusDestination(
120123
navigateToDestination = {
121-
if (it == Constants.LOGIN) {
122-
navController.navigateToLoginScreen()
123-
} else {
124-
navController.navigateToHomeAfterStatus()
124+
when (it) {
125+
Constants.LOGIN -> {
126+
navController.navigateToLoginScreen()
127+
}
128+
Constants.NAVIGATE_BACK_TO_LOAN -> {
129+
navController
130+
.navigateToAccountsScreen(Constants.LOAN_ACCOUNT)
131+
}
132+
Constants.NAVIGATE_BACK_TO_SAVINGS -> {
133+
navController
134+
.navigateToAccountsScreen(Constants.SAVINGS_ACCOUNT)
135+
}
136+
else -> {
137+
navController.navigateToHomeAfterStatus()
138+
}
125139
}
126140
},
127141
)
@@ -131,8 +145,9 @@ internal fun NavGraphBuilder.authenticatedGraph(
131145
navigateToClientChargeScreen = navController::navigateToClientChargeScreen,
132146
navigateToStatusScreen = navController::navigateToStatusAfterUpdate,
133147
navigateToAuthenticateScreen = navController::navigateToVerifyPasscodeScreen,
134-
navigateToDepositScreen = navController::navigateToSavingsMakeTransfer,
135-
navigateToTransferScreen = navController::navigateToSavingsMakeTransfer,
148+
navigateToTransferScreen = {
149+
navController.navigateToMakeTransferScreen(it)
150+
},
136151
navigateToSavingsAccountTransactionScreen = {
137152
navController.navigateToAccountTransactionsScreen(Constants.SAVINGS_ACCOUNT, it)
138153
},
@@ -141,18 +156,14 @@ internal fun NavGraphBuilder.authenticatedGraph(
141156

142157
loanNavGraph(
143158
navController = navController,
144-
navigateToMakePaymentScreen = { args ->
145-
navController.navigateToSavingsMakeTransfer(
146-
args,
147-
)
159+
navigateToMakePaymentScreen = {
160+
navController.navigateToMakeTransferScreen(it)
148161
},
149162
navigateToQrCodeScreen = navController::navigateToQrDisplayScreen,
150163
navigateToClientChargeScreen = navController::navigateToClientChargeScreen,
151164
navigateToLoanAccountTransactionScreen = {
152165
navController.navigateToAccountTransactionsScreen(Constants.LOAN_ACCOUNT, it)
153166
},
154-
// navigateToDepositScreen = navController::navigateToSavingsMakeTransfer,
155-
// navigateToTransferScreen = navController::navigateToSavingsMakeTransfer,
156167
)
157168

158169
loanApplicationNavGraph(
@@ -189,18 +200,19 @@ internal fun NavGraphBuilder.authenticatedGraph(
189200
openBeneficiaryApplication = navController::navigateToBeneficiaryApplicationScreen,
190201
)
191202

192-
oldSavingsNavGraph(
193-
navController = navController,
194-
viewQrCode = {},
195-
viewCharges = { _, _ -> },
196-
reviewTransfer = { transferPayload, transferType, transferDestination ->
203+
makeTransferDestination(
204+
navigateBack = navController::popBackStack,
205+
navigateToTransferScreen = { transferPayload, transferType, transferDestination ->
197206
navController.navigateToTransferProcessScreen(
198-
transferPayload,
199-
transferType,
200-
transferDestination,
207+
transferPayload = transferPayload,
208+
transferType = transferType,
209+
transferSuccessDestination = when (transferDestination) {
210+
TransferSuccessDestination.SAVINGS_ACCOUNT -> Constants.NAVIGATE_BACK_TO_SAVINGS
211+
TransferSuccessDestination.LOAN_ACCOUNT -> Constants.NAVIGATE_BACK_TO_LOAN
212+
TransferSuccessDestination.HOME -> ""
213+
},
201214
)
202215
},
203-
callHelpline = {},
204216
)
205217

206218
thirdPartyTransferNavGraph(
@@ -210,27 +222,15 @@ internal fun NavGraphBuilder.authenticatedGraph(
210222
navController.navigateToTransferProcessScreen(
211223
transferPayload,
212224
transferType,
213-
transferDestination,
225+
transferDestination.name,
214226
)
215227
},
216228
)
217229

218-
transferProcessNavGraph(
230+
transferProcessDestination(
219231
navigateBack = navController::popBackStack,
220-
onTransferSuccessNavigate = { destination ->
221-
println("getting destination from handle $destination")
222-
when (destination) {
223-
TransferSuccessDestination.HOME -> navController.navigateUpToAuthenticatedNavbarRoot()
224-
TransferSuccessDestination.LOAN_ACCOUNT ->
225-
navController.navigateToAccountsScreen(
226-
Constants.LOAN_ACCOUNT,
227-
)
228-
229-
TransferSuccessDestination.SAVINGS_ACCOUNT -> navController.navigateToAccountsScreen(
230-
Constants.SAVINGS_ACCOUNT,
231-
)
232-
}
233-
},
232+
navigateToAuthenticateScreen = navController::navigateToVerifyPasscodeScreen,
233+
navigateToStatusScreen = navController::navigateToStatusAfterUpdate,
234234
)
235235
}
236236
}

core/common/src/commonMain/kotlin/org/mifos/mobile/core/common/Constants.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,6 @@ object Constants {
9999
const val HELP = "help"
100100

101101
const val APPLY_LOAN = "apply_loan"
102+
const val NAVIGATE_BACK_TO_SAVINGS = "navigate_back_to_savings"
103+
const val NAVIGATE_BACK_TO_LOAN = "navigate_back_to_loan"
102104
}

core/designsystem/src/commonMain/kotlin/org/mifos/mobile/core/designsystem/component/MifosButton.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import androidx.compose.runtime.Composable
2828
import androidx.compose.ui.Modifier
2929
import androidx.compose.ui.graphics.Shape
3030
import androidx.compose.ui.unit.dp
31+
import org.mifos.mobile.core.designsystem.theme.DesignToken
3132

3233
/**
3334
* Mifos button with generic content slot. Wraps Material 3 [Button].
@@ -80,10 +81,12 @@ fun MifosButton(
8081
text: @Composable () -> Unit,
8182
modifier: Modifier = Modifier,
8283
enabled: Boolean = true,
83-
shape: Shape = ButtonDefaults.shape,
84+
shape: Shape = DesignToken.shapes.medium,
8485
contentPadding: PaddingValues = ButtonDefaults.ContentPadding,
8586
elevation: ButtonElevation? = ButtonDefaults.buttonElevation(),
86-
colors: ButtonColors = ButtonDefaults.buttonColors(),
87+
colors: ButtonColors = ButtonDefaults.buttonColors(
88+
containerColor = MaterialTheme.colorScheme.primary,
89+
),
8790
) {
8891
Button(
8992
onClick = onClick,
@@ -115,7 +118,7 @@ fun MifosOutlinedButton(
115118
onClick: () -> Unit,
116119
modifier: Modifier = Modifier,
117120
enabled: Boolean = true,
118-
shape: Shape = ButtonDefaults.outlinedShape,
121+
shape: Shape = DesignToken.shapes.medium,
119122
border: BorderStroke? = ButtonDefaults.outlinedButtonBorder(enabled),
120123
colors: ButtonColors = ButtonDefaults.outlinedButtonColors(),
121124
contentPadding: PaddingValues = ButtonDefaults.ContentPadding,

core/designsystem/src/commonMain/kotlin/org/mifos/mobile/core/designsystem/component/MifosRadioButton.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ fun MifosRadioButton(
137137
) {
138138
Row(
139139
modifier = modifier
140+
.padding(vertical = DesignToken.padding.extraSmall)
140141
.border(
141142
width = borderWidth,
142143
color = animatedBorderColor.copy(

core/ui/src/commonMain/composeResources/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
<string name="validation_amount_invalid_increment">Amount must be in valid increments for this currency</string>
115115

116116
<string name="savings_account">Savings Account</string>
117-
<string name="available_balance">Available Balance</string>
117+
<string name="available_balance">Client Name</string>
118118
<string name="select_other_payment_account">Select other payment account</string>
119119
<string name="available_balance_formatted">Available Balance - %1$s</string>
120120
</resources>
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
99
*/
10-
package org.mifos.mobile.feature.charge.components
10+
package org.mifos.mobile.core.ui.component
1111

1212
import androidx.compose.foundation.border
1313
import androidx.compose.foundation.layout.Arrangement
@@ -27,9 +27,11 @@ import org.mifos.mobile.core.designsystem.component.CardVariant
2727
import org.mifos.mobile.core.designsystem.component.MifosCustomCard
2828
import org.mifos.mobile.core.designsystem.theme.DesignToken
2929
import org.mifos.mobile.core.designsystem.theme.MifosTypography
30+
import kotlin.collections.component1
31+
import kotlin.collections.component2
3032

3133
@Composable
32-
fun ChargeDetailsCard(
34+
fun MifosDetailsCard(
3335
keyValuePairs: Map<StringResource, String>,
3436
modifier: Modifier = Modifier,
3537
) {

core/ui/src/commonMain/kotlin/org/mifos/mobile/core/ui/component/MifosDropDownPayFromComponent.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import androidx.compose.ui.layout.ContentScale
4242
import androidx.compose.ui.unit.dp
4343
import mifos_mobile.core.ui.generated.resources.Res
4444
import mifos_mobile.core.ui.generated.resources.available_balance
45-
import mifos_mobile.core.ui.generated.resources.available_balance_formatted
4645
import mifos_mobile.core.ui.generated.resources.ic_icon_dashboard
4746
import mifos_mobile.core.ui.generated.resources.savings_account
4847
import mifos_mobile.core.ui.generated.resources.select_other_payment_account
@@ -62,8 +61,8 @@ fun MifosPayFromDropdownUI(
6261
modifier: Modifier = Modifier,
6362
onAccountSelected: (String, String) -> Unit,
6463
) {
65-
var selectedAccount by rememberSaveable { mutableStateOf(accounts[0].first) }
66-
var selectedBalance by rememberSaveable { mutableStateOf(accounts[0].second) }
64+
var selectedAccount by rememberSaveable { mutableStateOf("") }
65+
var selectedBalance by rememberSaveable { mutableStateOf("") }
6766
Column {
6867
MifosDropDownPayFromComponent(
6968
accountNumber = selectedAccount,
@@ -176,7 +175,7 @@ fun AccountDropdownItem(
176175
)
177176
Spacer(modifier = Modifier.height(DesignToken.padding.extraSmall))
178177
Text(
179-
text = stringResource(Res.string.available_balance_formatted, balance),
178+
text = balance,
180179
style = MifosTypography.bodySmall,
181180
color = MaterialTheme.colorScheme.onPrimary,
182181
)

core/ui/src/commonMain/kotlin/org/mifos/mobile/core/ui/component/MifosDropDownTextField.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import androidx.compose.material3.DropdownMenuItem
2020
import androidx.compose.material3.Icon
2121
import androidx.compose.material3.MaterialTheme
2222
import androidx.compose.material3.OutlinedTextField
23+
import androidx.compose.material3.OutlinedTextFieldDefaults
2324
import androidx.compose.material3.Text
2425
import androidx.compose.runtime.Composable
2526
import androidx.compose.runtime.LaunchedEffect
@@ -157,6 +158,11 @@ fun MifosDropDownDoubleTextField(
157158
},
158159
)
159160
},
161+
colors = OutlinedTextFieldDefaults.colors(
162+
focusedBorderColor = MaterialTheme.colorScheme.secondaryContainer,
163+
unfocusedBorderColor = MaterialTheme.colorScheme.secondaryContainer,
164+
errorBorderColor = MaterialTheme.colorScheme.error,
165+
),
160166
)
161167

162168
DropdownMenu(

core/ui/src/commonMain/kotlin/org/mifos/mobile/core/ui/component/MifosOutlineDropDown.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ fun MifosOutlineDropdown(
8080
},
8181
showClearIcon = false,
8282
readOnly = true,
83+
enabled = enabled,
8384
),
8485

8586
modifier = Modifier
@@ -98,7 +99,7 @@ fun MifosOutlineDropdown(
9899
)
99100

100101
ExposedDropdownMenu(
101-
expanded = expanded,
102+
expanded = expanded && enabled,
102103
onDismissRequest = { expanded = false },
103104
modifier = Modifier
104105
.width(with(LocalDensity.current) { textFieldSize.width.toDp() })

feature/client-charge/src/commonMain/kotlin/org/mifos/mobile/feature/charge/chargeDetails/ChargeDetailScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ import org.mifos.mobile.core.designsystem.component.MifosButton
4545
import org.mifos.mobile.core.designsystem.component.MifosElevatedScaffold
4646
import org.mifos.mobile.core.designsystem.theme.DesignToken
4747
import org.mifos.mobile.core.designsystem.theme.MifosTypography
48+
import org.mifos.mobile.core.ui.component.MifosDetailsCard
4849
import org.mifos.mobile.core.ui.component.MifosPoweredCard
4950
import org.mifos.mobile.core.ui.utils.EventsEffect
50-
import org.mifos.mobile.feature.charge.components.ChargeDetailsCard
5151
import mifos_mobile.core.ui.generated.resources.Res as uiRes
5252

5353
@Composable
@@ -90,7 +90,7 @@ internal fun ChargeDetailScreen(
9090
),
9191
horizontalAlignment = Alignment.CenterHorizontally,
9292
) {
93-
ChargeDetailsCard(keyValuePairs = state.details)
93+
MifosDetailsCard(keyValuePairs = state.details)
9494
Spacer(Modifier.height(DesignToken.padding.extraExtraLarge))
9595
if (state.isPaid) {
9696
ChargeDetailsPaidComponent(

0 commit comments

Comments
 (0)