|
| 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