fix: label failed payments in PaymentRow
This commit is contained in:
@@ -306,6 +306,7 @@ val EnHomeStrings = AppStrings(
|
||||
paymentRowReceivedCD = "Received",
|
||||
paymentRowNoMemo = "No memo",
|
||||
paymentRowPending = "Pending",
|
||||
paymentRowFailed = "Failed",
|
||||
|
||||
onboarding = OnboardingStrings(
|
||||
back = "Back",
|
||||
|
||||
@@ -305,6 +305,8 @@ val EsHomeStrings = AppStrings(
|
||||
paymentRowReceivedCD = "Recibido",
|
||||
paymentRowNoMemo = "Sin nota",
|
||||
paymentRowPending = "Pendiente",
|
||||
paymentRowFailed = "Fallido",
|
||||
|
||||
|
||||
onboarding = OnboardingStrings(
|
||||
back = "Back",
|
||||
|
||||
@@ -305,6 +305,8 @@ val EuStrings = AppStrings(
|
||||
paymentRowReceivedCD = "Jasota",
|
||||
paymentRowNoMemo = "Oharrik gabe",
|
||||
paymentRowPending = "Zain",
|
||||
paymentRowFailed = "Huts eginda",
|
||||
|
||||
|
||||
onboarding = OnboardingStrings(
|
||||
back = "Back",
|
||||
|
||||
@@ -302,6 +302,7 @@ data class AppStrings(
|
||||
val paymentRowReceivedCD : String,
|
||||
val paymentRowNoMemo : String,
|
||||
val paymentRowPending : String,
|
||||
val paymentRowFailed : String,
|
||||
|
||||
val onboarding: OnboardingStrings
|
||||
)
|
||||
|
||||
@@ -30,6 +30,9 @@ internal fun formatTimestamp(createdAt: Long?, rawTime: String): String {
|
||||
internal fun isPendingStatus(status: String): Boolean =
|
||||
status.lowercase() in setOf("pending", "in_flight", "inflight")
|
||||
|
||||
internal fun isFailedStatus(status: String): Boolean =
|
||||
status.lowercase() in setOf("failed", "error", "expired")
|
||||
|
||||
// ── Composable helpers ───────────────────────────────────────────────────────
|
||||
|
||||
@Composable
|
||||
@@ -37,6 +40,7 @@ internal fun paymentAmountColor(status: String, isOutgoing: Boolean): Color {
|
||||
val semantic = semanticColors()
|
||||
return when {
|
||||
isPendingStatus(status) -> MaterialTheme.colorScheme.onSurfaceVariant
|
||||
isFailedStatus(status) -> MaterialTheme.colorScheme.onSurfaceVariant
|
||||
isOutgoing -> MaterialTheme.colorScheme.onSurface
|
||||
else -> semantic.success
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ internal fun PaymentRow(
|
||||
) {
|
||||
val strings = LocalAppStrings.current
|
||||
val isPending = isPendingStatus(payment.status)
|
||||
val isFailed = isFailedStatus(payment.status)
|
||||
val semantic = semanticColors()
|
||||
val amountColor = paymentAmountColor(payment.status, payment.isOutgoing)
|
||||
val icon = if (payment.isOutgoing) Icons.Default.ArrowUpward
|
||||
@@ -80,15 +81,30 @@ internal fun PaymentRow(
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
if (isPending) {
|
||||
val statusLabel = when {
|
||||
isPending -> strings.paymentRowPending
|
||||
isFailed -> strings.paymentRowFailed
|
||||
else -> null
|
||||
}
|
||||
val statusColor = when {
|
||||
isPending -> semantic.warningContainer
|
||||
isFailed -> semantic.errorContainer
|
||||
else -> semantic.successContainer // fallback, won't be used
|
||||
}
|
||||
val statusContentColor = when {
|
||||
isPending -> semantic.onWarningContainer
|
||||
isFailed -> semantic.onErrorContainer
|
||||
else -> semantic.onSuccessContainer
|
||||
}
|
||||
if (statusLabel != null) {
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Surface(
|
||||
shape = MaterialTheme.shapes.extraSmall,
|
||||
color = semantic.warningContainer,
|
||||
contentColor = semantic.onWarningContainer
|
||||
color = statusColor,
|
||||
contentColor = statusContentColor
|
||||
) {
|
||||
Text(
|
||||
text = strings.paymentRowPending, // ← "Pending"
|
||||
text = statusLabel,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
modifier = Modifier.padding(horizontal = 6.dp, vertical = 2.dp)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user