taler-ios

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

commit 1621944b2edb2e9ba33f0e8f7eb7ee94a1772930
parent baa2344ebbf76c1be1ddfd079ea57451041ee66e
Author: Marc Stibane <marc@taler.net>
Date:   Thu,  7 Nov 2024 23:04:23 +0100

- LazyView

Diffstat:
MTalerWallet1/Views/Balances/BalanceCellV.swift | 2+-
MTalerWallet1/Views/Balances/BalancesSectionView.swift | 4+---
MTalerWallet1/Views/HelperViews/ToSButtonView.swift | 11+++++------
MTalerWallet1/Views/Main/MainView.swift | 8--------
MTalerWallet1/Views/Settings/SettingsView.swift | 8+++-----
MTalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift | 9++++-----
MTalerWallet1/Views/Sheets/Payment/PayTemplateV.swift | 29++++++++++++-----------------
7 files changed, 26 insertions(+), 45 deletions(-)

diff --git a/TalerWallet1/Views/Balances/BalanceCellV.swift b/TalerWallet1/Views/Balances/BalanceCellV.swift @@ -15,7 +15,7 @@ struct BalanceCellV: View { let amount: Amount // let sizeCategory: ContentSizeCategory // let rowAction: () -> Void - let balanceDest: LazyView<TransactionsListView>? + let balanceDest: TransactionsListView @Environment(\.colorScheme) private var colorScheme @Environment(\.colorSchemeContrast) private var colorSchemeContrast diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift b/TalerWallet1/Views/Balances/BalancesSectionView.swift @@ -95,8 +95,7 @@ extension BalancesSectionView: View { let scopeInfo = balance.scopeInfo let currency = scopeInfo.currency - let balanceDest = LazyView { - TransactionsListView(stack: stack.push("\(Self.className())()"), + let balanceDest = TransactionsListView(stack: stack.push("\(Self.className())()"), scope: scopeInfo, balance: balance, selectedBalance: $selectedBalance, @@ -104,7 +103,6 @@ extension BalancesSectionView: View { transactions: $completedTransactions, reloadAllAction: loadCompleted, reloadOneAction: reloadOneAction) - } Section { BalanceCellV(stack: stack.push("BalanceCell"), diff --git a/TalerWallet1/Views/HelperViews/ToSButtonView.swift b/TalerWallet1/Views/HelperViews/ToSButtonView.swift @@ -25,12 +25,11 @@ struct ToSButtonView: View { .talerFont(.body) .multilineTextAlignment(.leading) .padding() - NavigationLink(destination: LazyView { - WithdrawTOSView(stack: stack.push(), - exchangeBaseUrl: exchangeBaseUrl, - viewID: viewID, - acceptAction: acceptAction) // pop back to here - }) { + let destination = WithdrawTOSView(stack: stack.push(), + exchangeBaseUrl: exchangeBaseUrl, + viewID: viewID, + acceptAction: acceptAction) // pop back to here + NavigationLink(destination: destination) { Text("Terms of Service") // VIEW_WITHDRAW_TOS }.buttonStyle(TalerButtonStyle(type: .prominent)) .padding(.horizontal) diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift @@ -12,14 +12,6 @@ import SymLog import AVFoundation import taler_swift -// Use this to delay instantiation when using `NavigationLink`, etc... -struct LazyView<Content: View>: View { - var content: () -> Content - var body: some View { - self.content() - } -} - struct MainView: View { private let symLog = SymLogV(0) let logger: Logger diff --git a/TalerWallet1/Views/Settings/SettingsView.swift b/TalerWallet1/Views/Settings/SettingsView.swift @@ -92,17 +92,15 @@ struct SettingsView: View { let localizedAppName = Bundle.main.bundleName ?? appName let aboutStr = String(localized: "About \(localizedAppName)") NavigationLink { // whole row like in a tableView - LazyView { AboutView(stack: stack.push(), navTitle: aboutStr) } + AboutView(stack: stack.push(), navTitle: aboutStr) } label: { SettingsItem(name: aboutStr, id1: "about", description: hideDescriptions ? nil : String(localized: "More info about this app...")) {} } let exchangesTitle = String(localized: "TitleExchanges", defaultValue: "Payment Services") - let exchangesDest = LazyView { - ExchangeListView(stack: stack.push(exchangesTitle), - navTitle: exchangesTitle) - } + let exchangesDest = ExchangeListView(stack: stack.push(exchangesTitle), + navTitle: exchangesTitle) NavigationLink { // whole row like in a tableView exchangesDest } label: { diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift @@ -74,11 +74,10 @@ struct P2pReceiveURIView: View { currencyInfo = controller.info2(for: currency, controller.currencyTicker) } if tosAccepted { - NavigationLink(destination: LazyView { - P2pAcceptDone(stack: stack.push(), - transactionId: peerPushCreditResponse.transactionId, - incoming: true) - }) { + let destination = P2pAcceptDone(stack: stack.push(), + transactionId: peerPushCreditResponse.transactionId, + incoming: true) + NavigationLink(destination: destination) { Text("Accept P2P Receive") // SHEET_RCV_P2P_ACCEPT } .buttonStyle(TalerButtonStyle(type: .prominent)) diff --git a/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift b/TalerWallet1/Views/Sheets/Payment/PayTemplateV.swift @@ -86,28 +86,25 @@ struct PayTemplateV: View { // let currencyInfo = controller.info(for: currency, controller.currencyTicker) let amountLabel = minimalistic ? String(localized: "Amount:") : String(localized: "Amount to pay:") - let finalDestinationI = LazyView { - PaymentView(stack: stack.push(), - url: url, - template: true, + // final destination with amountToTransfer, after user input of amount + let finalDestinationI = PaymentView(stack: stack.push(), + url: url, + template: true, amountToTransfer: $amountToTransfer, summary: $summary, amountIsEditable: amountIsEditable, summaryIsEditable: summaryIsEditable) - } // final destination with amountToTransfer, after user input of amount - let finalDestinationS = LazyView { - PaymentView(stack: stack.push(), - url: url, + let finalDestinationS = PaymentView(stack: stack.push(), + url: url, template: true, amountToTransfer: $amountShortcut, summary: $summary, amountIsEditable: amountIsEditable, summaryIsEditable: summaryIsEditable) - } // final destination with amountShortcut, when user tapped a shortcut - let inputDestination = LazyView { - SubjectInputV(stack: stack.push(), - url: url, + // destination to subject input + let inputDestination = SubjectInputV(stack: stack.push(), + url: url, amountAvailable: nil, amountToTransfer: $amountToTransfer, amountLabel: amountLabel, @@ -116,10 +113,9 @@ struct PayTemplateV: View { // feeAmount: $feeAmount, feeIsNotZero: true, // TODO: feeIsNotZero() targetView: finalDestinationI) - } // destination to subject input - let shortcutDestination = LazyView { - SubjectInputV(stack: stack.push(), - url: url, + // destination to subject input, when user tapped an amount shortcut + let shortcutDestination = SubjectInputV(stack: stack.push(), + url: url, amountAvailable: nil, amountToTransfer: $amountShortcut, amountLabel: amountLabel, @@ -128,7 +124,6 @@ struct PayTemplateV: View { // feeAmount: $feeAmount, feeIsNotZero: true, // TODO: feeIsNotZero() targetView: finalDestinationS) - }// destination to subject input, when user tapped an amount shortcut Group { if amountIsEditable { // template contract amount is not fixed => let the user input an amount first let amountInput = AmountInputV(stack: stack.push(),