TransferTaler.kt (4113B)
1 /* 2 * This file is part of GNU Taler 3 * (C) 2025 Taler Systems S.A. 4 * 5 * GNU Taler is free software; you can redistribute it and/or modify it under the 6 * terms of the GNU General Public License as published by the Free Software 7 * Foundation; either version 3, or (at your option) any later version. 8 * 9 * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY 10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License along with 14 * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 17 package net.taler.wallet.transfer 18 19 import androidx.compose.foundation.layout.Column 20 import androidx.compose.foundation.layout.padding 21 import androidx.compose.material3.HorizontalDivider 22 import androidx.compose.material3.MaterialTheme 23 import androidx.compose.material3.Text 24 import androidx.compose.runtime.Composable 25 import androidx.compose.ui.Alignment 26 import androidx.compose.ui.Modifier 27 import androidx.compose.ui.res.stringResource 28 import androidx.compose.ui.unit.dp 29 import net.taler.common.Amount 30 import net.taler.wallet.R 31 import net.taler.wallet.accounts.PaytoUri 32 import net.taler.wallet.accounts.PaytoUriTalerBank 33 import net.taler.wallet.cleanExchange 34 import net.taler.wallet.compose.WarningLabel 35 import net.taler.wallet.withdraw.TransferData 36 import net.taler.wallet.transfer.TransferContext.* 37 38 @Composable 39 fun TransferTaler( 40 transfer: TransferData.Taler, 41 transactionAmountEffective: Amount, 42 transferContext: TransferContext, 43 ) { 44 Column( 45 modifier = Modifier.padding(all = 16.dp), 46 horizontalAlignment = Alignment.CenterHorizontally, 47 ) { 48 Text( 49 text = when (transferContext) { 50 ManualWithdrawal -> stringResource( 51 R.string.withdraw_manual_ready_intro, 52 transfer.transferAmount, 53 transactionAmountEffective, 54 ) 55 56 is DepositKycAuth -> { 57 val paytoTaler = PaytoUri.parse(transferContext.debitPaytoUri) 58 if (paytoTaler !is PaytoUriTalerBank) return@Column // TODO: render error 59 stringResource( 60 R.string.send_deposit_kyc_auth_intro_bank, 61 transfer.transferAmount, 62 paytoTaler.account, 63 ) 64 } 65 }, 66 style = MaterialTheme.typography.bodyLarge, 67 modifier = Modifier 68 .padding(vertical = 8.dp) 69 ) 70 71 if (transferContext is DepositKycAuth) { 72 WarningLabel( 73 modifier = Modifier.padding( 74 horizontal = 8.dp, 75 vertical = 16.dp, 76 ), 77 label = stringResource(R.string.send_deposit_kyc_auth_warning_account), 78 ) 79 } 80 81 HorizontalDivider( 82 modifier = Modifier.padding(vertical = 6.dp) 83 ) 84 85 DetailRow( 86 stringResource(R.string.withdraw_manual_ready_subject), 87 transfer.subject, 88 characterBreak = true, 89 ) 90 91 WarningLabel( 92 modifier = Modifier.padding( 93 horizontal = 8.dp, 94 vertical = 16.dp, 95 ), 96 label = when (transferContext) { 97 ManualWithdrawal -> stringResource(R.string.withdraw_manual_ready_warning) 98 is DepositKycAuth -> stringResource(R.string.send_deposit_kyc_auth_warning_subject) 99 }, 100 ) 101 102 transfer.receiverName?.let { 103 DetailRow(stringResource(R.string.withdraw_manual_ready_receiver), it) 104 } 105 106 DetailRow(stringResource(R.string.withdraw_manual_ready_account), transfer.account) 107 108 DetailRow(stringResource(R.string.withdraw_exchange), cleanExchange(transfer.exchangeBaseUrl)) 109 110 WithdrawalAmountTransfer( 111 conversionAmountRaw = transfer.transferAmount, 112 ) 113 } 114 }