Skip to content

Commit 4721c8f

Browse files
Feature :Implement NewFixedDeposit with Stepper UI (#2525)
Co-authored-by: Ankit kumar <[email protected]>
1 parent 0775557 commit 4721c8f

File tree

10 files changed

+378
-2
lines changed

10 files changed

+378
-2
lines changed

feature/client/src/commonMain/composeResources/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,5 +528,8 @@
528528
<string name="client_identifier_document_not_found">Document not found</string>
529529
<string name="client_identifier_btn_update">Update</string>
530530
<string name="client_update_document_title">Update Document</string>
531+
<!-- Screen Title -->
532+
<string name="title_new_fixed_deposit_account">New Fixed Deposit Account</string>
531533

534+
532535
</resources>

feature/client/src/commonMain/kotlin/com/mifos/feature/client/navigation/ClientNavigation.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ import com.mifos.feature.client.documentPreviewScreen.createDocumentPreviewRoute
7575
import com.mifos.feature.client.documentPreviewScreen.navigateToDocumentPreviewRoute
7676
import com.mifos.feature.client.fixedDepositAccount.clientFixedDepositAccountDestination
7777
import com.mifos.feature.client.fixedDepositAccount.navigateToFixedDepositAccountRoute
78+
import com.mifos.feature.client.newFixedDepositAccount.fixedAccountDestination
79+
import com.mifos.feature.client.newFixedDepositAccount.navigateToNewFixedDepositRoute
7880
import com.mifos.feature.client.recurringDepositAccount.clientRecurringDepositAccountDestination
7981
import com.mifos.feature.client.recurringDepositAccount.navigateToRecurringDepositAccountRoute
8082
import com.mifos.feature.client.savingsAccounts.navigateToClientSavingsAccountsRoute
@@ -310,7 +312,7 @@ fun NavGraphBuilder.clientNavGraph(
310312
onNavigateApplyLoanAccount = navController::navigateToNewLoanAccountRoute,
311313
onNavigateApplySavingsAccount = navController::navigateToSavingsAccountRoute,
312314
onNavigateApplyRecurringAccount = navController::navigateToRecurringAccountRoute,
313-
onNavigateApplyFixedAccount = { },
315+
onNavigateApplyFixedAccount = navController::navigateToNewFixedDepositRoute,
314316
navController = navController,
315317
)
316318
clientUpcomingChargesDestination(
@@ -340,8 +342,8 @@ fun NavGraphBuilder.clientNavGraph(
340342
)
341343

342344
shareAccountDestination()
343-
344345
recurringAccountDestination()
346+
fixedAccountDestination()
345347
}
346348
}
347349

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.feature.client.newFixedDepositAccount
11+
12+
import androidx.navigation.NavController
13+
import androidx.navigation.NavGraphBuilder
14+
import androidx.navigation.compose.composable
15+
import kotlinx.serialization.Serializable
16+
17+
@Serializable
18+
data object FixedDepositRoute
19+
20+
fun NavGraphBuilder.fixedAccountDestination() {
21+
composable<FixedDepositRoute> {
22+
FixedDepositAccountScreen(
23+
onNavigateBack = {},
24+
onFinish = {},
25+
)
26+
}
27+
}
28+
fun NavController.navigateToNewFixedDepositRoute() {
29+
this.navigate(
30+
FixedDepositRoute,
31+
)
32+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.feature.client.newFixedDepositAccount
11+
12+
import androidclient.feature.client.generated.resources.Res
13+
import androidclient.feature.client.generated.resources.step_charges
14+
import androidclient.feature.client.generated.resources.step_details
15+
import androidclient.feature.client.generated.resources.step_interest
16+
import androidclient.feature.client.generated.resources.step_settings
17+
import androidclient.feature.client.generated.resources.step_terms
18+
import androidclient.feature.client.generated.resources.title_new_fixed_deposit_account
19+
import androidx.compose.foundation.layout.fillMaxWidth
20+
import androidx.compose.runtime.Composable
21+
import androidx.compose.runtime.getValue
22+
import androidx.compose.ui.Modifier
23+
import androidx.lifecycle.compose.collectAsStateWithLifecycle
24+
import androidx.lifecycle.viewmodel.compose.viewModel
25+
import com.mifos.core.designsystem.component.MifosScaffold
26+
import com.mifos.core.ui.components.MifosStepper
27+
import com.mifos.core.ui.components.Step
28+
import com.mifos.core.ui.util.EventsEffect
29+
import com.mifos.feature.client.newFixedDepositAccount.pages.ChargesPage
30+
import com.mifos.feature.client.newFixedDepositAccount.pages.DetailsPage
31+
import com.mifos.feature.client.newFixedDepositAccount.pages.InterestPage
32+
import com.mifos.feature.client.newFixedDepositAccount.pages.SettingPage
33+
import com.mifos.feature.client.newFixedDepositAccount.pages.TermsPage
34+
import org.jetbrains.compose.resources.stringResource
35+
36+
@Composable
37+
internal fun FixedDepositAccountScreen(
38+
onNavigateBack: () -> Unit,
39+
onFinish: () -> Unit,
40+
modifier: Modifier = Modifier,
41+
viewModel: NewFixedDepositAccountViewmodel = viewModel(),
42+
) {
43+
val state by viewModel.stateFlow.collectAsStateWithLifecycle()
44+
EventsEffect(viewModel.eventFlow) { event ->
45+
when (event) {
46+
NewFixedDepositAccountEvent.NavigateBack -> onNavigateBack()
47+
NewFixedDepositAccountEvent.Finish -> onFinish()
48+
}
49+
}
50+
FixedDepositAccountScaffold(
51+
state = state,
52+
onAction = { viewModel.trySendAction(it) },
53+
modifier = modifier,
54+
)
55+
}
56+
57+
@Composable
58+
private fun FixedDepositAccountScaffold(
59+
state: NewFixedDepositAccountState,
60+
onAction: (NewFixedDepositAccountAction) -> Unit,
61+
modifier: Modifier = Modifier,
62+
) {
63+
val steps =
64+
listOf(
65+
Step(stringResource(Res.string.step_details)) {
66+
DetailsPage(
67+
onNext = { onAction(NewFixedDepositAccountAction.NextStep) },
68+
)
69+
},
70+
Step(name = stringResource(Res.string.step_terms)) {
71+
TermsPage(
72+
onNext = { onAction(NewFixedDepositAccountAction.NextStep) },
73+
)
74+
},
75+
76+
Step(name = stringResource(Res.string.step_settings)) {
77+
SettingPage(
78+
onNext = { onAction(NewFixedDepositAccountAction.NextStep) },
79+
)
80+
},
81+
Step(name = stringResource(Res.string.step_interest)) {
82+
InterestPage(
83+
onNext = { onAction(NewFixedDepositAccountAction.NextStep) },
84+
)
85+
},
86+
Step(stringResource(Res.string.step_charges)) {
87+
ChargesPage(
88+
onNext = { onAction(NewFixedDepositAccountAction.NextStep) },
89+
)
90+
},
91+
)
92+
93+
MifosScaffold(
94+
title = stringResource(Res.string.title_new_fixed_deposit_account),
95+
onBackPressed = { onAction(NewFixedDepositAccountAction.NavigateBack) },
96+
modifier = modifier,
97+
98+
) { paddingValues ->
99+
if (state.dialogState == null) {
100+
MifosStepper(
101+
steps = steps,
102+
currentIndex = state.currentStep,
103+
onStepChange = { newIndex ->
104+
onAction(NewFixedDepositAccountAction.OnStepChange(newIndex))
105+
},
106+
modifier = Modifier
107+
.fillMaxWidth(),
108+
109+
)
110+
}
111+
}
112+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.feature.client.newFixedDepositAccount
11+
12+
import com.mifos.core.ui.util.BaseViewModel
13+
import kotlinx.coroutines.flow.update
14+
15+
class NewFixedDepositAccountViewmodel :
16+
BaseViewModel<
17+
NewFixedDepositAccountState,
18+
NewFixedDepositAccountEvent,
19+
NewFixedDepositAccountAction,
20+
>(NewFixedDepositAccountState()) {
21+
override fun handleAction(action: NewFixedDepositAccountAction) {
22+
when (action) {
23+
NewFixedDepositAccountAction.NextStep ->
24+
mutableStateFlow.update { state ->
25+
val maxIndex = 4
26+
state.copy(currentStep = (state.currentStep + 1).coerceAtMost(maxIndex))
27+
}
28+
is NewFixedDepositAccountAction.OnStepChange -> {
29+
mutableStateFlow.update { it.copy(currentStep = action.index) }
30+
}
31+
is NewFixedDepositAccountAction.NavigateBack -> {
32+
sendEvent(NewFixedDepositAccountEvent.NavigateBack)
33+
}
34+
NewFixedDepositAccountAction.Finish -> {
35+
sendEvent(NewFixedDepositAccountEvent.Finish)
36+
}
37+
}
38+
}
39+
}
40+
41+
data class NewFixedDepositAccountState(
42+
val currentStep: Int = 0,
43+
val dialogState: Any? = null,
44+
)
45+
sealed class NewFixedDepositAccountAction() {
46+
object NextStep : NewFixedDepositAccountAction()
47+
data class OnStepChange(val index: Int) : NewFixedDepositAccountAction()
48+
object NavigateBack : NewFixedDepositAccountAction()
49+
object Finish : NewFixedDepositAccountAction()
50+
}
51+
sealed class NewFixedDepositAccountEvent() {
52+
object NavigateBack : NewFixedDepositAccountEvent()
53+
object Finish : NewFixedDepositAccountEvent()
54+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.feature.client.newFixedDepositAccount.pages
11+
12+
import androidclient.feature.client.generated.resources.Res
13+
import androidclient.feature.client.generated.resources.step_charges
14+
import androidx.compose.foundation.layout.Column
15+
import androidx.compose.foundation.layout.Spacer
16+
import androidx.compose.foundation.layout.height
17+
import androidx.compose.material3.Button
18+
import androidx.compose.material3.Text
19+
import androidx.compose.runtime.Composable
20+
import androidx.compose.ui.Alignment
21+
import androidx.compose.ui.Modifier
22+
import androidx.compose.ui.unit.dp
23+
import org.jetbrains.compose.resources.stringResource
24+
25+
@Composable
26+
fun ChargesPage(onNext: () -> Unit) {
27+
Column(horizontalAlignment = Alignment.CenterHorizontally) {
28+
Text(stringResource(Res.string.step_charges))
29+
Spacer(Modifier.height(8.dp))
30+
Button(onClick = onNext) {
31+
Text("Next Button")
32+
}
33+
}
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.feature.client.newFixedDepositAccount.pages
11+
12+
import androidclient.feature.client.generated.resources.Res
13+
import androidclient.feature.client.generated.resources.step_details
14+
import androidx.compose.foundation.layout.Column
15+
import androidx.compose.foundation.layout.Spacer
16+
import androidx.compose.foundation.layout.height
17+
import androidx.compose.material3.Button
18+
import androidx.compose.material3.Text
19+
import androidx.compose.runtime.Composable
20+
import androidx.compose.ui.Alignment
21+
import androidx.compose.ui.Modifier
22+
import androidx.compose.ui.unit.dp
23+
import org.jetbrains.compose.resources.stringResource
24+
25+
@Composable
26+
fun DetailsPage(onNext: () -> Unit) {
27+
Column(horizontalAlignment = Alignment.CenterHorizontally) {
28+
Text(stringResource(Res.string.step_details))
29+
Spacer(Modifier.height(8.dp))
30+
Button(onClick = onNext) {
31+
Text("Next Button")
32+
}
33+
}
34+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.feature.client.newFixedDepositAccount.pages
11+
12+
import androidclient.feature.client.generated.resources.Res
13+
import androidclient.feature.client.generated.resources.step_interest
14+
import androidx.compose.foundation.layout.Column
15+
import androidx.compose.foundation.layout.Spacer
16+
import androidx.compose.foundation.layout.height
17+
import androidx.compose.material3.Button
18+
import androidx.compose.material3.Text
19+
import androidx.compose.runtime.Composable
20+
import androidx.compose.ui.Alignment
21+
import androidx.compose.ui.Modifier
22+
import androidx.compose.ui.unit.dp
23+
import org.jetbrains.compose.resources.stringResource
24+
25+
@Composable
26+
fun InterestPage(onNext: () -> Unit) {
27+
Column(horizontalAlignment = Alignment.CenterHorizontally) {
28+
Text(
29+
stringResource(Res.string.step_interest),
30+
31+
)
32+
Spacer(Modifier.height(8.dp))
33+
Button(onClick = onNext) {
34+
Text("Next Button")
35+
}
36+
}
37+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.feature.client.newFixedDepositAccount.pages
11+
12+
import androidclient.feature.client.generated.resources.Res
13+
import androidclient.feature.client.generated.resources.step_settings
14+
import androidx.compose.foundation.layout.Column
15+
import androidx.compose.foundation.layout.Spacer
16+
import androidx.compose.foundation.layout.height
17+
import androidx.compose.material3.Button
18+
import androidx.compose.material3.Text
19+
import androidx.compose.runtime.Composable
20+
import androidx.compose.ui.Alignment
21+
import androidx.compose.ui.Modifier
22+
import androidx.compose.ui.unit.dp
23+
import org.jetbrains.compose.resources.stringResource
24+
25+
@Composable
26+
fun SettingPage(onNext: () -> Unit) {
27+
Column(horizontalAlignment = Alignment.CenterHorizontally) {
28+
Text(stringResource(Res.string.step_settings))
29+
Spacer(Modifier.height(8.dp))
30+
Button(onClick = onNext) {
31+
Text("Next Button")
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)