Skip to content

Commit 2d86633

Browse files
feat: status component (#2852)
1 parent fc0b406 commit 2d86633

File tree

5 files changed

+187
-10
lines changed

5 files changed

+187
-10
lines changed

core/ui/src/commonMain/composeResources/drawable/ic_icon_error.svg

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2025 Mifos Initiative
4+
5+
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
6+
If a copy of the MPL was not distributed with this file,
7+
You can obtain one at https://mozilla.org/MPL/2.0/.
8+
9+
See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
10+
-->
11+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
12+
android:width="96dp"
13+
android:height="96dp"
14+
android:viewportWidth="96"
15+
android:viewportHeight="96">
16+
17+
<path
18+
android:fillColor="#E0E2E8"
19+
android:pathData="M48,0a48,48 0 1,0 0,96a48,48 0 1,0 0,-96z" />
20+
21+
<path
22+
android:fillColor="#93000A"
23+
android:pathData="M47.9932,10.6602a37.3333,37.3333 0 1,0 0.0001,74.6666a37.3333,37.3333 0 1,0 -0.0001,-74.6666z" />
24+
25+
<path
26+
android:fillColor="#FFFFFF"
27+
android:pathData="M37.5467,61.0669L34.9333,58.4536L45.3867,48.0003L34.9333,37.5469L37.5467,34.9336L48,45.3869L58.4534,34.9336L61.0667,37.5469L50.6134,48.0003L61.0667,58.4536L58.4534,61.0669L48,50.6136L37.5467,61.0669Z" />
28+
</vector>

core/ui/src/commonMain/composeResources/drawable/ic_icon_success.svg

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2025 Mifos Initiative
4+
5+
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
6+
If a copy of the MPL was not distributed with this file,
7+
You can obtain one at https://mozilla.org/MPL/2.0/.
8+
9+
See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
10+
-->
11+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
12+
android:width="96dp"
13+
android:height="96dp"
14+
android:viewportWidth="96"
15+
android:viewportHeight="96">
16+
17+
<path
18+
android:fillColor="#E0E2E8"
19+
android:pathData="M48,0a48,48 0 1,0 0,96a48,48 0 1,0 0,-96z" />
20+
21+
<path
22+
android:fillColor="#009325"
23+
android:pathData="M47.9932,10.6602a37.3333,37.3333 0 1,0 0.0001,74.6666a37.3333,37.3333 0 1,0 -0.0001,-74.6666z" />
24+
25+
<path
26+
android:fillColor="#FFFFFF"
27+
android:pathData="M43.4266,59.2001L32.7866,48.5601L35.4466,45.9001L43.4266,53.8801L60.5533,36.7534L63.2133,39.4134L43.4266,59.2001Z" />
28+
</vector>
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
9+
*/
10+
package org.mifos.mobile.core.ui.component
11+
12+
import androidx.compose.foundation.Image
13+
import androidx.compose.foundation.layout.Arrangement
14+
import androidx.compose.foundation.layout.Column
15+
import androidx.compose.foundation.layout.Spacer
16+
import androidx.compose.foundation.layout.fillMaxSize
17+
import androidx.compose.foundation.layout.fillMaxWidth
18+
import androidx.compose.foundation.layout.height
19+
import androidx.compose.foundation.layout.padding
20+
import androidx.compose.foundation.layout.width
21+
import androidx.compose.material3.ButtonDefaults
22+
import androidx.compose.material3.MaterialTheme
23+
import androidx.compose.material3.Text
24+
import androidx.compose.runtime.Composable
25+
import androidx.compose.ui.Alignment
26+
import androidx.compose.ui.Modifier
27+
import androidx.compose.ui.text.style.TextAlign
28+
import androidx.compose.ui.unit.dp
29+
import mifos_mobile.core.ui.generated.resources.Res
30+
import mifos_mobile.core.ui.generated.resources.ic_icon_error
31+
import mifos_mobile.core.ui.generated.resources.ic_icon_success
32+
import org.jetbrains.compose.resources.DrawableResource
33+
import org.jetbrains.compose.resources.painterResource
34+
import org.jetbrains.compose.ui.tooling.preview.Preview
35+
import org.mifos.mobile.core.designsystem.component.MifosButton
36+
import org.mifos.mobile.core.designsystem.theme.AppColors
37+
import org.mifos.mobile.core.designsystem.theme.DesignToken
38+
import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme
39+
import org.mifos.mobile.core.designsystem.theme.MifosTypography
40+
41+
@Composable
42+
fun MifosStatusComponent(
43+
icon: DrawableResource,
44+
title: String,
45+
subTitle: String,
46+
buttonText: String,
47+
onClick: () -> Unit,
48+
modifier: Modifier = Modifier,
49+
) {
50+
Column(
51+
modifier = modifier
52+
.fillMaxWidth(),
53+
verticalArrangement = Arrangement.Center,
54+
horizontalAlignment = Alignment.CenterHorizontally,
55+
) {
56+
Image(
57+
modifier = Modifier
58+
.height(96.dp)
59+
.width(96.dp),
60+
painter = painterResource(icon),
61+
contentDescription = "Status icon",
62+
)
63+
64+
Spacer(modifier = Modifier.height(DesignToken.spacing.medium))
65+
66+
Text(
67+
text = title,
68+
style = MifosTypography.headlineSmallEmphasized,
69+
color = AppColors.customBlack,
70+
textAlign = TextAlign.Center,
71+
)
72+
73+
Spacer(modifier = Modifier.height(DesignToken.spacing.medium))
74+
75+
Text(
76+
text = subTitle,
77+
style = MifosTypography.bodySmall,
78+
color = MaterialTheme.colorScheme.secondary,
79+
textAlign = TextAlign.Center,
80+
)
81+
82+
Spacer(modifier = Modifier.height(DesignToken.spacing.extraLarge))
83+
84+
MifosButton(
85+
modifier = Modifier
86+
.fillMaxWidth()
87+
.height(DesignToken.sizes.buttonHeight),
88+
shape = DesignToken.shapes.medium,
89+
colors = ButtonDefaults.buttonColors(
90+
containerColor = MaterialTheme.colorScheme.primary,
91+
),
92+
text = {
93+
Text(
94+
text = buttonText,
95+
style = MifosTypography.titleMedium,
96+
color = AppColors.customWhite,
97+
)
98+
},
99+
onClick = onClick,
100+
)
101+
}
102+
}
103+
104+
@Composable
105+
@Preview
106+
private fun Mifos_Status_Component() {
107+
MifosMobileTheme {
108+
Column(
109+
modifier = Modifier
110+
.fillMaxSize()
111+
.padding(DesignToken.padding.large),
112+
verticalArrangement = Arrangement.Center,
113+
) {
114+
MifosStatusComponent(
115+
icon = Res.drawable.ic_icon_success,
116+
title = "User Successfully Registered",
117+
subTitle = "You can now log in with your username (phone number) and password.",
118+
buttonText = "Next",
119+
onClick = {},
120+
)
121+
Spacer(modifier = Modifier.height(DesignToken.spacing.extraExtraLarge))
122+
MifosStatusComponent(
123+
icon = Res.drawable.ic_icon_error,
124+
title = "Failed To Register The User",
125+
subTitle = "There is an error to register the user. Please try again.",
126+
buttonText = "Try Again",
127+
onClick = {},
128+
)
129+
}
130+
}
131+
}

0 commit comments

Comments
 (0)