@@ -40,6 +40,7 @@ import mifos_mobile.feature.savings_account.generated.resources.feature_account_
4040import mifos_mobile.feature.savings_account.generated.resources.feature_savings_account
4141import mifos_mobile.feature.savings_account.generated.resources.feature_savings_account_dashboard
4242import mifos_mobile.feature.savings_account.generated.resources.feature_savings_account_items
43+ import mifos_mobile.feature.savings_account.generated.resources.feature_savings_filter_pending_account
4344import mifos_mobile.feature.savings_account.generated.resources.feature_savings_no_accounts_found
4445import org.jetbrains.compose.resources.StringResource
4546import org.jetbrains.compose.resources.stringResource
@@ -52,15 +53,14 @@ import org.mifos.mobile.core.designsystem.theme.AppColors
5253import org.mifos.mobile.core.designsystem.theme.DesignToken
5354import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme
5455import org.mifos.mobile.core.designsystem.theme.MifosTypography
55- import org.mifos.mobile.core.model.LoanStatus
56+ import org.mifos.mobile.core.model.SavingStatus
5657import org.mifos.mobile.core.ui.component.EmptyDataView
5758import org.mifos.mobile.core.ui.component.MifosAccountCard
5859import org.mifos.mobile.core.ui.component.MifosDashboardCard
5960import org.mifos.mobile.core.ui.component.MifosErrorComponent
6061import org.mifos.mobile.core.ui.component.MifosProgressIndicator
6162import org.mifos.mobile.core.ui.utils.EventsEffect
6263import org.mifos.mobile.core.ui.utils.ScreenUiState
63- import kotlin.collections.orEmpty
6464
6565@Composable
6666fun SavingsAccountScreen (
@@ -91,29 +91,21 @@ fun SavingsAccountScreen(
9191 EventsEffect (viewModel.eventFlow) { event ->
9292 when (event) {
9393 is SavingsAccountsEvent .NavigateBack -> navigateBack.invoke()
94-
9594 is SavingsAccountsEvent .AccountClicked -> {
9695 onAccountClicked(Constants .SAVINGS_ACCOUNT , event.accountId)
9796 }
98-
99- is SavingsAccountsEvent .LoadingCompleted -> {
100- onLoadingCompleted.invoke()
101- }
97+ is SavingsAccountsEvent .LoadingCompleted -> onLoadingCompleted.invoke()
10298 }
10399 }
104100
105101 SavingsAccountDialog (
106102 dialogState = state.dialogState,
107- onAction = remember(viewModel) {
108- { viewModel.trySendAction(it) }
109- },
103+ onAction = remember(viewModel) { { viewModel.trySendAction(it) } },
110104 )
111105
112106 SavingsAccountContent (
113107 state = state,
114- onAction = remember(viewModel) {
115- { viewModel.trySendAction(it) }
116- },
108+ onAction = remember(viewModel) { { viewModel.trySendAction(it) } },
117109 filtersClicked = filtersClicked,
118110 )
119111}
@@ -131,7 +123,6 @@ internal fun SavingsAccountDialog(
131123 isRetryEnabled = true ,
132124 )
133125 }
134-
135126 null -> Unit
136127 }
137128}
@@ -210,19 +201,7 @@ internal fun SavingsAccountContent(
210201 )
211202 }
212203
213- Row (
214- horizontalArrangement = Arrangement .spacedBy(DesignToken .spacing.largeIncreased),
215- ) {
216- // TODO : un-implemented feature,
217- // commenting because user won't feels its good ,uncomment and implement it
218- // Icon(
219- // modifier = Modifier
220- // .clickable {}
221- // .size(20.dp),
222- // imageVector = MifosIcons.SearchNew,
223- // contentDescription =
224- // stringResource(Res.string.content_description_search),
225- // )
204+ Row (horizontalArrangement = Arrangement .spacedBy(DesignToken .spacing.largeIncreased)) {
226205 Icon (
227206 modifier = Modifier
228207 .clickable { filtersClicked() }
@@ -254,38 +233,41 @@ internal fun SavingsAccountContent(
254233 )
255234 }
256235 } else {
236+ val accounts = state.savingsAccount.orEmpty()
257237 LazyColumn (
258238 modifier = Modifier
259239 .fillMaxSize()
260240 .weight(1f ),
261241 ) {
262- item {
263- Spacer (modifier = Modifier .height(DesignToken .spacing.small))
264- }
265- items(state.savingsAccount.orEmpty()) { account ->
242+ item { Spacer (modifier = Modifier .height(DesignToken .spacing.small)) }
243+
244+ items(accounts) { account ->
266245 val color = when (account.status?.value) {
267- LoanStatus .ACTIVE .status -> AppColors .customEnable
268- LoanStatus .SUBMIT_AND_PENDING_APPROVAL .status -> AppColors .customYellow
269- LoanStatus .WITHDRAWN .status, LoanStatus .MATURED .status ->
270- MaterialTheme .colorScheme.error
246+ SavingStatus .ACTIVE .status -> AppColors .customEnable
247+ SavingStatus .SUBMIT_AND_PENDING_APPROVAL .status -> AppColors .customYellow
248+ SavingStatus .INACTIVE .status -> MaterialTheme .colorScheme.error
271249 else -> MaterialTheme .colorScheme.onSurface
272250 }
273251
252+ val accountStatus = if (account.status?.active == true ) {
253+ CurrencyFormatter .format(
254+ account.accountBalance,
255+ account.currency?.code,
256+ account.currency?.decimalPlaces,
257+ )
258+ } else {
259+ if (account.status?.value == SavingStatus .SUBMIT_AND_PENDING_APPROVAL .status) {
260+ stringResource(Res .string.feature_savings_filter_pending_account)
261+ } else {
262+ account.status?.value ? : " "
263+ }
264+ }
265+
274266 MifosAccountCard (
275267 accountId = account.id,
276268 accountNumber = account.accountNo,
277269 accountType = account.productName,
278- accountStatus = (
279- if (account.status?.active == true ) {
280- CurrencyFormatter .format(
281- account.accountBalance,
282- account.currency?.code,
283- account.currency?.decimalPlaces,
284- )
285- } else {
286- account.status?.value ? : " "
287- }
288- ),
270+ accountStatus = accountStatus,
289271 accountStatusColor = color,
290272 onAccountClick = {
291273 onAction(
0 commit comments