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