@@ -16,6 +16,8 @@ import androidx.compose.animation.fadeIn
1616import androidx.compose.animation.fadeOut
1717import androidx.compose.animation.togetherWith
1818import androidx.compose.foundation.Image
19+ import androidx.compose.foundation.background
20+ import androidx.compose.foundation.border
1921import androidx.compose.foundation.layout.Arrangement
2022import androidx.compose.foundation.layout.Box
2123import androidx.compose.foundation.layout.Column
@@ -24,25 +26,35 @@ import androidx.compose.foundation.layout.fillMaxSize
2426import androidx.compose.foundation.layout.fillMaxWidth
2527import androidx.compose.foundation.layout.height
2628import androidx.compose.foundation.layout.padding
29+ import androidx.compose.foundation.layout.size
30+ import androidx.compose.foundation.layout.wrapContentWidth
2731import androidx.compose.foundation.shape.RoundedCornerShape
32+ import androidx.compose.material3.CardDefaults
2833import androidx.compose.material3.Icon
2934import androidx.compose.material3.IconButton
35+ import androidx.compose.material3.MaterialTheme
3036import androidx.compose.material3.Text
3137import androidx.compose.runtime.Composable
3238import androidx.compose.ui.Alignment
3339import androidx.compose.ui.Modifier
3440import androidx.compose.ui.draw.clip
3541import androidx.compose.ui.graphics.Color
3642import androidx.compose.ui.layout.ContentScale
43+ import androidx.compose.ui.text.style.TextAlign
3744import androidx.compose.ui.unit.dp
3845import 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
3949import mifos_mobile.core.ui.generated.resources.ic_icon_dashboard
4050import mifos_mobile.core.ui.generated.resources.powered_by
4151import org.jetbrains.compose.resources.StringResource
4252import org.jetbrains.compose.resources.painterResource
4353import org.jetbrains.compose.resources.stringResource
4454import org.jetbrains.compose.ui.tooling.preview.Preview
55+ import org.mifos.mobile.core.designsystem.component.CardVariant
4556import org.mifos.mobile.core.designsystem.component.MifosButton
57+ import org.mifos.mobile.core.designsystem.component.MifosCustomCard
4658import org.mifos.mobile.core.designsystem.icon.MifosIcons
4759import org.mifos.mobile.core.designsystem.theme.AppColors
4860import org.mifos.mobile.core.designsystem.theme.DesignToken
@@ -54,8 +66,6 @@ import org.mifos.mobile.core.designsystem.theme.MifosTypography
5466fun 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