|
| 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.border |
| 13 | +import androidx.compose.foundation.layout.Arrangement |
| 14 | +import androidx.compose.foundation.layout.Column |
| 15 | +import androidx.compose.foundation.layout.fillMaxSize |
| 16 | +import androidx.compose.foundation.layout.padding |
| 17 | +import androidx.compose.material3.CardDefaults |
| 18 | +import androidx.compose.material3.MaterialTheme |
| 19 | +import androidx.compose.material3.Text |
| 20 | +import androidx.compose.runtime.Composable |
| 21 | +import androidx.compose.ui.Alignment |
| 22 | +import androidx.compose.ui.Modifier |
| 23 | +import androidx.compose.ui.graphics.Color |
| 24 | +import androidx.compose.ui.unit.dp |
| 25 | +import org.jetbrains.compose.ui.tooling.preview.Preview |
| 26 | +import org.mifos.mobile.core.designsystem.component.CardVariant |
| 27 | +import org.mifos.mobile.core.designsystem.component.MifosCustomCard |
| 28 | +import org.mifos.mobile.core.designsystem.theme.AppColors |
| 29 | +import org.mifos.mobile.core.designsystem.theme.DesignToken |
| 30 | +import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme |
| 31 | +import org.mifos.mobile.core.designsystem.theme.MifosTypography |
| 32 | + |
| 33 | +@Composable |
| 34 | +fun MifosLabelValueCard( |
| 35 | + label: String, |
| 36 | + value: String, |
| 37 | + color: Color, |
| 38 | + modifier: Modifier = Modifier, |
| 39 | +) { |
| 40 | + MifosCustomCard( |
| 41 | + variant = CardVariant.OUTLINED, |
| 42 | + modifier = modifier |
| 43 | + .border( |
| 44 | + 1.dp, |
| 45 | + MaterialTheme.colorScheme.secondaryContainer, |
| 46 | + DesignToken.shapes.medium, |
| 47 | + ), |
| 48 | + shape = DesignToken.shapes.medium, |
| 49 | + colors = CardDefaults.outlinedCardColors(containerColor = MaterialTheme.colorScheme.onPrimary), |
| 50 | + ) { |
| 51 | + Column( |
| 52 | + modifier = Modifier |
| 53 | + .padding(DesignToken.padding.medium), |
| 54 | + verticalArrangement = Arrangement.spacedBy(DesignToken.spacing.extraSmall), |
| 55 | + horizontalAlignment = Alignment.Start, |
| 56 | + ) { |
| 57 | + Text( |
| 58 | + text = label, |
| 59 | + style = MifosTypography.bodySmall, |
| 60 | + color = MaterialTheme.colorScheme.secondary, |
| 61 | + |
| 62 | + ) |
| 63 | + |
| 64 | + Text( |
| 65 | + text = value, |
| 66 | + style = MifosTypography.bodyMediumEmphasized, |
| 67 | + color = color, |
| 68 | + ) |
| 69 | + } |
| 70 | + } |
| 71 | +} |
| 72 | + |
| 73 | +@Preview |
| 74 | +@Composable |
| 75 | +private fun Mifos_Label_Card_Preview() { |
| 76 | + MifosMobileTheme { |
| 77 | + Column( |
| 78 | + modifier = Modifier |
| 79 | + .fillMaxSize() |
| 80 | + .padding(16.dp), |
| 81 | + verticalArrangement = Arrangement.spacedBy(16.dp), |
| 82 | + ) { |
| 83 | + MifosLabelValueCard( |
| 84 | + label = "Account Number", |
| 85 | + value = "268978976666", |
| 86 | + color = MaterialTheme.colorScheme.onBackground, |
| 87 | + |
| 88 | + ) |
| 89 | + |
| 90 | + MifosLabelValueCard( |
| 91 | + label = "Product Type", |
| 92 | + value = "Education Loan", |
| 93 | + color = AppColors.customEnable, |
| 94 | + |
| 95 | + ) |
| 96 | + } |
| 97 | + } |
| 98 | +} |
0 commit comments