diff --git a/feature/client/src/commonMain/composeResources/values/strings.xml b/feature/client/src/commonMain/composeResources/values/strings.xml index 8fca3f4cb18..9c0d1ec0184 100644 --- a/feature/client/src/commonMain/composeResources/values/strings.xml +++ b/feature/client/src/commonMain/composeResources/values/strings.xml @@ -481,6 +481,14 @@ Apply for new recurring deposit account Apply for new fixed deposit account + Details + Terms + Settings + Interest + Charges + Create Recurring Deposit Account + + Delete Signature Upload New Signature diff --git a/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/RecurringAccountRoute.kt b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/RecurringAccountRoute.kt new file mode 100644 index 00000000000..42cbcd7feca --- /dev/null +++ b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/RecurringAccountRoute.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2025 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ +package com.mifos.feature.client.createRecurringDepositAccount + +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.compose.composable +import kotlinx.serialization.Serializable + +@Serializable +data object RecurringAccountRoute + +fun NavGraphBuilder.recurringAccountDestination() { + composable { + RecurringAccountScreen( + onNavigateBack = {}, + onFinish = {}, + ) + } +} + +fun NavController.navigateToRecurringAccountRoute() { + this.navigate( + RecurringAccountRoute, + ) +} diff --git a/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/RecurringAccountScreen.kt b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/RecurringAccountScreen.kt new file mode 100644 index 00000000000..f19b54601d7 --- /dev/null +++ b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/RecurringAccountScreen.kt @@ -0,0 +1,112 @@ +/* + * Copyright 2025 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ +package com.mifos.feature.client.createRecurringDepositAccount + +import androidclient.feature.client.generated.resources.Res +import androidclient.feature.client.generated.resources.create_recurring_deposit_account +import androidclient.feature.client.generated.resources.step_charges +import androidclient.feature.client.generated.resources.step_details +import androidclient.feature.client.generated.resources.step_interest +import androidclient.feature.client.generated.resources.step_settings +import androidclient.feature.client.generated.resources.step_terms +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.ui.Modifier +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.viewmodel.compose.viewModel +import com.mifos.core.designsystem.component.MifosScaffold +import com.mifos.core.ui.components.MifosStepper +import com.mifos.core.ui.components.Step +import com.mifos.core.ui.util.EventsEffect +import com.mifos.feature.client.createRecurringDepositAccount.pages.ChargesPage +import com.mifos.feature.client.createRecurringDepositAccount.pages.DetailsPage +import com.mifos.feature.client.createRecurringDepositAccount.pages.InterestPage +import com.mifos.feature.client.createRecurringDepositAccount.pages.SettingPage +import com.mifos.feature.client.createRecurringDepositAccount.pages.TermsPage +import org.jetbrains.compose.resources.stringResource + +@Composable +internal fun RecurringAccountScreen( + onNavigateBack: () -> Unit, + onFinish: () -> Unit, + modifier: Modifier = Modifier, + viewModel: RecurringAccountViewModel = viewModel(), +) { + val state by viewModel.stateFlow.collectAsStateWithLifecycle() + + EventsEffect(viewModel.eventFlow) { event -> + when (event) { + RecurringAccountEvent.NavigateBack -> onNavigateBack() + RecurringAccountEvent.Finish -> onFinish() + } + } + + RecurringAccountScaffold( + modifier = modifier, + state = state, + onAction = { viewModel.trySendAction(it) }, + ) +} + +@Composable +private fun RecurringAccountScaffold( + state: RecurringAccountState, + modifier: Modifier = Modifier, + onAction: (RecurringAccountAction) -> Unit, +) { + val steps = listOf( + Step(name = stringResource(Res.string.step_details)) { + DetailsPage( + onNext = { onAction(RecurringAccountAction.NextStep) }, + ) + }, + Step(name = stringResource(Res.string.step_terms)) { + TermsPage( + onNext = { onAction(RecurringAccountAction.NextStep) }, + ) + }, + Step(name = stringResource(Res.string.step_settings)) { + SettingPage( + onNext = { onAction(RecurringAccountAction.NextStep) }, + ) + }, + Step(name = stringResource(Res.string.step_interest)) { + InterestPage( + onNext = { onAction(RecurringAccountAction.NextStep) }, + ) + }, + Step(name = stringResource(Res.string.step_charges)) { + ChargesPage( + onNext = { onAction(RecurringAccountAction.NextStep) }, + ) + }, + ) + + MifosScaffold( + title = stringResource(Res.string.create_recurring_deposit_account), + onBackPressed = { onAction(RecurringAccountAction.NavigateBack) }, + modifier = modifier, + ) { paddingValues -> + if (state.dialogState == null) { + MifosStepper( + steps = steps, + currentIndex = state.currentStep, + onStepChange = { newIndex -> + onAction(RecurringAccountAction.OnStepChange(newIndex)) + }, + modifier = Modifier + .fillMaxWidth() + .padding(paddingValues), + ) + } + } +} diff --git a/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/RecurringAccountViewModel.kt b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/RecurringAccountViewModel.kt new file mode 100644 index 00000000000..75892e15ce9 --- /dev/null +++ b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/RecurringAccountViewModel.kt @@ -0,0 +1,54 @@ +/* + * Copyright 2025 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ +package com.mifos.feature.client.createRecurringDepositAccount + +import com.mifos.core.ui.util.BaseViewModel +import kotlinx.coroutines.flow.update + +class RecurringAccountViewModel : + BaseViewModel(RecurringAccountState()) { + + override fun handleAction(action: RecurringAccountAction) { + when (action) { + RecurringAccountAction.NextStep -> { + mutableStateFlow.update { state -> + val maxIndex = 4 + state.copy(currentStep = (state.currentStep + 1).coerceAtMost(maxIndex)) + } + } + is RecurringAccountAction.OnStepChange -> { + mutableStateFlow.update { it.copy(currentStep = action.index) } + } + RecurringAccountAction.NavigateBack -> { + sendEvent(RecurringAccountEvent.NavigateBack) + } + RecurringAccountAction.Finish -> { + sendEvent(RecurringAccountEvent.Finish) + } + } + } +} + +data class RecurringAccountState( + val currentStep: Int = 0, + val dialogState: Any? = null, +) + +sealed class RecurringAccountAction { + object NextStep : RecurringAccountAction() + data class OnStepChange(val index: Int) : RecurringAccountAction() + object NavigateBack : RecurringAccountAction() + object Finish : RecurringAccountAction() +} + +sealed class RecurringAccountEvent { + object NavigateBack : RecurringAccountEvent() + object Finish : RecurringAccountEvent() +} diff --git a/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/pages/ChargesPage.kt b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/pages/ChargesPage.kt new file mode 100644 index 00000000000..88c4163a45c --- /dev/null +++ b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/pages/ChargesPage.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2025 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ +package com.mifos.feature.client.createRecurringDepositAccount.pages + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.material3.Button +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp + +@Composable +fun ChargesPage(onNext: () -> Unit) { + Column(horizontalAlignment = Alignment.CenterHorizontally) { + Text("Charges Page") + Spacer(Modifier.height(8.dp)) + Button(onClick = onNext) { + Text("Next Button") + } + } +} diff --git a/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/pages/DetailsPage.kt b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/pages/DetailsPage.kt new file mode 100644 index 00000000000..ed8cb5b378d --- /dev/null +++ b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/pages/DetailsPage.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2025 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ +package com.mifos.feature.client.createRecurringDepositAccount.pages + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.material3.Button +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp + +@Composable +fun DetailsPage(onNext: () -> Unit) { + Column(horizontalAlignment = Alignment.CenterHorizontally) { + Text("Details Page") + Spacer(Modifier.height(8.dp)) + Button(onClick = onNext) { + Text("Next Button") + } + } +} diff --git a/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/pages/InterestPage.kt b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/pages/InterestPage.kt new file mode 100644 index 00000000000..d570f07eb76 --- /dev/null +++ b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/pages/InterestPage.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2025 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ +package com.mifos.feature.client.createRecurringDepositAccount.pages + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.material3.Button +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp + +@Composable +fun InterestPage(onNext: () -> Unit) { + Column(horizontalAlignment = Alignment.CenterHorizontally) { + Text("Interest Page") + Spacer(Modifier.height(8.dp)) + Button(onClick = onNext) { + Text("Next Button") + } + } +} diff --git a/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/pages/SettingsPage.kt b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/pages/SettingsPage.kt new file mode 100644 index 00000000000..75e4f135344 --- /dev/null +++ b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/pages/SettingsPage.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2025 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ +package com.mifos.feature.client.createRecurringDepositAccount.pages + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.material3.Button +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp + +@Composable +fun SettingPage(onNext: () -> Unit) { + Column(horizontalAlignment = Alignment.CenterHorizontally) { + Text("Settings Page") + Spacer(Modifier.height(8.dp)) + Button(onClick = onNext) { + Text("Next Button") + } + } +} diff --git a/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/pages/TermsPage.kt b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/pages/TermsPage.kt new file mode 100644 index 00000000000..2567158e703 --- /dev/null +++ b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/createRecurringDepositAccount/pages/TermsPage.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2025 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ +package com.mifos.feature.client.createRecurringDepositAccount.pages + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.material3.Button +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp + +@Composable +fun TermsPage(onNext: () -> Unit) { + Column(horizontalAlignment = Alignment.CenterHorizontally) { + Text("Terms Page") + Spacer(Modifier.height(8.dp)) + Button(onClick = onNext) { + Text("Next Button") + } + } +} diff --git a/feature/client/src/commonMain/kotlin/com/mifos/feature/client/navigation/ClientNavigation.kt b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/navigation/ClientNavigation.kt index 7b76f2dddf5..4705e43177e 100644 --- a/feature/client/src/commonMain/kotlin/com/mifos/feature/client/navigation/ClientNavigation.kt +++ b/feature/client/src/commonMain/kotlin/com/mifos/feature/client/navigation/ClientNavigation.kt @@ -69,6 +69,8 @@ import com.mifos.feature.client.clientUpdateDefaultAccount.navigateToUpdateDefau import com.mifos.feature.client.clientUpdateDefaultAccount.updateDefaultAccountDestination import com.mifos.feature.client.clientsList.ClientListScreen import com.mifos.feature.client.createNewClient.CreateNewClientScreen +import com.mifos.feature.client.createRecurringDepositAccount.navigateToRecurringAccountRoute +import com.mifos.feature.client.createRecurringDepositAccount.recurringAccountDestination import com.mifos.feature.client.createShareAccount.navigateToShareAccountRoute import com.mifos.feature.client.createShareAccount.shareAccountDestination import com.mifos.feature.client.documentPreviewScreen.createDocumentPreviewRoute @@ -307,7 +309,7 @@ fun NavGraphBuilder.clientNavGraph( onNavigateApplyShareAccount = navController::navigateToShareAccountRoute, onNavigateApplyLoanAccount = navController::navigateToNewLoanAccountRoute, onNavigateApplySavingsAccount = navController::navigateToSavingsAccountRoute, - onNavigateApplyRecurringAccount = { }, + onNavigateApplyRecurringAccount = navController::navigateToRecurringAccountRoute, onNavigateApplyFixedAccount = { }, navController = navController, ) @@ -338,6 +340,8 @@ fun NavGraphBuilder.clientNavGraph( ) shareAccountDestination() + + recurringAccountDestination() } }