TransferIBAN.kt (5794B)
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.Spacer 21 import androidx.compose.foundation.layout.fillMaxWidth 22 import androidx.compose.foundation.layout.padding 23 import androidx.compose.material3.HorizontalDivider 24 import androidx.compose.material3.MaterialTheme 25 import androidx.compose.material3.Text 26 import androidx.compose.runtime.Composable 27 import androidx.compose.ui.Alignment 28 import androidx.compose.ui.Modifier 29 import androidx.compose.ui.res.stringResource 30 import androidx.compose.ui.unit.dp 31 import net.taler.common.Amount 32 import net.taler.common.TalerUtils 33 import net.taler.wallet.R 34 import net.taler.wallet.accounts.PaytoUri 35 import net.taler.wallet.accounts.PaytoUriIban 36 import net.taler.wallet.compose.WarningLabel 37 import net.taler.wallet.transactions.AccountRestriction 38 import net.taler.wallet.transfer.TransferContext.DepositKycAuth 39 import net.taler.wallet.transfer.TransferContext.ManualWithdrawal 40 import net.taler.wallet.withdraw.TransferData 41 42 @Composable 43 fun TransferIBAN( 44 transfer: TransferData.IBAN, 45 transactionAmountEffective: Amount, 46 transferContext: TransferContext, 47 ) { 48 Column( 49 modifier = Modifier.padding(all = 16.dp), 50 horizontalAlignment = Alignment.CenterHorizontally, 51 ) { 52 Text( 53 text = when(transferContext) { 54 ManualWithdrawal -> stringResource( 55 R.string.withdraw_manual_ready_intro, 56 transfer.transferAmount, 57 transactionAmountEffective, 58 ) 59 60 is DepositKycAuth -> { 61 val paytoIban = PaytoUri.parse(transferContext.debitPaytoUri) 62 if (paytoIban !is PaytoUriIban) return@Column // TODO: render error 63 stringResource( 64 R.string.send_deposit_kyc_auth_intro_bank, 65 transfer.transferAmount, 66 paytoIban.iban, 67 ) 68 } 69 }, 70 style = MaterialTheme.typography.bodyLarge, 71 modifier = Modifier 72 .padding(vertical = 8.dp) 73 ) 74 75 Spacer(Modifier.padding(4.dp)) 76 77 transfer.withdrawalAccount.creditRestrictions?.forEach { restriction -> 78 when (restriction) { 79 is AccountRestriction.RegexAccount -> { 80 WarningLabel ( 81 modifier = Modifier 82 .fillMaxWidth() 83 .padding(vertical = 4.dp), 84 label = TalerUtils.getLocalizedString( 85 restriction.humanHintI18n, 86 restriction.humanHint, 87 ) 88 ) 89 } 90 91 else -> {} 92 } 93 } 94 95 if (transferContext is DepositKycAuth) { 96 WarningLabel( 97 modifier = Modifier.padding( 98 horizontal = 8.dp, 99 vertical = 16.dp, 100 ), 101 label = stringResource(R.string.send_deposit_kyc_auth_warning_account), 102 ) 103 } 104 105 HorizontalDivider( 106 modifier = Modifier.padding(vertical = 6.dp) 107 ) 108 109 TransferStep(1, stringResource(R.string.withdraw_manual_step_iban)) 110 111 DetailRow(stringResource(R.string.withdraw_manual_ready_iban), transfer.iban) 112 113 transfer.receiverName?.let { 114 DetailRow(stringResource(R.string.withdraw_manual_ready_receiver), it) 115 } 116 117 transfer.receiverPostalCode?.let { 118 DetailRow(stringResource(R.string.withdraw_manual_ready_postal_code), it) 119 } 120 121 transfer.receiverTown?.let { 122 DetailRow(stringResource(R.string.withdraw_manual_ready_town), it) 123 } 124 125 WithdrawalAmountTransfer( 126 conversionAmountRaw = transfer.transferAmount, 127 ) 128 129 TransferStep(2, stringResource(R.string.withdraw_manual_step_subject)) 130 131 WarningLabel( 132 modifier = Modifier.padding( 133 horizontal = 8.dp, 134 vertical = 16.dp, 135 ), 136 label = when (transferContext) { 137 ManualWithdrawal -> stringResource(R.string.withdraw_manual_ready_warning) 138 is DepositKycAuth -> stringResource(R.string.send_deposit_kyc_auth_warning_subject) 139 }, 140 ) 141 142 DetailRow( 143 stringResource(R.string.withdraw_manual_ready_subject), 144 transfer.subject, 145 characterBreak = true, 146 ) 147 148 TransferStep(3, 149 when (transferContext) { 150 ManualWithdrawal -> stringResource( 151 R.string.withdraw_manual_step_finish, 152 transfer.transferAmount, 153 ) 154 155 is DepositKycAuth -> stringResource( 156 R.string.send_deposit_kyc_auth_step_finish, 157 transfer.transferAmount, 158 transfer.iban, 159 ) 160 } 161 ) 162 } 163 }