From 0fc3748fd3b3918f000de16fa9c1c9b6fc6e7ebd Mon Sep 17 00:00:00 2001 From: revanthkumarJ Date: Tue, 26 Aug 2025 23:02:13 +0530 Subject: [PATCH 1/5] updated --- .../mifos/core/designsystem/theme/Color.kt | 1 + .../core/designsystem/theme/DesignToken.kt | 1 + .../mifos/core/ui/components/MifosStepper.kt | 142 ++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt diff --git a/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/Color.kt b/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/Color.kt index 14fe33b456f..5c6cd931b49 100644 --- a/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/Color.kt +++ b/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/Color.kt @@ -246,4 +246,5 @@ object AppColors { val lightRed = Color(0xFFFF6E6E) val peach = Color(0xFFFF926E) val lightPurple = Color(0xFF706EFF) + val stepperColor=Color(0xFF9ECAFC) } diff --git a/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/DesignToken.kt b/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/DesignToken.kt index 604c140c21f..254d38e263b 100644 --- a/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/DesignToken.kt +++ b/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/DesignToken.kt @@ -290,6 +290,7 @@ data class AppSizes( val iconExtraLarge: Dp = 36.dp, val avatarSmall: Dp = 32.dp, val avatarMedium: Dp = 48.dp, + val avatarMediumExtra:Dp=56.dp, val avatarLarge: Dp = 64.dp, val avatarLargeLarge: Dp = 128.dp, val buttonHeight: Dp = 56.dp, diff --git a/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt new file mode 100644 index 00000000000..74f7dadd62f --- /dev/null +++ b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt @@ -0,0 +1,142 @@ +/* + * 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.core.ui.components + +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.dp +import com.mifos.core.designsystem.theme.AppColors +import com.mifos.core.designsystem.theme.DesignToken +import com.mifos.core.designsystem.theme.MifosTypography +import org.jetbrains.compose.ui.tooling.preview.Preview + +data class Step( + val name: String, + val content: @Composable () -> Unit, +) + +@Composable +fun MifosStepper( + steps: List, + currentIndex: Int, + onStepChange: (Int) -> Unit, + modifier: Modifier = Modifier, +) { + Column( + modifier = modifier + .fillMaxWidth() + .padding( + vertical = DesignToken.padding.small, + horizontal = DesignToken.padding.large + ), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Row( + modifier = Modifier + .clip(shape = DesignToken.shapes.medium) + .background(MaterialTheme.colorScheme.primary) + .padding(vertical = DesignToken.padding.largeIncreasedExtra) + .fillMaxWidth(), + horizontalArrangement = Arrangement.Center, + verticalAlignment = Alignment.CenterVertically, + ) { + steps.forEachIndexed { index, step -> + Row( + verticalAlignment = Alignment.Top, + ) { + Column( + horizontalAlignment = Alignment.CenterHorizontally, + modifier=Modifier.width(DesignToken.sizes.avatarMediumExtra) + ) { + Box( + modifier = Modifier + .size(DesignToken.sizes.iconLarge) + .clip(CircleShape) + .background( + when { + index == currentIndex -> AppColors.customWhite + else -> AppColors.stepperColor + }, + ) + .clickable(enabled = index < currentIndex) { + if (index < currentIndex) onStepChange(index) + }, + contentAlignment = Alignment.Center, + ) { + Text( + text = (index + 1).toString(), + color = MaterialTheme.colorScheme.primary, + ) + } + + Spacer(modifier = Modifier.height(DesignToken.padding.small)) + Text( + text=step.name, + color = AppColors.customWhite, + style = MifosTypography.labelSmall, + maxLines = 1, + overflow = TextOverflow.Ellipsis + ) + } + if (index != steps.lastIndex) { + Box( + modifier = Modifier + .padding(vertical = DesignToken.padding.large) + .width(8.dp) + .height(1.dp) + .background(AppColors.customWhite) + ) + } + } + } + } + Spacer(Modifier.height(DesignToken.padding.largeIncreased)) + steps[currentIndex].content() + } +} + +@Preview +@Composable +fun MifosStepperDemo() { + val steps = listOf( + Step("Details") { Text("Step 1: Details Content") }, + Step("Terms") { Text("Step 2: Terms Content") }, + Step("Charges") { Text("Step 3: Charges Content") }, + Step("Schedule") { Text("Step 4: Schedule Content") }, + Step("Preview") { Text("Step 5: Preview Content") }, + ) + + MifosStepper( + steps = steps, + currentIndex = 2, + onStepChange = { }, + modifier = Modifier + .fillMaxWidth(), + ) +} From b7ac06e931334f15a2c31759c8f4751328a3a112 Mon Sep 17 00:00:00 2001 From: revanthkumarJ Date: Tue, 26 Aug 2025 23:17:50 +0530 Subject: [PATCH 2/5] updated --- .../com/mifos/core/designsystem/theme/Color.kt | 2 +- .../mifos/core/designsystem/theme/DesignToken.kt | 2 +- .../com/mifos/core/ui/components/MifosStepper.kt | 13 ++++++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/Color.kt b/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/Color.kt index 5c6cd931b49..624b70a85ac 100644 --- a/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/Color.kt +++ b/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/Color.kt @@ -246,5 +246,5 @@ object AppColors { val lightRed = Color(0xFFFF6E6E) val peach = Color(0xFFFF926E) val lightPurple = Color(0xFF706EFF) - val stepperColor=Color(0xFF9ECAFC) + val stepperColor = Color(0xFF9ECAFC) } diff --git a/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/DesignToken.kt b/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/DesignToken.kt index 254d38e263b..1627b3cc74b 100644 --- a/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/DesignToken.kt +++ b/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/DesignToken.kt @@ -290,7 +290,7 @@ data class AppSizes( val iconExtraLarge: Dp = 36.dp, val avatarSmall: Dp = 32.dp, val avatarMedium: Dp = 48.dp, - val avatarMediumExtra:Dp=56.dp, + val avatarMediumExtra: Dp = 56.dp, val avatarLarge: Dp = 64.dp, val avatarLargeLarge: Dp = 128.dp, val buttonHeight: Dp = 56.dp, diff --git a/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt index 74f7dadd62f..29dfb834e9f 100644 --- a/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt +++ b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt @@ -28,7 +28,6 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.mifos.core.designsystem.theme.AppColors @@ -53,7 +52,7 @@ fun MifosStepper( .fillMaxWidth() .padding( vertical = DesignToken.padding.small, - horizontal = DesignToken.padding.large + horizontal = DesignToken.padding.large, ), horizontalAlignment = Alignment.CenterHorizontally, ) { @@ -72,7 +71,7 @@ fun MifosStepper( ) { Column( horizontalAlignment = Alignment.CenterHorizontally, - modifier=Modifier.width(DesignToken.sizes.avatarMediumExtra) + modifier = Modifier.width(DesignToken.sizes.avatarMediumExtra), ) { Box( modifier = Modifier @@ -97,20 +96,20 @@ fun MifosStepper( Spacer(modifier = Modifier.height(DesignToken.padding.small)) Text( - text=step.name, + text = step.name, color = AppColors.customWhite, style = MifosTypography.labelSmall, maxLines = 1, - overflow = TextOverflow.Ellipsis + overflow = TextOverflow.Ellipsis, ) } if (index != steps.lastIndex) { Box( modifier = Modifier .padding(vertical = DesignToken.padding.large) - .width(8.dp) + .width(DesignToken.padding.small) .height(1.dp) - .background(AppColors.customWhite) + .background(AppColors.stepperColor), ) } } From 9395152609b92c5f6963d7a2c6cf6b220e486be6 Mon Sep 17 00:00:00 2001 From: revanthkumarJ Date: Wed, 27 Aug 2025 14:03:02 +0530 Subject: [PATCH 3/5] updated --- .../core/ui/components/MifosAutoResizeText.kt | 98 +++++++++++++++ .../mifos/core/ui/components/MifosStepper.kt | 100 +++++++++------- feature/savings/build.gradle.kts | 1 + .../savings/navigation/SavingsNavigation.kt | 3 + .../savingsAccountv2/SavingsAccountRoute.kt | 33 ++++++ .../savingsAccountv2/SavingsAccountScreen.kt | 112 ++++++++++++++++++ .../SavingsAccountViewModel.kt | 66 +++++++++++ .../savingsAccountv2/pages/ChargesPage.kt | 31 +++++ .../savingsAccountv2/pages/DetailsPage.kt | 31 +++++ .../savingsAccountv2/pages/PreviewPage.kt | 31 +++++ .../savingsAccountv2/pages/TermsPage.kt | 31 +++++ 11 files changed, 492 insertions(+), 45 deletions(-) create mode 100644 core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosAutoResizeText.kt create mode 100644 feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountRoute.kt create mode 100644 feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountScreen.kt create mode 100644 feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountViewModel.kt create mode 100644 feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/ChargesPage.kt create mode 100644 feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/DetailsPage.kt create mode 100644 feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/PreviewPage.kt create mode 100644 feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/TermsPage.kt diff --git a/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosAutoResizeText.kt b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosAutoResizeText.kt new file mode 100644 index 00000000000..99a2ab46d10 --- /dev/null +++ b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosAutoResizeText.kt @@ -0,0 +1,98 @@ +/* + * 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.core.ui.components + +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.drawWithContent +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontStyle +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextDecoration +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.TextUnit +import androidx.compose.ui.unit.sp + +@Composable +fun MifosAutoResizeText( + text: String, + fontSizeRange: FontSizeRange, + modifier: Modifier = Modifier, + color: Color = Color.Unspecified, + fontStyle: FontStyle? = null, + fontWeight: FontWeight? = null, + fontFamily: FontFamily? = null, + letterSpacing: TextUnit = TextUnit.Unspecified, + textDecoration: TextDecoration? = null, + textAlign: TextAlign? = null, + lineHeight: TextUnit = TextUnit.Unspecified, + overflow: TextOverflow = TextOverflow.Clip, + softWrap: Boolean = true, + maxLines: Int = Int.MAX_VALUE, + style: TextStyle = LocalTextStyle.current, +) { + var fontSizeValue by remember { mutableStateOf(fontSizeRange.max.value) } + var readyToDraw by remember { mutableStateOf(false) } + + Text( + text = text, + color = color, + maxLines = maxLines, + fontStyle = fontStyle, + fontWeight = fontWeight, + fontFamily = fontFamily, + letterSpacing = letterSpacing, + textDecoration = textDecoration, + textAlign = textAlign, + lineHeight = lineHeight, + overflow = overflow, + softWrap = softWrap, + style = style, + fontSize = fontSizeValue.sp, + onTextLayout = { + if (it.didOverflowHeight && !readyToDraw) { + val nextFontSizeValue = fontSizeValue - fontSizeRange.step.value + if (nextFontSizeValue <= fontSizeRange.min.value) { + fontSizeValue = fontSizeRange.min.value + readyToDraw = true + } else { + fontSizeValue = nextFontSizeValue + } + } else { + readyToDraw = true + } + }, + modifier = modifier.drawWithContent { if (readyToDraw) drawContent() }, + ) +} + +data class FontSizeRange( + val min: TextUnit, + val max: TextUnit, + val step: TextUnit = DEFAULT_TEXT_STEP, +) { + init { + require(min < max) { "min should be less than max, $this" } + require(step.value > 0) { "step should be greater than 0, $this" } + } + + companion object { + private val DEFAULT_TEXT_STEP = 1.sp + } +} diff --git a/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt index 29dfb834e9f..9dbdb7129b4 100644 --- a/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt +++ b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt @@ -11,7 +11,6 @@ package com.mifos.core.ui.components import androidx.compose.foundation.background import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -21,15 +20,18 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width +import androidx.compose.foundation.lazy.LazyRow +import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp import com.mifos.core.designsystem.theme.AppColors import com.mifos.core.designsystem.theme.DesignToken import com.mifos.core.designsystem.theme.MifosTypography @@ -47,6 +49,11 @@ fun MifosStepper( onStepChange: (Int) -> Unit, modifier: Modifier = Modifier, ) { + val listState = rememberLazyListState() + + LaunchedEffect(currentIndex) { + listState.animateScrollToItem(currentIndex) + } Column( modifier = modifier .fillMaxWidth() @@ -56,61 +63,64 @@ fun MifosStepper( ), horizontalAlignment = Alignment.CenterHorizontally, ) { - Row( + LazyRow( + state = listState, modifier = Modifier .clip(shape = DesignToken.shapes.medium) .background(MaterialTheme.colorScheme.primary) .padding(vertical = DesignToken.padding.largeIncreasedExtra) + .padding(start = DesignToken.padding.small) .fillMaxWidth(), - horizontalArrangement = Arrangement.Center, - verticalAlignment = Alignment.CenterVertically, ) { steps.forEachIndexed { index, step -> - Row( - verticalAlignment = Alignment.Top, - ) { - Column( - horizontalAlignment = Alignment.CenterHorizontally, - modifier = Modifier.width(DesignToken.sizes.avatarMediumExtra), + item { + Row( + verticalAlignment = Alignment.Top, ) { - Box( - modifier = Modifier - .size(DesignToken.sizes.iconLarge) - .clip(CircleShape) - .background( - when { - index == currentIndex -> AppColors.customWhite - else -> AppColors.stepperColor + Column( + horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier.width(DesignToken.sizes.avatarMediumExtra), + ) { + Box( + modifier = Modifier + .size(DesignToken.sizes.iconLarge) + .clip(CircleShape) + .background( + when { + index == currentIndex -> AppColors.customWhite + else -> AppColors.stepperColor + }, + ) + .clickable(enabled = index < currentIndex) { + if (index < currentIndex) onStepChange(index) }, + contentAlignment = Alignment.Center, + ) { + Text( + text = (index + 1).toString(), + color = MaterialTheme.colorScheme.primary, ) - .clickable(enabled = index < currentIndex) { - if (index < currentIndex) onStepChange(index) - }, - contentAlignment = Alignment.Center, - ) { - Text( - text = (index + 1).toString(), - color = MaterialTheme.colorScheme.primary, + } + + Spacer(modifier = Modifier.height(DesignToken.padding.small)) + MifosAutoResizeText( + text = step.name, + color = AppColors.customWhite, + style = MifosTypography.labelSmall, + fontSizeRange = FontSizeRange(2.sp, 11.sp), ) } - - Spacer(modifier = Modifier.height(DesignToken.padding.small)) - Text( - text = step.name, - color = AppColors.customWhite, - style = MifosTypography.labelSmall, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - ) - } - if (index != steps.lastIndex) { - Box( - modifier = Modifier - .padding(vertical = DesignToken.padding.large) - .width(DesignToken.padding.small) - .height(1.dp) - .background(AppColors.stepperColor), - ) + if (index != steps.lastIndex) { + Box( + modifier = Modifier + .padding(vertical = DesignToken.padding.large) + .width(DesignToken.padding.small) + .height(1.dp) + .background(AppColors.stepperColor), + ) + } else { + Spacer(Modifier.width(DesignToken.padding.small)) + } } } } diff --git a/feature/savings/build.gradle.kts b/feature/savings/build.gradle.kts index e1b16d1537a..53f95809bf9 100644 --- a/feature/savings/build.gradle.kts +++ b/feature/savings/build.gradle.kts @@ -9,6 +9,7 @@ */ plugins { alias(libs.plugins.mifos.cmp.feature) + alias(libs.plugins.kotlin.serialization) } android { diff --git a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/navigation/SavingsNavigation.kt b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/navigation/SavingsNavigation.kt index eefad9bdee9..5c5e9997bb3 100644 --- a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/navigation/SavingsNavigation.kt +++ b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/navigation/SavingsNavigation.kt @@ -21,6 +21,7 @@ import com.mifos.feature.savings.savingsAccountActivate.SavingsAccountActivateSc import com.mifos.feature.savings.savingsAccountApproval.SavingsAccountApprovalScreen import com.mifos.feature.savings.savingsAccountSummary.SavingsAccountSummaryScreen import com.mifos.feature.savings.savingsAccountTransaction.SavingsAccountTransactionScreen +import com.mifos.feature.savings.savingsAccountv2.savingsAccountDestination import com.mifos.room.entities.accounts.savings.SavingAccountDepositTypeEntity import com.mifos.room.entities.accounts.savings.SavingsAccountWithAssociationsEntity @@ -83,6 +84,8 @@ fun NavGraphBuilder.savingsNavGraph( savingsAccountTransactionScreen { onBackPressed() } + + savingsAccountDestination() } } diff --git a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountRoute.kt b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountRoute.kt new file mode 100644 index 00000000000..453e0d2282e --- /dev/null +++ b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountRoute.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.savings.savingsAccountv2 + +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.compose.composable +import kotlinx.serialization.Serializable + +@Serializable +data object SavingsAccountRoute + +fun NavGraphBuilder.savingsAccountDestination() { + composable { + SavingsAccountScreen( + onNavigateBack = {}, + onFinish = {}, + ) + } +} + +fun NavController.navigateToSavingsAccountRoute() { + this.navigate( + SavingsAccountRoute, + ) +} diff --git a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountScreen.kt b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountScreen.kt new file mode 100644 index 00000000000..4206a07b32c --- /dev/null +++ b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountScreen.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.savings.savingsAccountv2 + +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 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.savings.savingsAccountv2.pages.ChargesPage +import com.mifos.feature.savings.savingsAccountv2.pages.DetailsPage +import com.mifos.feature.savings.savingsAccountv2.pages.PreviewPage +import com.mifos.feature.savings.savingsAccountv2.pages.TermsPage + +@Composable +internal fun SavingsAccountScreen( + onNavigateBack: () -> Unit, + onFinish: () -> Unit, + modifier: Modifier = Modifier, + viewModel: SavingsAccountViewModel = androidx.lifecycle.viewmodel.compose.viewModel(), +) { + val state by viewModel.stateFlow.collectAsStateWithLifecycle() + + EventsEffect(viewModel.eventFlow) { event -> + when (event) { + SavingsAccountEvent.NavigateBack -> onNavigateBack() + SavingsAccountEvent.Finish -> onFinish() + } + } + + SavingsAccountScaffold( + modifier = modifier, + state = state, + onAction = { viewModel.trySendAction(it) }, + ) +} + +@Composable +private fun SavingsAccountScaffold( + state: SavingsAccountState, + modifier: Modifier = Modifier, + onAction: (SavingsAccountAction) -> Unit, +) { + val steps = listOf( + Step("Details") { + DetailsPage { + onAction(SavingsAccountAction.NextStep) + } + }, + Step("Terms") { + TermsPage { + onAction(SavingsAccountAction.NextStep) + } + }, + Step("Charges") { + ChargesPage { + onAction(SavingsAccountAction.NextStep) + } + }, + Step("Details") { + DetailsPage { + onAction(SavingsAccountAction.NextStep) + } + }, + Step("Terms of Service") { + TermsPage { + onAction(SavingsAccountAction.NextStep) + } + }, + Step("Charges") { + ChargesPage { + onAction(SavingsAccountAction.NextStep) + } + }, + Step("Preview") { + PreviewPage { + onAction(SavingsAccountAction.NextStep) + } + }, + ) + + MifosScaffold( + title = "Savings Account", + onBackPressed = { onAction(SavingsAccountAction.NavigateBack) }, + modifier = modifier, + ) { paddingValues -> + if (state.dialogState == null) { + MifosStepper( + steps = steps, + currentIndex = state.currentStep, + onStepChange = { newIndex -> + onAction(SavingsAccountAction.OnStepChange(newIndex)) + }, + modifier = Modifier + .fillMaxWidth() + .padding(paddingValues), + ) + } + } +} diff --git a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountViewModel.kt b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountViewModel.kt new file mode 100644 index 00000000000..ac19b821cdf --- /dev/null +++ b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountViewModel.kt @@ -0,0 +1,66 @@ +/* + * 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.savings.savingsAccountv2 + +import com.mifos.core.ui.util.BaseViewModel +import kotlinx.coroutines.flow.update + +internal class SavingsAccountViewModel : + BaseViewModel( + initialState = SavingsAccountState(), + ) { + + override fun handleAction(action: SavingsAccountAction) { + when (action) { + SavingsAccountAction.NavigateBack -> sendEvent(SavingsAccountEvent.NavigateBack) + SavingsAccountAction.NextStep -> moveToNextStep() + SavingsAccountAction.Finish -> sendEvent(SavingsAccountEvent.Finish) + is SavingsAccountAction.OnStepChange -> + mutableStateFlow.value = + mutableStateFlow.value.copy(currentStep = action.newIndex) + } + } + + private fun moveToNextStep() { + val current = state.currentStep + if (current < state.totalSteps) { + mutableStateFlow.update { + it.copy( + currentStep = current + 1, + ) + } + } else { + sendEvent(SavingsAccountEvent.Finish) + } + } +} + +data class SavingsAccountState( + val currentStep: Int = 0, + val totalSteps: Int = 7, + val dialogState: DialogState? = null, +) { + sealed interface DialogState { + data class Error(val message: String) : DialogState + data object Loading : DialogState + } +} + +sealed interface SavingsAccountEvent { + data object NavigateBack : SavingsAccountEvent + data object Finish : SavingsAccountEvent +} + +sealed interface SavingsAccountAction { + data object NavigateBack : SavingsAccountAction + data object NextStep : SavingsAccountAction + data object Finish : SavingsAccountAction + data class OnStepChange(val newIndex: Int) : SavingsAccountAction +} diff --git a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/ChargesPage.kt b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/ChargesPage.kt new file mode 100644 index 00000000000..c7f43ceedbf --- /dev/null +++ b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/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.savings.savingsAccountv2.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 Content") + Spacer(Modifier.height(8.dp)) + Button(onClick = onNext) { + Text("Next") + } + } +} diff --git a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/DetailsPage.kt b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/DetailsPage.kt new file mode 100644 index 00000000000..56ec656fa37 --- /dev/null +++ b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/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.savings.savingsAccountv2.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 Content") + Spacer(Modifier.height(8.dp)) + Button(onClick = onNext) { + Text("Next") + } + } +} diff --git a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/PreviewPage.kt b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/PreviewPage.kt new file mode 100644 index 00000000000..b6b7c894f65 --- /dev/null +++ b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/PreviewPage.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.savings.savingsAccountv2.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 PreviewPage(onNext: () -> Unit) { + Column(horizontalAlignment = Alignment.CenterHorizontally) { + Text("Preview Content") + Spacer(Modifier.height(8.dp)) + Button(onClick = onNext) { + Text("Next") + } + } +} diff --git a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/TermsPage.kt b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/TermsPage.kt new file mode 100644 index 00000000000..34bc13c2341 --- /dev/null +++ b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/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.savings.savingsAccountv2.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 Content") + Spacer(Modifier.height(8.dp)) + Button(onClick = onNext) { + Text("Next") + } + } +} From 027338436730e79920d4b39110aae50127b498e1 Mon Sep 17 00:00:00 2001 From: revanthkumarJ Date: Wed, 27 Aug 2025 14:17:38 +0530 Subject: [PATCH 4/5] updated --- .../navigation/navigation/FeatureNavHost.kt | 4 +- .../core/ui/components/MifosAutoResizeText.kt | 98 ------------------- .../mifos/core/ui/components/MifosStepper.kt | 13 ++- 3 files changed, 12 insertions(+), 103 deletions(-) delete mode 100644 core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosAutoResizeText.kt diff --git a/cmp-navigation/src/commonMain/kotlin/cmp/navigation/navigation/FeatureNavHost.kt b/cmp-navigation/src/commonMain/kotlin/cmp/navigation/navigation/FeatureNavHost.kt index 1c984c6444e..33988695087 100644 --- a/cmp-navigation/src/commonMain/kotlin/cmp/navigation/navigation/FeatureNavHost.kt +++ b/cmp-navigation/src/commonMain/kotlin/cmp/navigation/navigation/FeatureNavHost.kt @@ -54,6 +54,7 @@ import com.mifos.feature.report.navigation.reportNavGraph import com.mifos.feature.savings.navigation.navigateToAddSavingsAccount import com.mifos.feature.savings.navigation.navigateToSavingsAccountSummaryScreen import com.mifos.feature.savings.navigation.savingsNavGraph +import com.mifos.feature.savings.savingsAccountv2.navigateToSavingsAccountRoute import com.mifos.feature.search.navigation.searchNavGraph import com.mifos.feature.settings.navigation.settingsScreen @@ -118,7 +119,8 @@ internal fun FeatureNavHost( paddingValues = padding, onActivateCenter = appState.navController::navigateToActivateScreen, addSavingsAccount = { centerId -> - appState.navController.navigateToAddSavingsAccount(0, centerId, false) + appState.navController.navigateToSavingsAccountRoute() +// appState.navController.navigateToAddSavingsAccount(0, centerId, false) }, ) diff --git a/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosAutoResizeText.kt b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosAutoResizeText.kt deleted file mode 100644 index 99a2ab46d10..00000000000 --- a/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosAutoResizeText.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.core.ui.components - -import androidx.compose.material3.LocalTextStyle -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.drawWithContent -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.font.FontFamily -import androidx.compose.ui.text.font.FontStyle -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.text.style.TextDecoration -import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.unit.TextUnit -import androidx.compose.ui.unit.sp - -@Composable -fun MifosAutoResizeText( - text: String, - fontSizeRange: FontSizeRange, - modifier: Modifier = Modifier, - color: Color = Color.Unspecified, - fontStyle: FontStyle? = null, - fontWeight: FontWeight? = null, - fontFamily: FontFamily? = null, - letterSpacing: TextUnit = TextUnit.Unspecified, - textDecoration: TextDecoration? = null, - textAlign: TextAlign? = null, - lineHeight: TextUnit = TextUnit.Unspecified, - overflow: TextOverflow = TextOverflow.Clip, - softWrap: Boolean = true, - maxLines: Int = Int.MAX_VALUE, - style: TextStyle = LocalTextStyle.current, -) { - var fontSizeValue by remember { mutableStateOf(fontSizeRange.max.value) } - var readyToDraw by remember { mutableStateOf(false) } - - Text( - text = text, - color = color, - maxLines = maxLines, - fontStyle = fontStyle, - fontWeight = fontWeight, - fontFamily = fontFamily, - letterSpacing = letterSpacing, - textDecoration = textDecoration, - textAlign = textAlign, - lineHeight = lineHeight, - overflow = overflow, - softWrap = softWrap, - style = style, - fontSize = fontSizeValue.sp, - onTextLayout = { - if (it.didOverflowHeight && !readyToDraw) { - val nextFontSizeValue = fontSizeValue - fontSizeRange.step.value - if (nextFontSizeValue <= fontSizeRange.min.value) { - fontSizeValue = fontSizeRange.min.value - readyToDraw = true - } else { - fontSizeValue = nextFontSizeValue - } - } else { - readyToDraw = true - } - }, - modifier = modifier.drawWithContent { if (readyToDraw) drawContent() }, - ) -} - -data class FontSizeRange( - val min: TextUnit, - val max: TextUnit, - val step: TextUnit = DEFAULT_TEXT_STEP, -) { - init { - require(min < max) { "min should be less than max, $this" } - require(step.value > 0) { "step should be greater than 0, $this" } - } - - companion object { - private val DEFAULT_TEXT_STEP = 1.sp - } -} diff --git a/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt index 9dbdb7129b4..bbcfd3a72a3 100644 --- a/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt +++ b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt @@ -23,6 +23,8 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.text.BasicText +import androidx.compose.foundation.text.TextAutoSize import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -103,11 +105,14 @@ fun MifosStepper( } Spacer(modifier = Modifier.height(DesignToken.padding.small)) - MifosAutoResizeText( + BasicText( text = step.name, - color = AppColors.customWhite, - style = MifosTypography.labelSmall, - fontSizeRange = FontSizeRange(2.sp, 11.sp), + autoSize = TextAutoSize.StepBased( + minFontSize = 2.sp, maxFontSize = 11.sp + ), + style = MifosTypography.labelSmall.copy( + color = AppColors.customWhite + ), ) } if (index != steps.lastIndex) { From ee3d8ae7ecc73a0bc16500763da9b967f858b866 Mon Sep 17 00:00:00 2001 From: revanthkumarJ Date: Wed, 27 Aug 2025 15:13:31 +0530 Subject: [PATCH 5/5] updated --- .../navigation/navigation/FeatureNavHost.kt | 4 +-- .../mifos/core/ui/components/MifosStepper.kt | 5 +-- .../values/feature_savings_strings.xml | 4 +++ .../savingsAccountv2/SavingsAccountScreen.kt | 32 +++++++------------ .../SavingsAccountViewModel.kt | 2 +- .../savingsAccountv2/pages/ChargesPage.kt | 8 +++-- .../savingsAccountv2/pages/DetailsPage.kt | 8 +++-- .../savingsAccountv2/pages/PreviewPage.kt | 8 +++-- .../savingsAccountv2/pages/TermsPage.kt | 8 +++-- 9 files changed, 45 insertions(+), 34 deletions(-) diff --git a/cmp-navigation/src/commonMain/kotlin/cmp/navigation/navigation/FeatureNavHost.kt b/cmp-navigation/src/commonMain/kotlin/cmp/navigation/navigation/FeatureNavHost.kt index 206de10eedd..91f97a2d5e0 100644 --- a/cmp-navigation/src/commonMain/kotlin/cmp/navigation/navigation/FeatureNavHost.kt +++ b/cmp-navigation/src/commonMain/kotlin/cmp/navigation/navigation/FeatureNavHost.kt @@ -54,7 +54,6 @@ import com.mifos.feature.report.navigation.reportNavGraph import com.mifos.feature.savings.navigation.navigateToAddSavingsAccount import com.mifos.feature.savings.navigation.navigateToSavingsAccountSummaryScreen import com.mifos.feature.savings.navigation.savingsNavGraph -import com.mifos.feature.savings.savingsAccountv2.navigateToSavingsAccountRoute import com.mifos.feature.search.navigation.searchNavGraph import com.mifos.feature.settings.navigation.settingsScreen @@ -122,8 +121,7 @@ internal fun FeatureNavHost( paddingValues = padding, onActivateCenter = appState.navController::navigateToActivateScreen, addSavingsAccount = { centerId -> - appState.navController.navigateToSavingsAccountRoute() -// appState.navController.navigateToAddSavingsAccount(0, centerId, false) + appState.navController.navigateToAddSavingsAccount(0, centerId, false) }, ) diff --git a/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt index bbcfd3a72a3..79b1a1cf9c5 100644 --- a/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt +++ b/core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosStepper.kt @@ -108,10 +108,11 @@ fun MifosStepper( BasicText( text = step.name, autoSize = TextAutoSize.StepBased( - minFontSize = 2.sp, maxFontSize = 11.sp + minFontSize = 2.sp, + maxFontSize = 11.sp, ), style = MifosTypography.labelSmall.copy( - color = AppColors.customWhite + color = AppColors.customWhite, ), ) } diff --git a/feature/savings/src/commonMain/composeResources/values/feature_savings_strings.xml b/feature/savings/src/commonMain/composeResources/values/feature_savings_strings.xml index c7cd6ea52f4..aae0d047649 100644 --- a/feature/savings/src/commonMain/composeResources/values/feature_savings_strings.xml +++ b/feature/savings/src/commonMain/composeResources/values/feature_savings_strings.xml @@ -95,6 +95,10 @@ Savings Account Id View Receipt + Details + Terms + Charges + Preview diff --git a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountScreen.kt b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountScreen.kt index 4206a07b32c..d321d74c123 100644 --- a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountScreen.kt +++ b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountScreen.kt @@ -9,6 +9,12 @@ */ package com.mifos.feature.savings.savingsAccountv2 +import androidclient.feature.savings.generated.resources.Res +import androidclient.feature.savings.generated.resources.feature_savings_create_savings_account +import androidclient.feature.savings.generated.resources.step_charges +import androidclient.feature.savings.generated.resources.step_details +import androidclient.feature.savings.generated.resources.step_preview +import androidclient.feature.savings.generated.resources.step_terms import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable @@ -23,6 +29,7 @@ import com.mifos.feature.savings.savingsAccountv2.pages.ChargesPage import com.mifos.feature.savings.savingsAccountv2.pages.DetailsPage import com.mifos.feature.savings.savingsAccountv2.pages.PreviewPage import com.mifos.feature.savings.savingsAccountv2.pages.TermsPage +import org.jetbrains.compose.resources.stringResource @Composable internal fun SavingsAccountScreen( @@ -54,37 +61,22 @@ private fun SavingsAccountScaffold( onAction: (SavingsAccountAction) -> Unit, ) { val steps = listOf( - Step("Details") { + Step(stringResource(Res.string.step_details)) { DetailsPage { onAction(SavingsAccountAction.NextStep) } }, - Step("Terms") { + Step(stringResource(Res.string.step_terms)) { TermsPage { onAction(SavingsAccountAction.NextStep) } }, - Step("Charges") { + Step(stringResource(Res.string.step_charges)) { ChargesPage { onAction(SavingsAccountAction.NextStep) } }, - Step("Details") { - DetailsPage { - onAction(SavingsAccountAction.NextStep) - } - }, - Step("Terms of Service") { - TermsPage { - onAction(SavingsAccountAction.NextStep) - } - }, - Step("Charges") { - ChargesPage { - onAction(SavingsAccountAction.NextStep) - } - }, - Step("Preview") { + Step(stringResource(Res.string.step_preview)) { PreviewPage { onAction(SavingsAccountAction.NextStep) } @@ -92,7 +84,7 @@ private fun SavingsAccountScaffold( ) MifosScaffold( - title = "Savings Account", + title = stringResource(Res.string.feature_savings_create_savings_account), onBackPressed = { onAction(SavingsAccountAction.NavigateBack) }, modifier = modifier, ) { paddingValues -> diff --git a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountViewModel.kt b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountViewModel.kt index ac19b821cdf..2c36356e21c 100644 --- a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountViewModel.kt +++ b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/SavingsAccountViewModel.kt @@ -44,7 +44,7 @@ internal class SavingsAccountViewModel : data class SavingsAccountState( val currentStep: Int = 0, - val totalSteps: Int = 7, + val totalSteps: Int = 4, val dialogState: DialogState? = null, ) { sealed interface DialogState { diff --git a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/ChargesPage.kt b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/ChargesPage.kt index c7f43ceedbf..377c7ba2775 100644 --- a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/ChargesPage.kt +++ b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/ChargesPage.kt @@ -9,6 +9,9 @@ */ package com.mifos.feature.savings.savingsAccountv2.pages +import androidclient.feature.savings.generated.resources.Res +import androidclient.feature.savings.generated.resources.feature_savings_submit +import androidclient.feature.savings.generated.resources.step_charges import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height @@ -18,14 +21,15 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import org.jetbrains.compose.resources.stringResource @Composable fun ChargesPage(onNext: () -> Unit) { Column(horizontalAlignment = Alignment.CenterHorizontally) { - Text("Charges Content") + Text(stringResource(Res.string.step_charges)) Spacer(Modifier.height(8.dp)) Button(onClick = onNext) { - Text("Next") + Text(stringResource(Res.string.feature_savings_submit)) } } } diff --git a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/DetailsPage.kt b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/DetailsPage.kt index 56ec656fa37..317df67dad3 100644 --- a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/DetailsPage.kt +++ b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/DetailsPage.kt @@ -9,6 +9,9 @@ */ package com.mifos.feature.savings.savingsAccountv2.pages +import androidclient.feature.savings.generated.resources.Res +import androidclient.feature.savings.generated.resources.feature_savings_submit +import androidclient.feature.savings.generated.resources.step_details import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height @@ -18,14 +21,15 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import org.jetbrains.compose.resources.stringResource @Composable fun DetailsPage(onNext: () -> Unit) { Column(horizontalAlignment = Alignment.CenterHorizontally) { - Text("Details Content") + Text(stringResource(Res.string.step_details)) Spacer(Modifier.height(8.dp)) Button(onClick = onNext) { - Text("Next") + Text(stringResource(Res.string.feature_savings_submit)) } } } diff --git a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/PreviewPage.kt b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/PreviewPage.kt index b6b7c894f65..8c6b124c746 100644 --- a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/PreviewPage.kt +++ b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/PreviewPage.kt @@ -9,6 +9,9 @@ */ package com.mifos.feature.savings.savingsAccountv2.pages +import androidclient.feature.savings.generated.resources.Res +import androidclient.feature.savings.generated.resources.feature_savings_submit +import androidclient.feature.savings.generated.resources.step_preview import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height @@ -18,14 +21,15 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import org.jetbrains.compose.resources.stringResource @Composable fun PreviewPage(onNext: () -> Unit) { Column(horizontalAlignment = Alignment.CenterHorizontally) { - Text("Preview Content") + Text(stringResource(Res.string.step_preview)) Spacer(Modifier.height(8.dp)) Button(onClick = onNext) { - Text("Next") + Text(stringResource(Res.string.feature_savings_submit)) } } } diff --git a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/TermsPage.kt b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/TermsPage.kt index 34bc13c2341..e335bee6bef 100644 --- a/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/TermsPage.kt +++ b/feature/savings/src/commonMain/kotlin/com/mifos/feature/savings/savingsAccountv2/pages/TermsPage.kt @@ -9,6 +9,9 @@ */ package com.mifos.feature.savings.savingsAccountv2.pages +import androidclient.feature.savings.generated.resources.Res +import androidclient.feature.savings.generated.resources.feature_savings_submit +import androidclient.feature.savings.generated.resources.step_terms import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height @@ -18,14 +21,15 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import org.jetbrains.compose.resources.stringResource @Composable fun TermsPage(onNext: () -> Unit) { Column(horizontalAlignment = Alignment.CenterHorizontally) { - Text("Terms Content") + Text(stringResource(Res.string.step_terms)) Spacer(Modifier.height(8.dp)) Button(onClick = onNext) { - Text("Next") + Text(stringResource(Res.string.feature_savings_submit)) } } }