@@ -35,28 +35,27 @@ import androidx.compose.ui.unit.dp
3535import androidx.lifecycle.compose.collectAsStateWithLifecycle
3636import mifos_mobile.feature.savings_account.generated.resources.Res
3737import mifos_mobile.feature.savings_account.generated.resources.content_description_filter
38- import mifos_mobile.feature.savings_account.generated.resources.content_description_search
3938import mifos_mobile.feature.savings_account.generated.resources.feature_savings_account
4039import mifos_mobile.feature.savings_account.generated.resources.feature_savings_account_dashboard
4140import mifos_mobile.feature.savings_account.generated.resources.feature_savings_account_items
41+ import mifos_mobile.feature.savings_account.generated.resources.feature_savings_no_accounts_found
4242import org.jetbrains.compose.resources.StringResource
4343import org.jetbrains.compose.resources.stringResource
4444import org.jetbrains.compose.ui.tooling.preview.Preview
4545import org.koin.compose.viewmodel.koinViewModel
4646import org.mifos.mobile.core.common.Constants
4747import org.mifos.mobile.core.common.CurrencyFormatter
48- import org.mifos.mobile.core.designsystem.component.BasicDialogState
49- import org.mifos.mobile.core.designsystem.component.LoadingDialogState
50- import org.mifos.mobile.core.designsystem.component.MifosBasicDialog
51- import org.mifos.mobile.core.designsystem.component.MifosLoadingDialog
5248import org.mifos.mobile.core.designsystem.icon.MifosIcons
5349import org.mifos.mobile.core.designsystem.theme.AppColors
5450import org.mifos.mobile.core.designsystem.theme.DesignToken
5551import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme
5652import org.mifos.mobile.core.designsystem.theme.MifosTypography
5753import org.mifos.mobile.core.model.LoanStatus
54+ import org.mifos.mobile.core.ui.component.EmptyDataView
5855import org.mifos.mobile.core.ui.component.MifosAccountCard
5956import org.mifos.mobile.core.ui.component.MifosDashboardCard
57+ import org.mifos.mobile.core.ui.component.MifosErrorComponent
58+ import org.mifos.mobile.core.ui.component.MifosProgressIndicator
6059import org.mifos.mobile.core.ui.utils.EventsEffect
6160
6261@Composable
@@ -84,7 +83,6 @@ fun SavingsAccountScreen(
8483 when (event) {
8584 is SavingsAccountsEvent .NavigateBack -> navigateBack.invoke()
8685
87- // TODO uncomment this after designing account detail screen
8886 is SavingsAccountsEvent .AccountClicked -> {
8987 onAccountClicked(Constants .SAVINGS_ACCOUNT , event.accountId)
9088 }
@@ -117,16 +115,16 @@ internal fun SavingsAccountDialog(
117115 onAction : (SavingsAccountAction ) -> Unit ,
118116) {
119117 when (dialogState) {
120- is SavingsAccountState .DialogState .Error -> MifosBasicDialog (
121- visibilityState = BasicDialogState . Shown (
118+ is SavingsAccountState .DialogState .Error -> {
119+ MifosErrorComponent (
122120 message = dialogState.message,
123- ) ,
124- onDismissRequest = { onAction( SavingsAccountAction . OnDismissDialog ) } ,
125- )
126- is SavingsAccountState . DialogState . Loading -> MifosLoadingDialog (
127- visibilityState = LoadingDialogState . Shown ,
128- )
129-
121+ onRetry = { onAction( SavingsAccountAction . OnRetry ) } ,
122+ isRetryEnabled = true ,
123+ )
124+ }
125+ is SavingsAccountState . DialogState . Loading -> {
126+ MifosProgressIndicator ( )
127+ }
130128 null -> Unit
131129 }
132130}
@@ -142,67 +140,78 @@ internal fun SavingsAccountContent(
142140 .fillMaxSize()
143141 .padding(DesignToken .padding.large),
144142 ) {
145- Spacer (modifier = Modifier .height(DesignToken .spacing.large))
143+ if (state.dialogState == null ) {
144+ Spacer (modifier = Modifier .height(DesignToken .spacing.large))
146145
147- MifosDashboardCard (
148- isSingleLine = true ,
149- savingsAccount = Res .string.feature_savings_account_dashboard,
150- savingsAmount = state.totalSavingAmount,
151- isVisible = state.isAmountVisible,
152- currency = state.currency,
153- onVisibilityToggle = { onAction(SavingsAccountAction .ToggleAmountVisible ) },
154- )
155-
156- Spacer (modifier = Modifier .height(DesignToken .spacing.largeIncreased))
146+ MifosDashboardCard (
147+ isSingleLine = true ,
148+ savingsAccount = Res .string.feature_savings_account_dashboard,
149+ savingsAmount = state.totalSavingAmount,
150+ isVisible = state.isAmountVisible,
151+ currency = state.currency,
152+ onVisibilityToggle = { onAction(SavingsAccountAction .ToggleAmountVisible ) },
153+ )
157154
158- Row (
159- modifier = Modifier .fillMaxWidth(),
160- verticalAlignment = Alignment .CenterVertically ,
161- horizontalArrangement = Arrangement .SpaceBetween ,
162- ) {
163- Column {
164- Text (
165- text = stringResource(Res .string.feature_savings_account),
166- style = MifosTypography .titleMediumEmphasized,
167- color = MaterialTheme .colorScheme.onBackground,
168- )
169- Text (
170- text = stringResource(
171- Res .string.feature_savings_account_items,
172- state.items ? : 0 ,
173- ),
174- style = MifosTypography .labelMedium,
175- color = MaterialTheme .colorScheme.secondary,
176- )
177- }
155+ Spacer (modifier = Modifier .height(DesignToken .spacing.largeIncreased))
178156
179157 Row (
180- horizontalArrangement = Arrangement .spacedBy(DesignToken .spacing.largeIncreased),
158+ modifier = Modifier .fillMaxWidth(),
159+ verticalAlignment = Alignment .CenterVertically ,
160+ horizontalArrangement = Arrangement .SpaceBetween ,
181161 ) {
182- Icon (
183- modifier = Modifier
184- .clickable {}
185- .size(20 .dp),
186- imageVector = MifosIcons .SearchNew ,
187- contentDescription = stringResource(Res .string.content_description_search),
188- )
189- Icon (
190- modifier = Modifier
191- .clickable { filtersClicked() }
192- .size(20 .dp),
193- imageVector = MifosIcons .Filter ,
194- contentDescription = stringResource(Res .string.content_description_filter),
195- )
162+ Column {
163+ Text (
164+ text = stringResource(Res .string.feature_savings_account),
165+ style = MifosTypography .titleMediumEmphasized,
166+ color = MaterialTheme .colorScheme.onBackground,
167+ )
168+ Text (
169+ text = stringResource(
170+ Res .string.feature_savings_account_items,
171+ state.items ? : 0 ,
172+ ),
173+ style = MifosTypography .labelMedium,
174+ color = MaterialTheme .colorScheme.secondary,
175+ )
176+ }
177+
178+ Row (
179+ horizontalArrangement = Arrangement .spacedBy(DesignToken .spacing.largeIncreased),
180+ ) {
181+ // TODO : un-implemented feature,
182+ // commenting because user won't feels its good ,uncomment and implement it
183+ // Icon(
184+ // modifier = Modifier
185+ // .clickable {}
186+ // .size(20.dp),
187+ // imageVector = MifosIcons.SearchNew,
188+ // contentDescription = stringResource(Res.string.content_description_search),
189+ // )
190+ Icon (
191+ modifier = Modifier
192+ .clickable { filtersClicked() }
193+ .size(20 .dp),
194+ imageVector = MifosIcons .Filter ,
195+ contentDescription = stringResource(Res .string.content_description_filter),
196+ )
197+ }
196198 }
197- }
198199
199- Spacer (modifier = Modifier .height(DesignToken .spacing.medium))
200+ Spacer (modifier = Modifier .height(DesignToken .spacing.medium))
200201
201- HorizontalDivider (
202- modifier = Modifier
203- .fillMaxWidth()
204- .height(0.99997 .dp),
205- )
202+ HorizontalDivider (
203+ modifier = Modifier
204+ .fillMaxWidth()
205+ .height(0.99997 .dp),
206+ )
207+ }
208+
209+ if (state.isEmpty) {
210+ EmptyDataView (
211+ icon = MifosIcons .Info ,
212+ error = Res .string.feature_savings_no_accounts_found,
213+ )
214+ }
206215
207216 LazyColumn (
208217 modifier = Modifier
0 commit comments