Skip to content

Commit 015c21e

Browse files
feat(home): add empty state and account creation flow (#2970)
1 parent 5c3920b commit 015c21e

File tree

13 files changed

+438
-140
lines changed

13 files changed

+438
-140
lines changed

core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/UserAuthRepository.kt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,12 @@ package org.mifos.mobile.core.data.repository
1111

1212
import org.mifos.mobile.core.common.DataState
1313
import org.mifos.mobile.core.model.entity.User
14+
import org.mifos.mobile.core.model.entity.register.RegisterPayload
1415

1516
interface UserAuthRepository {
1617

1718
suspend fun registerUser(
18-
accountNumber: String?,
19-
authenticationMode: String?,
20-
email: String?,
21-
firstName: String?,
22-
lastName: String?,
23-
mobileNumber: String?,
24-
password: String?,
25-
username: String?,
19+
registerPayload: RegisterPayload,
2620
): DataState<String>
2721

2822
suspend fun login(username: String, password: String): DataState<User>

core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/UserAuthRepositoryImp.kt

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,8 @@ class UserAuthRepositoryImp(
3131
) : UserAuthRepository {
3232

3333
override suspend fun registerUser(
34-
accountNumber: String?,
35-
authenticationMode: String?,
36-
email: String?,
37-
firstName: String?,
38-
lastName: String?,
39-
mobileNumber: String?,
40-
password: String?,
41-
username: String?,
34+
registerPayload: RegisterPayload,
4235
): DataState<String> {
43-
val registerPayload = RegisterPayload(
44-
accountNumber = accountNumber,
45-
authenticationMode = authenticationMode,
46-
email = email,
47-
firstName = firstName,
48-
lastName = lastName,
49-
mobileNumber = mobileNumber,
50-
password = password,
51-
username = username,
52-
)
5336
return withContext(ioDispatcher) {
5437
try {
5538
val response = dataManager.registrationApi.registerUser(registerPayload)

core/designsystem/src/commonMain/kotlin/org/mifos/mobile/core/designsystem/icon/MifosIcons.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ import androidx.compose.material.icons.rounded.Home
5454
import androidx.compose.material.icons.rounded.SwapHoriz
5555
import androidx.compose.ui.graphics.vector.ImageVector
5656
import fluent.ui.system.icons.FluentIcons
57+
import fluent.ui.system.icons.colored.AddCircle
5758
import fluent.ui.system.icons.colored.Alert
59+
import fluent.ui.system.icons.colored.CoinMultiple
60+
import fluent.ui.system.icons.colored.Savings
5861
import fluent.ui.system.icons.colored.Warning
5962
import fluent.ui.system.icons.filled.AppRecent
6063
import fluent.ui.system.icons.filled.ArchiveSettings
@@ -192,7 +195,9 @@ object MifosIcons {
192195
val SearchNew = FluentIcons.Regular.Search
193196

194197
val SavingsAccount = FluentIcons.Filled.Wallet
198+
val SavingsAccountColor = FluentIcons.Colored.Savings
195199
val LoanAccount = FluentIcons.Filled.CoinMultiple
200+
val LoanAccountColor = FluentIcons.Colored.CoinMultiple
196201
val ShareAccount = FluentIcons.Filled.DataWhisker
197202
val ApplyForLoan = FluentIcons.Filled.Receipt
198203
val ApplyForSavings = FluentIcons.Filled.Savings
@@ -255,4 +260,6 @@ object MifosIcons {
255260
val Signature = FluentIcons.Regular.DrawShape
256261
val Camera = FluentIcons.Regular.Camera
257262
val Attach = FluentIcons.Regular.Attach
263+
264+
val AddColor = FluentIcons.Colored.AddCircle
258265
}

core/model/src/commonMain/kotlin/org/mifos/mobile/core/model/entity/register/RegisterPayload.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ data class RegisterPayload(
1818

1919
val firstName: String? = null,
2020

21+
val middleName: String? = null,
22+
2123
val lastName: String? = null,
2224

2325
val email: String? = null,

core/ui/src/commonMain/composeResources/values/strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@
120120
<string name="pay_from">Pay from</string>
121121
<string name="available_balance_formatted">Available Balance - %1$s</string>
122122

123+
<string name="feature_dashboard_welcome_back">Welcome back to Mifos</string>
124+
<string name="feature_dashboard_no_accounts_title">No Accounts Yet</string>
125+
<string name="feature_dashboard_no_accounts_description">Start your financial journey by opening your first account with us.</string>
126+
<string name="feature_dashboard_open_account">Open Account</string>
127+
123128
<string name="feature_savings_filter">Filters</string>
124129
<string name="feature_savings_reset">Reset</string>
125130
<string name="feature_savings_apply">Apply</string>

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

Lines changed: 137 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import androidx.compose.animation.fadeIn
1616
import androidx.compose.animation.fadeOut
1717
import androidx.compose.animation.togetherWith
1818
import androidx.compose.foundation.Image
19+
import androidx.compose.foundation.background
20+
import androidx.compose.foundation.border
1921
import androidx.compose.foundation.layout.Arrangement
2022
import androidx.compose.foundation.layout.Box
2123
import androidx.compose.foundation.layout.Column
@@ -24,25 +26,35 @@ import androidx.compose.foundation.layout.fillMaxSize
2426
import androidx.compose.foundation.layout.fillMaxWidth
2527
import androidx.compose.foundation.layout.height
2628
import androidx.compose.foundation.layout.padding
29+
import androidx.compose.foundation.layout.size
30+
import androidx.compose.foundation.layout.wrapContentWidth
2731
import androidx.compose.foundation.shape.RoundedCornerShape
32+
import androidx.compose.material3.CardDefaults
2833
import androidx.compose.material3.Icon
2934
import androidx.compose.material3.IconButton
35+
import androidx.compose.material3.MaterialTheme
3036
import androidx.compose.material3.Text
3137
import androidx.compose.runtime.Composable
3238
import androidx.compose.ui.Alignment
3339
import androidx.compose.ui.Modifier
3440
import androidx.compose.ui.draw.clip
3541
import androidx.compose.ui.graphics.Color
3642
import androidx.compose.ui.layout.ContentScale
43+
import androidx.compose.ui.text.style.TextAlign
3744
import androidx.compose.ui.unit.dp
3845
import mifos_mobile.core.ui.generated.resources.Res
46+
import mifos_mobile.core.ui.generated.resources.feature_dashboard_no_accounts_description
47+
import mifos_mobile.core.ui.generated.resources.feature_dashboard_no_accounts_title
48+
import mifos_mobile.core.ui.generated.resources.feature_dashboard_open_account
3949
import mifos_mobile.core.ui.generated.resources.ic_icon_dashboard
4050
import mifos_mobile.core.ui.generated.resources.powered_by
4151
import org.jetbrains.compose.resources.StringResource
4252
import org.jetbrains.compose.resources.painterResource
4353
import org.jetbrains.compose.resources.stringResource
4454
import org.jetbrains.compose.ui.tooling.preview.Preview
55+
import org.mifos.mobile.core.designsystem.component.CardVariant
4556
import org.mifos.mobile.core.designsystem.component.MifosButton
57+
import org.mifos.mobile.core.designsystem.component.MifosCustomCard
4658
import org.mifos.mobile.core.designsystem.icon.MifosIcons
4759
import org.mifos.mobile.core.designsystem.theme.AppColors
4860
import org.mifos.mobile.core.designsystem.theme.DesignToken
@@ -54,8 +66,6 @@ import org.mifos.mobile.core.designsystem.theme.MifosTypography
5466
fun MifosDashboardCard(
5567
isVisible: Boolean,
5668
modifier: Modifier = Modifier,
57-
isLoanApplied: Boolean = true,
58-
onLoanApplyClick: () -> Unit = {},
5969
isSingleLine: Boolean = false,
6070
loanAccount: StringResource? = null,
6171
loanAmount: String? = null,
@@ -77,95 +87,147 @@ fun MifosDashboardCard(
7787
contentDescription = null,
7888
contentScale = ContentScale.Crop,
7989
)
80-
if (isLoanApplied) {
81-
Row(
90+
Row(
91+
modifier = Modifier
92+
.fillMaxWidth()
93+
.padding(DesignToken.padding.small),
94+
horizontalArrangement = Arrangement.spacedBy(
95+
DesignToken.spacing.medium,
96+
Alignment.End,
97+
),
98+
) {
99+
Column(
82100
modifier = Modifier
83-
.fillMaxWidth()
84-
.padding(DesignToken.padding.small),
85-
horizontalArrangement = Arrangement.spacedBy(
86-
DesignToken.spacing.medium,
87-
Alignment.End,
88-
),
101+
.fillMaxSize()
102+
.padding(DesignToken.padding.medium),
103+
verticalArrangement = Arrangement.SpaceBetween,
89104
) {
90-
Column(
91-
modifier = Modifier
92-
.fillMaxSize()
93-
.padding(DesignToken.padding.medium),
94-
verticalArrangement = Arrangement.SpaceBetween,
95-
) {
96-
if (loanAccount != null) {
97-
Column {
98-
Text(
99-
text = stringResource(loanAccount),
100-
style = MifosTypography.bodySmall,
105+
if (loanAccount != null) {
106+
Column {
107+
Text(
108+
text = stringResource(loanAccount),
109+
style = MifosTypography.bodySmall,
101110
// color = MaterialTheme.colorScheme.secondary.copy(alpha = 0.7f),
102-
color = AppColors.customWhite.copy(alpha = 0.5f),
111+
color = AppColors.customWhite.copy(alpha = 0.5f),
112+
)
113+
AnimatedContent(
114+
targetState = isVisible,
115+
transitionSpec = {
116+
fadeIn(tween(300)) togetherWith fadeOut(tween(300))
117+
},
118+
label = "Loan Amount Animation",
119+
) { visible ->
120+
Text(
121+
text = if (visible) "$loanAmount" else "$currency •••••••••",
122+
style = MifosTypography.titleMediumEmphasized,
123+
color = AppColors.customWhite,
103124
)
104-
AnimatedContent(
105-
targetState = isVisible,
106-
transitionSpec = {
107-
fadeIn(tween(300)) togetherWith fadeOut(tween(300))
108-
},
109-
label = "Loan Amount Animation",
110-
) { visible ->
111-
Text(
112-
text = if (visible) "$loanAmount" else "$currency •••••••••",
113-
style = MifosTypography.titleMediumEmphasized,
114-
color = AppColors.customWhite,
115-
)
116-
}
117125
}
118126
}
127+
}
119128

120-
if (savingsAccount != null) {
121-
Column {
122-
Text(
123-
text = stringResource(savingsAccount),
124-
style = MifosTypography.bodySmall,
129+
if (savingsAccount != null) {
130+
Column {
131+
Text(
132+
text = stringResource(savingsAccount),
133+
style = MifosTypography.bodySmall,
125134
// color = MaterialTheme.colorScheme.secondary,
126-
color = AppColors.customWhite.copy(alpha = 0.5f),
135+
color = AppColors.customWhite.copy(alpha = 0.5f),
136+
)
137+
AnimatedContent(
138+
targetState = isVisible,
139+
transitionSpec = {
140+
fadeIn(tween(300)) togetherWith fadeOut(tween(300))
141+
},
142+
label = "Savings Amount Animation",
143+
) { visible ->
144+
Text(
145+
text = if (visible) "$savingsAmount" else "$currency •••••••••",
146+
style = MifosTypography.titleMediumEmphasized,
147+
color = AppColors.customWhite,
127148
)
128-
AnimatedContent(
129-
targetState = isVisible,
130-
transitionSpec = {
131-
fadeIn(tween(300)) togetherWith fadeOut(tween(300))
132-
},
133-
label = "Savings Amount Animation",
134-
) { visible ->
135-
Text(
136-
text = if (visible) "$savingsAmount" else "$currency •••••••••",
137-
style = MifosTypography.titleMediumEmphasized,
138-
color = AppColors.customWhite,
139-
)
140-
}
141149
}
142150
}
143151
}
144152
}
153+
}
145154

146-
IconButton(
147-
onClick = onVisibilityToggle,
148-
modifier = Modifier
149-
.align(Alignment.BottomEnd)
150-
.padding(12.dp),
151-
) {
152-
Icon(
153-
imageVector = if (isVisible) MifosIcons.Eye else MifosIcons.EyeOff,
154-
contentDescription = "Toggle Visibility",
155-
tint = Color.White,
155+
IconButton(
156+
onClick = onVisibilityToggle,
157+
modifier = Modifier
158+
.align(Alignment.BottomEnd)
159+
.padding(12.dp),
160+
) {
161+
Icon(
162+
imageVector = if (isVisible) MifosIcons.Eye else MifosIcons.EyeOff,
163+
contentDescription = "Toggle Visibility",
164+
tint = Color.White,
165+
)
166+
}
167+
}
168+
}
169+
170+
@Composable
171+
fun MifosAccountApplyDashboard(
172+
onOpenAccountClick: () -> Unit,
173+
) {
174+
MifosCustomCard(
175+
modifier = Modifier
176+
.padding(horizontal = DesignToken.padding.largeIncreased)
177+
.border(
178+
0.5.dp,
179+
MaterialTheme.colorScheme.primary,
180+
DesignToken.shapes.medium,
181+
),
182+
variant = CardVariant.OUTLINED,
183+
enabled = false,
184+
onClick = onOpenAccountClick,
185+
colors = CardDefaults.cardColors(
186+
containerColor = Color.Transparent,
187+
contentColor = MaterialTheme.colorScheme.onSurface,
188+
),
189+
) {
190+
Column(
191+
modifier = Modifier
192+
.background(
193+
MaterialTheme.colorScheme.onSurface.copy(alpha = 0.01f),
156194
)
157-
}
158-
} else {
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+
)
206+
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+
)
213+
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+
)
220+
159221
MifosButton(
160222
modifier = Modifier
161-
.fillMaxWidth()
162-
.height(DesignToken.sizes.buttonHeight)
163-
.align(Alignment.Center),
164-
onClick = onLoanApplyClick,
165-
content = {
223+
.wrapContentWidth()
224+
.height(DesignToken.sizes.avatarMedium),
225+
onClick = onOpenAccountClick,
226+
shape = DesignToken.shapes.circle,
227+
text = {
166228
Text(
167-
text = "Apply Loan",
168-
style = MifosTypography.titleMedium,
229+
text = stringResource(Res.string.feature_dashboard_open_account),
230+
style = MifosTypography.titleSmallEmphasized,
169231
)
170232
},
171233
)
@@ -219,9 +281,8 @@ private fun MifosDashboardCard() {
219281
onVisibilityToggle = {},
220282
)
221283

222-
MifosDashboardCard(
223-
isLoanApplied = false,
224-
isVisible = true,
284+
MifosAccountApplyDashboard(
285+
onOpenAccountClick = {},
225286
)
226287
}
227288
}

0 commit comments

Comments
 (0)