taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit a2df784dd3b07bc715b58c6d83387a6342bfc3f1
parent f03a19f0058c3bed63ac47c3bffb012403b24599
Author: Marc Stibane <marc@taler.net>
Date:   Tue,  7 May 2024 15:41:30 +0200

CurrencyFormatter for manual withdrawals

Diffstat:
MTalerWallet1/Backend/WalletBackendRequest.swift | 1+
MTalerWallet1/Views/Transactions/ManualDetailsV.swift | 14+++++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/TalerWallet1/Backend/WalletBackendRequest.swift b/TalerWallet1/Backend/WalletBackendRequest.swift @@ -29,6 +29,7 @@ struct ScopeInfo: Codable, Hashable { case global case exchange case auditor + case madeUp // => type unknown, currency name taken from amount } var type: ScopeInfoType var noFees: Bool? // only for "global". Regional have this field per Exchange diff --git a/TalerWallet1/Views/Transactions/ManualDetailsV.swift b/TalerWallet1/Views/Transactions/ManualDetailsV.swift @@ -159,13 +159,25 @@ struct ManualDetailsV: View { } } + func amountString(_ amount: Amount, specs: CurrencySpecification?, scope: ScopeInfo? = nil) -> String { + if let specs { + let myScope = scope ?? ScopeInfo(type: .madeUp, currency: amount.currencyStr) + let currencyInfo = CurrencyInfo(scope: myScope, specs: specs, + formatter: CurrencyFormatter.formatter(scope: myScope, + specs: specs)) + return amount.string(currencyInfo) + } + return amount.string() + } + var body: some View { if let accountDetails = details.exchangeCreditAccountDetails { let validDetails = validDetails(accountDetails) if validDetails.count > 0 { let account = validDetails[accountID] if let amount = account.transferAmount { - let amountStr = amount.string() + let specs = account.currencySpecification + let amountStr = amountString(amount, specs: specs) let obtainStr = common.amountRaw.string() if !minimalistic { Text("The Payment Service Provider is waiting for your wire-transfer.")