Skip to content

Commit 474e96b

Browse files
committed
refactor(home): improve empty state dashboard card
This commit refactors the `MifosAccountApplyDashboard` composable: - Removes the top section containing the user's name and welcome message. - Changes the card variant from `ELEVATED` to `OUTLINED`. - Removes unnecessary background and shadow modifiers. - Updates padding and button shape. Additionally: - The greeting message in `HomeScreen` is now always displayed, regardless of account presence. - The default value for `isAccountsPresent` in `HomeUiState` is changed to `false`. - The order of `BottomSheetItemType` enum values is adjusted.
1 parent ef69dcb commit 474e96b

File tree

5 files changed

+59
-124
lines changed

5 files changed

+59
-124
lines changed

core/ui/src/commonMain/kotlin/org/mifos/mobile/core/ui/component/MifosDashboardCard.kt

Lines changed: 46 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import androidx.compose.runtime.Composable
3838
import androidx.compose.ui.Alignment
3939
import androidx.compose.ui.Modifier
4040
import androidx.compose.ui.draw.clip
41-
import androidx.compose.ui.draw.shadow
4241
import androidx.compose.ui.graphics.Color
4342
import androidx.compose.ui.layout.ContentScale
4443
import androidx.compose.ui.text.style.TextAlign
@@ -47,7 +46,6 @@ import mifos_mobile.core.ui.generated.resources.Res
4746
import mifos_mobile.core.ui.generated.resources.feature_dashboard_no_accounts_description
4847
import mifos_mobile.core.ui.generated.resources.feature_dashboard_no_accounts_title
4948
import mifos_mobile.core.ui.generated.resources.feature_dashboard_open_account
50-
import mifos_mobile.core.ui.generated.resources.feature_dashboard_welcome_back
5149
import mifos_mobile.core.ui.generated.resources.ic_icon_dashboard
5250
import mifos_mobile.core.ui.generated.resources.powered_by
5351
import org.jetbrains.compose.resources.StringResource
@@ -171,124 +169,68 @@ fun MifosDashboardCard(
171169

172170
@Composable
173171
fun MifosAccountApplyDashboard(
174-
userName: String,
175172
onOpenAccountClick: () -> Unit,
176173
) {
177174
MifosCustomCard(
178175
modifier = Modifier
176+
.padding(horizontal = DesignToken.padding.largeIncreased)
179177
.border(
180-
0.dp,
181-
Color.Transparent,
182-
)
183-
.shadow(
184-
elevation = 7.dp,
185-
shape = DesignToken.shapes.bottomSheet,
186-
spotColor = MaterialTheme.colorScheme.onSurface,
187-
ambientColor = MaterialTheme.colorScheme.onSurface,
178+
0.5.dp,
179+
MaterialTheme.colorScheme.primary,
180+
DesignToken.shapes.medium,
188181
),
189-
variant = CardVariant.ELEVATED,
182+
variant = CardVariant.OUTLINED,
190183
enabled = false,
191-
elevation = CardDefaults.elevatedCardElevation(
192-
defaultElevation = DesignToken.elevation.elevation,
184+
onClick = onOpenAccountClick,
185+
colors = CardDefaults.cardColors(
186+
containerColor = Color.Transparent,
187+
contentColor = MaterialTheme.colorScheme.onSurface,
193188
),
194189
) {
195190
Column(
196191
modifier = Modifier
197-
.fillMaxWidth()
198192
.background(
199-
color = Color.Transparent,
200-
shape = DesignToken.shapes.bottomSheet,
201-
),
202-
) {
203-
Column(
204-
modifier = Modifier
205-
.fillMaxWidth()
206-
.background(
207-
color = MaterialTheme.colorScheme.primary,
208-
shape = DesignToken.shapes.bottomSheet,
209-
)
210-
.padding(DesignToken.padding.large),
211-
verticalArrangement = Arrangement.spacedBy(DesignToken.spacing.small),
212-
) {
213-
Text(
214-
text = userName,
215-
style = MifosTypography.titleLarge,
216-
color = MaterialTheme.colorScheme.surface,
193+
MaterialTheme.colorScheme.onSurface.copy(alpha = 0.01f),
217194
)
218-
Text(
219-
text = stringResource(Res.string.feature_dashboard_welcome_back),
220-
color = MaterialTheme.colorScheme.surface,
221-
style = MifosTypography.titleSmallEmphasized,
222-
)
223-
}
224-
225-
Column(
226-
modifier = Modifier
227-
.fillMaxWidth(),
228-
) {
229-
MifosCustomCard(
230-
modifier = Modifier
231-
.padding(DesignToken.padding.largeIncreased)
232-
.border(
233-
0.5.dp,
234-
MaterialTheme.colorScheme.primary,
235-
DesignToken.shapes.medium,
236-
),
237-
variant = CardVariant.ELEVATED,
238-
enabled = false,
239-
onClick = onOpenAccountClick,
240-
colors = CardDefaults.cardColors(
241-
containerColor = Color.Transparent,
242-
contentColor = MaterialTheme.colorScheme.onSurface,
243-
),
244-
) {
245-
Column(
246-
modifier = Modifier
247-
.background(
248-
MaterialTheme.colorScheme.onSurface.copy(alpha = 0.01f),
249-
)
250-
.fillMaxWidth()
251-
.padding(DesignToken.padding.extraLarge),
252-
horizontalAlignment = Alignment.CenterHorizontally,
253-
verticalArrangement = Arrangement.spacedBy(DesignToken.spacing.medium),
254-
) {
255-
Icon(
256-
imageVector = MifosIcons.AddColor,
257-
contentDescription = null,
258-
tint = Color.Unspecified,
259-
modifier = Modifier.size(DesignToken.sizes.iconExtraLarge),
260-
)
195+
.fillMaxWidth()
196+
.padding(DesignToken.padding.extraLarge),
197+
horizontalAlignment = Alignment.CenterHorizontally,
198+
verticalArrangement = Arrangement.spacedBy(DesignToken.spacing.medium),
199+
) {
200+
Icon(
201+
imageVector = MifosIcons.AddColor,
202+
contentDescription = null,
203+
tint = Color.Unspecified,
204+
modifier = Modifier.size(DesignToken.sizes.iconExtraLarge),
205+
)
261206

262-
Text(
263-
text = stringResource(Res.string.feature_dashboard_no_accounts_title),
264-
style = MifosTypography.titleMediumEmphasized,
265-
color = MaterialTheme.colorScheme.onSurface,
266-
textAlign = TextAlign.Center,
267-
)
207+
Text(
208+
text = stringResource(Res.string.feature_dashboard_no_accounts_title),
209+
style = MifosTypography.titleMediumEmphasized,
210+
color = MaterialTheme.colorScheme.onSurface,
211+
textAlign = TextAlign.Center,
212+
)
268213

269-
Text(
270-
text = stringResource(Res.string.feature_dashboard_no_accounts_description),
271-
style = MifosTypography.bodySmall,
272-
color = MaterialTheme.colorScheme.secondary,
273-
textAlign = TextAlign.Center,
274-
)
214+
Text(
215+
text = stringResource(Res.string.feature_dashboard_no_accounts_description),
216+
style = MifosTypography.bodySmall,
217+
color = MaterialTheme.colorScheme.secondary,
218+
textAlign = TextAlign.Center,
219+
)
275220

276-
MifosButton(
277-
modifier = Modifier
278-
.wrapContentWidth()
279-
.height(DesignToken.sizes.buttonHeight),
280-
onClick = onOpenAccountClick,
281-
shape = DesignToken.shapes.medium,
282-
text = {
283-
Text(
284-
text = stringResource(Res.string.feature_dashboard_open_account),
285-
style = MifosTypography.titleSmallEmphasized,
286-
)
287-
},
288-
)
289-
}
290-
}
291-
}
221+
MifosButton(
222+
modifier = Modifier
223+
.wrapContentWidth()
224+
.height(DesignToken.sizes.avatarMedium),
225+
onClick = onOpenAccountClick,
226+
shape = DesignToken.shapes.circle,
227+
text = {
228+
Text(
229+
text = stringResource(Res.string.feature_dashboard_open_account),
230+
style = MifosTypography.titleSmallEmphasized,
231+
)
232+
},
233+
)
292234
}
293235
}
294236
}
@@ -340,7 +282,6 @@ private fun MifosDashboardCard() {
340282
)
341283

342284
MifosAccountApplyDashboard(
343-
userName = "Maria",
344285
onOpenAccountClick = {},
345286
)
346287
}

core/ui/src/commonMain/kotlin/org/mifos/mobile/core/ui/component/MifosProgressIndicator.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fun MifosProgressIndicator(
4242

4343
val progress by animateLottieCompositionAsState(
4444
composition,
45-
iterations = Int.MAX_VALUE
45+
iterations = Int.MAX_VALUE,
4646
)
4747

4848
Box(
@@ -71,7 +71,7 @@ fun MifosProgressIndicatorOverlay(
7171

7272
val progress by animateLottieCompositionAsState(
7373
composition,
74-
iterations = Int.MAX_VALUE
74+
iterations = Int.MAX_VALUE,
7575
)
7676

7777
Box(

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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,15 @@ internal fun HomeContent(
173173
.verticalScroll(rememberScrollState())
174174
.padding(DesignToken.padding.large),
175175
) {
176-
if (state.isAccountsPresent) {
177-
Spacer(modifier = Modifier.height(DesignToken.spacing.small))
178-
Text(
179-
text = stringResource(
180-
Res.string.feature_home_greet,
181-
state.firstName.toString(),
182-
),
183-
style = MifosTypography.titleLarge,
184-
color = MaterialTheme.colorScheme.onSurface,
185-
)
186-
}
176+
Spacer(modifier = Modifier.height(DesignToken.spacing.small))
177+
Text(
178+
text = stringResource(
179+
Res.string.feature_home_greet,
180+
state.firstName.toString(),
181+
),
182+
style = MifosTypography.titleLarge,
183+
color = MaterialTheme.colorScheme.onSurface,
184+
)
187185

188186
Spacer(modifier = Modifier.height(DesignToken.spacing.large))
189187

@@ -199,10 +197,6 @@ internal fun HomeContent(
199197
)
200198
} else {
201199
MifosAccountApplyDashboard(
202-
userName = stringResource(
203-
Res.string.feature_home_greet,
204-
state.firstName.toString(),
205-
),
206200
onOpenAccountClick = { onAction(HomeAction.BottomBarPicker) },
207201
)
208202
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ internal data class HomeState(
401401
val firstName: String? = "",
402402
val currency: String? = "",
403403
val decimals: Int = 2,
404-
val isAccountsPresent: Boolean = true,
404+
val isAccountsPresent: Boolean = false,
405405
val username: String = "",
406406
val clientAccounts: ClientAccounts? = null,
407407
val notificationCount: Int = 0,

feature/home/src/commonMain/kotlin/org/mifos/mobile/feature/home/components/BottomSheetContent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,6 @@ internal fun BottomSheetIconContainer(
152152
}
153153

154154
enum class BottomSheetItemType {
155-
LOAN,
156155
SAVINGS,
156+
LOAN,
157157
}

0 commit comments

Comments
 (0)