diff options
Diffstat (limited to 'wallet/src/main/java/net/taler/wallet/transactions/TransactionRefreshFragment.kt')
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/transactions/TransactionRefreshFragment.kt | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefreshFragment.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefreshFragment.kt index 391eefa..8f474f9 100644 --- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefreshFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionRefreshFragment.kt @@ -38,12 +38,17 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import net.taler.common.Amount +import net.taler.common.CurrencySpecification import net.taler.common.Timestamp import net.taler.common.toAbsoluteTime import net.taler.wallet.R import net.taler.wallet.backend.TalerErrorCode import net.taler.wallet.backend.TalerErrorInfo import net.taler.wallet.compose.TalerSurface +import net.taler.wallet.transactions.TransactionAction.Abort +import net.taler.wallet.transactions.TransactionAction.Retry +import net.taler.wallet.transactions.TransactionAction.Suspend +import net.taler.wallet.transactions.TransactionMajorState.Pending class TransactionRefreshFragment : TransactionDetailFragment() { @@ -55,9 +60,10 @@ class TransactionRefreshFragment : TransactionDetailFragment() { setContent { TalerSurface { val t = transactionManager.selectedTransaction.observeAsState().value - val devMode = devMode.observeAsState().value ?: false - if (t is TransactionRefresh) TransactionRefreshComposable(t, devMode) { - onDeleteButtonClicked(t) + if (t is TransactionRefresh) TransactionRefreshComposable(t, devMode, + balanceManager.getSpecForCurrency(t.amountRaw.currency), + ) { + onTransitionButtonClicked(t, it) } } } @@ -68,7 +74,8 @@ class TransactionRefreshFragment : TransactionDetailFragment() { private fun TransactionRefreshComposable( t: TransactionRefresh, devMode: Boolean, - onDelete: () -> Unit, + spec: CurrencySpecification?, + onTransition: (t: TransactionAction) -> Unit, ) { val scrollState = rememberScrollState() Column( @@ -85,10 +92,10 @@ private fun TransactionRefreshComposable( ) TransactionAmountComposable( label = stringResource(id = R.string.withdraw_fees), - amount = t.amountEffective, + amount = t.amountEffective.withSpec(spec), amountType = AmountType.Negative, ) - DeleteTransactionComposable(onDelete) + TransitionsComposable(t, devMode, onTransition) if (devMode && t.error != null) { ErrorTransactionButton(error = t.error) } @@ -101,12 +108,13 @@ private fun TransactionRefreshComposablePreview() { val t = TransactionRefresh( transactionId = "transactionId", timestamp = Timestamp.fromMillis(System.currentTimeMillis() - 360 * 60 * 1000), - extendedStatus = ExtendedStatus.Pending, - amountRaw = Amount.fromDouble("TESTKUDOS", 42.23), - amountEffective = Amount.fromDouble("TESTKUDOS", 42.1337), + txState = TransactionState(Pending), + txActions = listOf(Retry, Suspend, Abort), + amountRaw = Amount.fromString("TESTKUDOS", "42.23"), + amountEffective = Amount.fromString("TESTKUDOS", "42.1337"), error = TalerErrorInfo(code = TalerErrorCode.WALLET_WITHDRAWAL_KYC_REQUIRED), ) Surface { - TransactionRefreshComposable(t, true) {} + TransactionRefreshComposable(t, true, null) {} } } |