taler-ios

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

commit 81502bac681c695789da5f0dfe3faeda20a05a8f
parent 072bca2209ba2384d6639400e057a8390e614954
Author: Marc Stibane <marc@taler.net>
Date:   Thu, 18 Jul 2024 12:29:23 +0200

Use currencyName for buttons

Diffstat:
MTalerWallet1/Views/Balances/BalancesSectionView.swift | 4++--
MTalerWallet1/Views/Banking/DepositWithdrawV.swift | 19++++++++++++-------
MTalerWallet1/Views/Banking/ExchangeRowView.swift | 6++++--
MTalerWallet1/Views/Banking/ExchangeSectionView.swift | 5+++--
4 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift b/TalerWallet1/Views/Balances/BalancesSectionView.swift @@ -126,9 +126,9 @@ extension BalancesSectionView: View { .listRowSeparator(.hidden) } DepositWithdrawV(stack: stack.push(), - scopeInfo: balance.scopeInfo, + currencyInfo: currencyInfo, +// scopeInfo: balance.scopeInfo, amountAvailable: balance.available, - currency: currencyName, amountToTransfer: $amountToTransfer) // does still have the wrong currency .listRowSeparator(.hidden) diff --git a/TalerWallet1/Views/Banking/DepositWithdrawV.swift b/TalerWallet1/Views/Banking/DepositWithdrawV.swift @@ -12,9 +12,10 @@ import SymLog struct DepositWithdrawV: View { private let symLog = SymLogV(0) let stack: CallStack - let scopeInfo: ScopeInfo + let currencyInfo: CurrencyInfo +// let scopeInfo: ScopeInfo let amountAvailable: Amount? - let currency: String // this is the currency to be used +// let currency: String // this is the currency to be used @Binding var amountToTransfer: Amount // does still have the wrong currency @EnvironmentObject private var model: WalletModel @@ -23,13 +24,15 @@ struct DepositWithdrawV: View { @State private var myExchange: Exchange? = nil func selectAndUpdate(_ button: Int) { + let scope = currencyInfo.scope + let currency = scope.currency amountToTransfer.setCurrency(currency) buttonSelected = button // will trigger NavigationLink // after user tapped a button, while navigation animation runs, contact Exchange to update Fees - if let url = scopeInfo.url { + if let url = scope.url { Task { // runs on MainActor do { -// try await model.updateExchange(scopeInfo: scopeInfo) + // TODO: try await model.updateExchange(scopeInfo: scope) try await model.updateExchange(exchangeBaseUrl: url) } catch { // TODO: error handling - couldn't updateExchange symLog.log("error: \(error)") @@ -39,14 +42,16 @@ struct DepositWithdrawV: View { } var body: some View { + let scope = currencyInfo.scope + let currencyName = currencyInfo.specs.name let depositTitle0 = String(localized: "DepositButton_Short", defaultValue: "Deposit", comment: "Abbreviation of button `Deposit (currency)´") - let depositTitle1 = String(localized: "Deposit\t\(currency)", + let depositTitle1 = String(localized: "Deposit\t\(currencyName)", comment: "Button `Deposit (currency)´, must have ONE \\t and ONE %@") let withdrawTitle0 = String(localized: "WithdrawButton_Short", defaultValue: "Withdraw", comment: "Abbreviation of button `Withdraw (currency)´") - let withdrawTitle1 = String(localized: "Withdraw\t\(currency)", + let withdrawTitle1 = String(localized: "Withdraw\t\(currencyName)", comment: "Button `Withdraw (currency)´, must have ONE \\t and ONE %@") let deposit = LazyView { DepositIbanV(stack: stack.push(), @@ -60,7 +65,7 @@ struct DepositWithdrawV: View { let manualWithdraw = LazyView { ManualWithdraw(stack: stack.push(), isSheet: false, - scopeInfo: scopeInfo, + scopeInfo: scope, exchange: $myExchange, amountToTransfer: $amountToTransfer) } diff --git a/TalerWallet1/Views/Banking/ExchangeRowView.swift b/TalerWallet1/Views/Banking/ExchangeRowView.swift @@ -12,6 +12,7 @@ import SymLog struct ExchangeRowView: View { private let symLog = SymLogV(0) let stack: CallStack + let currencyInfo: CurrencyInfo let exchange: Exchange // @Binding var depositIBAN: String // @Binding var accountHolder: String @@ -53,9 +54,9 @@ struct ExchangeRowView: View { .listRowSeparator(.hidden) DepositWithdrawV(stack: stack.push(), - scopeInfo: exchange.scopeInfo, + currencyInfo: currencyInfo, +// scopeInfo: exchange.scopeInfo, amountAvailable: amountAvailable, - currency: currency, amountToTransfer: $amountToTransfer) } .task { @@ -99,6 +100,7 @@ fileprivate struct ExchangeRow_Container : View { exchangeUpdateStatus: .ready, ageRestrictionOptions: []) ExchangeRowView(stack: CallStack("Preview"), + currencyInfo: CurrencyInfo.zero(LONGCURRENCY), exchange: exchange1, amountAvailable: Amount(currency: LONGCURRENCY, cent: 5000), // 50,00 currency: LONGCURRENCY, diff --git a/TalerWallet1/Views/Banking/ExchangeSectionView.swift b/TalerWallet1/Views/Banking/ExchangeSectionView.swift @@ -45,11 +45,12 @@ struct ExchangeSectionView: View { #endif let scopeInfo = exchange.scopeInfo let currency = scopeInfo.currency - let currencyInfoOpt = controller.info(for: currency) // might be nil - let currencyName = currencyInfoOpt?.scope.currency ?? currency // might be "Unknown" + let currencyInfo = controller.info(for: currency, controller.currencyTicker) + let currencyName = currencyInfo.scope.currency Section { // ForEach(exchanges) { exchange in ExchangeRowView(stack: stack.push(), + currencyInfo: currencyInfo, exchange: exchange, amountAvailable: amountAvailable(exchange, currency: currency), // depositIBAN: $depositIBAN,