diff --git a/wallet/src/main/java/net/taler/wallet/balances/Balances.kt b/wallet/src/main/java/net/taler/wallet/balances/Balances.kt index d2a57099..01595f47 100644 --- a/wallet/src/main/java/net/taler/wallet/balances/Balances.kt +++ b/wallet/src/main/java/net/taler/wallet/balances/Balances.kt @@ -30,8 +30,22 @@ data class BalanceItem( val pendingOutgoing: Amount, val disablePeerPayments: Boolean, val shoppingUrls: List = emptyList(), + /** + * wallet-core's BalanceFlag values, kept as strings so that a flag + * added later cannot break decoding the whole balance list. + */ + val flags: List = emptyList(), ) { val currency: String get() = available.currency + + /** Pending incoming money waits for the user to pass KYC. */ + val incomingKyc: Boolean get() = "incoming-kyc" in flags + + /** Pending incoming money waits for the user to confirm at the bank. */ + val incomingConfirmation: Boolean get() = "incoming-confirmation" in flags + + /** Pending outgoing money waits for the user to pass KYC. */ + val outgoingKyc: Boolean get() = "outgoing-kyc" in flags } @Serializable diff --git a/wallet/src/main/java/net/taler/wallet/balances/LegacyBalancesComposable.kt b/wallet/src/main/java/net/taler/wallet/balances/LegacyBalancesComposable.kt index 06bdfa07..fdc7b36d 100644 --- a/wallet/src/main/java/net/taler/wallet/balances/LegacyBalancesComposable.kt +++ b/wallet/src/main/java/net/taler/wallet/balances/LegacyBalancesComposable.kt @@ -16,6 +16,7 @@ package net.taler.wallet.balances +import androidx.annotation.StringRes import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.animateContentSize import androidx.compose.foundation.background @@ -23,10 +24,12 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.consumeWindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.material.icons.Icons @@ -344,23 +347,37 @@ fun LegacyPendingComposable( Column(modifier = Modifier.padding(vertical = 5.dp)) { ProvideTextStyle(MaterialTheme.typography.bodyLarge) { AnimatedVisibility(!balance.pendingIncoming.isZero()) { - Text( - stringResource( - R.string.balances_inbound_amount, - balance.pendingIncoming.toString(showSymbol = false), - ), - color = TalerTheme.extraColors.success, - ) + Column { + Text( + stringResource( + R.string.balances_inbound_amount, + balance.pendingIncoming.toString(showSymbol = false), + ), + color = TalerTheme.extraColors.success, + ) + // the money only arrives once the user acts + if (balance.incomingKyc) { + PendingActionRequired(R.string.transactions_required_kyc) + } + if (balance.incomingConfirmation) { + PendingActionRequired(R.string.transaction_state_pending_bank) + } + } } AnimatedVisibility(!balance.pendingOutgoing.isZero()) { - Text( - stringResource( - R.string.balances_outbound_amount, - balance.pendingOutgoing.toString(showSymbol = false) - ), - color = MaterialTheme.colorScheme.error, - ) + Column { + Text( + stringResource( + R.string.balances_outbound_amount, + balance.pendingOutgoing.toString(showSymbol = false) + ), + color = MaterialTheme.colorScheme.error, + ) + if (balance.outgoingKyc) { + PendingActionRequired(R.string.transactions_required_kyc) + } + } } } } @@ -374,6 +391,27 @@ fun LegacyPendingComposable( ) } +@Composable +private fun PendingActionRequired(@StringRes text: Int) { + Row( + modifier = Modifier.padding(top = 2.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + Icon( + Icons.Default.Warning, + contentDescription = null, + modifier = Modifier.size(16.dp), + tint = MaterialTheme.colorScheme.error, + ) + Text( + text = stringResource(text), + modifier = Modifier.padding(start = 4.dp), + style = MaterialTheme.typography.bodyMedium, + color = MaterialTheme.colorScheme.error, + ) + } +} + @Preview @Composable fun LegacyBalancesComposablePreview() {