Skip to content

Commit a16c0fc

Browse files
updated progess bars and states (#2881)
1 parent e440f59 commit a16c0fc

File tree

5 files changed

+98
-78
lines changed

5 files changed

+98
-78
lines changed

feature/home/src/commonMain/kotlin/org/mifos/mobile/feature/home/HomeScreen.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,15 @@ import org.jetbrains.compose.ui.tooling.preview.Preview
4848
import org.koin.compose.viewmodel.koinViewModel
4949
import org.mifos.mobile.core.common.Constants
5050
import org.mifos.mobile.core.designsystem.component.BasicDialogState
51-
import org.mifos.mobile.core.designsystem.component.LoadingDialogState
5251
import org.mifos.mobile.core.designsystem.component.MifosBasicDialog
5352
import org.mifos.mobile.core.designsystem.component.MifosElevatedScaffold
54-
import org.mifos.mobile.core.designsystem.component.MifosLoadingDialog
5553
import org.mifos.mobile.core.designsystem.icon.MifosIcons
5654
import org.mifos.mobile.core.designsystem.theme.AppColors
5755
import org.mifos.mobile.core.designsystem.theme.DesignToken
5856
import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme
5957
import org.mifos.mobile.core.designsystem.theme.MifosTypography
6058
import org.mifos.mobile.core.ui.component.MifosDashboardCard
59+
import org.mifos.mobile.core.ui.component.MifosProgressIndicator
6160
import org.mifos.mobile.core.ui.utils.EventsEffect
6261

6362
@Composable
@@ -263,9 +262,10 @@ private fun HomeScreenDialog(
263262
),
264263
onDismissRequest = { onAction(HomeAction.OnDismissDialog) },
265264
)
266-
is HomeState.DialogState.Loading -> MifosLoadingDialog(
267-
visibilityState = LoadingDialogState.Shown,
268-
)
265+
266+
is HomeState.DialogState.Loading -> {
267+
MifosProgressIndicator()
268+
}
269269

270270
null -> Unit
271271
}

feature/savings-account/src/commonMain/composeResources/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,6 @@
9191
<string name="feature_savings_withdraw_request_successful_message">Request to withdraw the account is submitted successfully </string>
9292
<string name="feature_savings_withdraw_request_failed">Request Failed To Submit</string>
9393
<string name="feature_savings_withdraw_request_failed_message">Request to withdraw the account is failed. Please try again </string>
94+
95+
<string name="feature_savings_no_accounts_found">No Savings Accounts Found</string>
9496
</resources>

feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt

Lines changed: 77 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,27 @@ import androidx.compose.ui.unit.dp
3535
import androidx.lifecycle.compose.collectAsStateWithLifecycle
3636
import mifos_mobile.feature.savings_account.generated.resources.Res
3737
import mifos_mobile.feature.savings_account.generated.resources.content_description_filter
38-
import mifos_mobile.feature.savings_account.generated.resources.content_description_search
3938
import mifos_mobile.feature.savings_account.generated.resources.feature_savings_account
4039
import mifos_mobile.feature.savings_account.generated.resources.feature_savings_account_dashboard
4140
import 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
4242
import org.jetbrains.compose.resources.StringResource
4343
import org.jetbrains.compose.resources.stringResource
4444
import org.jetbrains.compose.ui.tooling.preview.Preview
4545
import org.koin.compose.viewmodel.koinViewModel
4646
import org.mifos.mobile.core.common.Constants
4747
import 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
5248
import org.mifos.mobile.core.designsystem.icon.MifosIcons
5349
import org.mifos.mobile.core.designsystem.theme.AppColors
5450
import org.mifos.mobile.core.designsystem.theme.DesignToken
5551
import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme
5652
import org.mifos.mobile.core.designsystem.theme.MifosTypography
5753
import org.mifos.mobile.core.model.LoanStatus
54+
import org.mifos.mobile.core.ui.component.EmptyDataView
5855
import org.mifos.mobile.core.ui.component.MifosAccountCard
5956
import 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
6059
import 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

feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ class SavingsAccountViewmodel(
6868
is SavingsAccountAction.Internal.ReceiveSavingsAccounts -> {
6969
handleReceivedAccounts(action.dataState, action.filters)
7070
}
71+
72+
SavingsAccountAction.OnRetry -> {
73+
handleAction(SavingsAccountAction.LoadAccounts(emptyList()))
74+
}
7175
}
7276
}
7377

@@ -122,6 +126,7 @@ class SavingsAccountViewmodel(
122126
savingsAccount = filtered,
123127
selectedFilters = selectedFilters,
124128
dialogState = null,
129+
isEmpty = filtered.isEmpty(),
125130
)
126131
}
127132
sendEvent(SavingsAccountsEvent.LoadingCompleted)
@@ -184,6 +189,7 @@ class SavingsAccountViewmodel(
184189
it.copy(
185190
items = filtered.size,
186191
savingsAccount = filtered,
192+
isEmpty = filtered.isEmpty(),
187193
originalAccounts = allSavings,
188194
currency = allSavings.firstOrNull()?.currency?.displaySymbol,
189195
dialogState = null,
@@ -268,6 +274,8 @@ data class SavingsAccountState(
268274

269275
/** Controls whether account balances are visible */
270276
val isAmountVisible: Boolean = false,
277+
278+
val isEmpty: Boolean = false,
271279
) {
272280

273281
/**
@@ -284,6 +292,8 @@ data class SavingsAccountState(
284292
*/
285293
sealed interface SavingsAccountAction {
286294

295+
data object OnRetry : SavingsAccountAction
296+
287297
/** Dismiss any open dialog */
288298
data object OnDismissDialog : SavingsAccountAction
289299

feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccountDetails/SavingsAccountDetailsScreen.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ import org.jetbrains.compose.ui.tooling.preview.Preview
4646
import org.koin.compose.viewmodel.koinViewModel
4747
import org.mifos.mobile.core.common.Constants
4848
import org.mifos.mobile.core.designsystem.component.BasicDialogState
49-
import org.mifos.mobile.core.designsystem.component.LoadingDialogState
5049
import org.mifos.mobile.core.designsystem.component.MifosBasicDialog
5150
import org.mifos.mobile.core.designsystem.component.MifosElevatedScaffold
52-
import org.mifos.mobile.core.designsystem.component.MifosLoadingDialog
5351
import org.mifos.mobile.core.designsystem.icon.MifosIcons
5452
import org.mifos.mobile.core.designsystem.theme.AppColors
5553
import org.mifos.mobile.core.designsystem.theme.DesignToken
@@ -59,6 +57,7 @@ import org.mifos.mobile.core.model.enums.ChargeType
5957
import org.mifos.mobile.core.ui.component.MifosActionCard
6058
import org.mifos.mobile.core.ui.component.MifosLabelValueCard
6159
import org.mifos.mobile.core.ui.component.MifosPoweredCard
60+
import org.mifos.mobile.core.ui.component.MifosProgressIndicator
6261
import org.mifos.mobile.core.ui.utils.EventsEffect
6362
import org.mifos.mobile.feature.savingsaccount.components.SavingsActionItems
6463
import org.mifos.mobile.feature.savingsaccount.components.savingsAccountActions
@@ -346,9 +345,9 @@ internal fun SavingsAccountDialogs(
346345
onDismissRequest = { onAction(SavingsAccountDetailsAction.DismissDialog) },
347346
)
348347

349-
is SavingsAccountDetailsState.DialogState.Loading -> MifosLoadingDialog(
350-
visibilityState = LoadingDialogState.Shown,
351-
)
348+
is SavingsAccountDetailsState.DialogState.Loading -> {
349+
MifosProgressIndicator()
350+
}
352351

353352
null -> Unit
354353
}

0 commit comments

Comments
 (0)