taler-ios

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

commit 072bca2209ba2384d6639400e057a8390e614954
parent e4d886798a108d4fa1408ecdd85ec2febc1022ce
Author: Marc Stibane <marc@taler.net>
Date:   Thu, 18 Jul 2024 12:06:43 +0200

Use currencyName for header

Diffstat:
MTalerWallet1/Views/Balances/BalancesSectionView.swift | 15++++++++++-----
MTalerWallet1/Views/Overview/OverviewSectionV.swift | 9++++-----
2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift b/TalerWallet1/Views/Balances/BalancesSectionView.swift @@ -40,6 +40,8 @@ struct BalancesSectionView { @State private var transactions: [Transaction] = [] @State private var completedTransactions: [Transaction] = [] @State private var pendingTransactions: [Transaction] = [] + @State private var currencyInfo: CurrencyInfo = CurrencyInfo.zero("UNKNOWN") + @State private var currencyName: String = "UNKNOWN" func reloadOneAction(_ transactionId: String, _ viewHandles: Bool) async throws -> Transaction { return try await model.getTransactionByIdT(transactionId, viewHandles: viewHandles) @@ -69,8 +71,8 @@ extension BalancesSectionView: View { #endif let scopeInfo = balance.scopeInfo let currency = scopeInfo.currency - let currencyInfo = controller.info(for: currency) + Group { Section { if scopeInfo.type == .exchange { let baseURL = scopeInfo.url?.trimURL() ?? String(localized: "Unknown Payment Provider", comment: "exchange url") @@ -96,7 +98,6 @@ extension BalancesSectionView: View { reloadOneAction: reloadOneAction) .padding(.leading, ICONLEADING) } - let currencyName = currencyInfo?.scope.currency ?? currency let showSpendingButton = DEMOCURRENCY == currency && !balance.available.isZero if showSpendingButton { if !minimalistic && showSpendingHint { @@ -132,10 +133,14 @@ extension BalancesSectionView: View { .listRowSeparator(.hidden) } header: { - BarGraphHeader(stack: stack.push(), scopeInfo: scopeInfo, - currencyName: currencyInfo?.scope.currency ?? currency, - shouldReloadBalances: $shouldReloadBalances) + BarGraphHeader(stack: stack.push(), scopeInfo: scopeInfo, currencyName: currencyName, + shouldReloadBalances: $shouldReloadBalances) }.id(sectionID) + .task(id: controller.currencyTicker) { + currencyInfo = controller.info(for: currency, controller.currencyTicker) + currencyName = currencyInfo.scope.currency + } + } // group .task(id: shouldReloadBalances + 1_000_000) { // if shownSectionID != sectionID { symLog.log(".task for BalancesSectionView - reload Transactions") diff --git a/TalerWallet1/Views/Overview/OverviewSectionV.swift b/TalerWallet1/Views/Overview/OverviewSectionV.swift @@ -68,7 +68,8 @@ extension OverviewSectionV: View { #endif let scopeInfo = balance.scopeInfo let currency = scopeInfo.currency - let currencyInfo = controller.info(for: currency) + let currencyInfo = controller.info(for: currency, controller.currencyTicker) + let currencyName = currencyInfo.scope.currency Section { if scopeInfo.type == .exchange { @@ -95,9 +96,8 @@ extension OverviewSectionV: View { .padding(.leading, ICONLEADING) } } header: { - BarGraphHeader(stack: stack.push(), scopeInfo: scopeInfo, - currencyName: currencyInfo?.scope.currency ?? currency, - shouldReloadBalances: $shouldReloadBalances) + BarGraphHeader(stack: stack.push(), scopeInfo: scopeInfo, currencyName: currencyName, + shouldReloadBalances: $shouldReloadBalances) }.id(sectionID) .task(id: shouldReloadBalances + 1_000_000) { // if shownSectionID != sectionID { @@ -141,7 +141,6 @@ extension OverviewSectionV: View { fileprivate struct CurrenciesPendingRowV: View { let symLog: SymLogV? let stack: CallStack -// let currency: String // = currencyInfo.scope.currency let balance: Balance // this is the currency to be used @Binding var pendingTransactions: [Transaction] let reloadPending: (_ stack: CallStack) async -> ()