commit 38a00b98662986c28f7e54b1f23dc611950bc94d parent 8a5c684ac1008c8330f57acbb56e43c2adf46765 Author: Marc Stibane <marc@taler.net> Date: Fri, 13 Oct 2023 08:03:40 +0200 More CallStack for Debugging Diffstat:
21 files changed, 60 insertions(+), 47 deletions(-)
diff --git a/TalerWallet1/Controllers/DebugViewC.swift b/TalerWallet1/Controllers/DebugViewC.swift @@ -146,7 +146,7 @@ class DebugViewC: ObservableObject { @Published var viewID: Int = 0 @Published var sheetID: Int = 0 - @MainActor func setViewID(_ newID: Int) -> Void { + @MainActor func setViewID(_ newID: Int, stack: CallStack) -> Void { if developerMode { if viewID == 0 { symLog.log("switching ON, \(newID)") diff --git a/TalerWallet1/Views/Balances/BalancesListView.swift b/TalerWallet1/Views/Balances/BalancesListView.swift @@ -92,7 +92,7 @@ struct BalancesListView: View { trailing: QRButton(action: checkCameraAvailable)) .overlay { if balances.isEmpty { - WalletEmptyView() + WalletEmptyView(stack: stack.push()) .refreshable { // already async symLog.log("empty refreshing") let count = await reloadAction(stack.push("empty refreshing")) @@ -109,7 +109,7 @@ struct BalancesListView: View { dismissAlertButton }, message: { Text("Please allow camera access in settings.") }) .onAppear() { - DebugViewC.shared.setViewID(VIEW_BALANCES) + DebugViewC.shared.setViewID(VIEW_BALANCES, stack: stack.push("onAppear")) } .sheet(isPresented: $showQRScanner) { let sheet = AnyView(QRSheet(stack: stack.push())) diff --git a/TalerWallet1/Views/Exchange/ExchangeListView.swift b/TalerWallet1/Views/Exchange/ExchangeListView.swift @@ -124,7 +124,7 @@ extension ExchangeListView { .listStyle(myListStyle.style).anyView } .onAppear() { - DebugViewC.shared.setViewID(VIEW_EXCHANGES) + DebugViewC.shared.setViewID(VIEW_EXCHANGES, stack: stack.push()) } .onNotification(.ExchangeAdded) { notification in // doesn't need to be received on main thread because we just reload in the background anyway diff --git a/TalerWallet1/Views/Exchange/ManualWithdraw.swift b/TalerWallet1/Views/Exchange/ManualWithdraw.swift @@ -62,9 +62,10 @@ struct ManualWithdraw: View { .buttonStyle(TalerButtonStyle(type: .prominent)) .padding(.horizontal) } else { - ToSButtonView(exchangeBaseUrl: exchange.exchangeBaseUrl, - viewID: VIEW_WITHDRAW_TOS, - p2p: false) + ToSButtonView(stack: stack.push(), + exchangeBaseUrl: exchange.exchangeBaseUrl, + viewID: VIEW_WITHDRAW_TOS, + p2p: false) } } } // disabled @@ -77,7 +78,7 @@ struct ManualWithdraw: View { .navigationTitle(navTitle) .onAppear { symLog.log("onAppear") - DebugViewC.shared.setViewID(VIEW_WITHDRAWAL) + DebugViewC.shared.setViewID(VIEW_WITHDRAWAL, stack: stack.push()) } .task(id: centsToTransfer) { // re-run this whenever centsToTransfer changes let amount = Amount.amountFromCents(currency, centsToTransfer) diff --git a/TalerWallet1/Views/Exchange/ManualWithdrawDone.swift b/TalerWallet1/Views/Exchange/ManualWithdrawDone.swift @@ -50,7 +50,7 @@ struct ManualWithdrawDone: View { } }.onAppear() { symLog.log("onAppear") - DebugViewC.shared.setViewID(VIEW_WITHDRAW_ACCEPT) + DebugViewC.shared.setViewID(VIEW_WITHDRAW_ACCEPT, stack: stack.push()) }.task { do { let amount = Amount.amountFromCents(exchange.currency!, centsToTransfer) diff --git a/TalerWallet1/Views/HelperViews/ToSButtonView.swift b/TalerWallet1/Views/HelperViews/ToSButtonView.swift @@ -9,6 +9,7 @@ import SwiftUI struct ToSButtonView: View { + let stack: CallStack let exchangeBaseUrl: String? let viewID: Int // either VIEW_WITHDRAW_TOS or SHEET_WITHDRAW_TOS let p2p: Bool @@ -21,9 +22,10 @@ struct ToSButtonView: View { .multilineTextAlignment(.leading) .padding() NavigationLink(destination: LazyView { - WithdrawTOSView(exchangeBaseUrl: exchangeBaseUrl, - viewID: viewID, - acceptAction: nil) // pop back to here + WithdrawTOSView(stack: stack.push(), + exchangeBaseUrl: exchangeBaseUrl, + viewID: viewID, + acceptAction: nil) // pop back to here }) { Text("Terms of Service") // VIEW_WITHDRAW_TOS }.buttonStyle(TalerButtonStyle(type: .prominent)) @@ -32,5 +34,5 @@ struct ToSButtonView: View { } #Preview { - ToSButtonView(exchangeBaseUrl: nil, viewID: 0, p2p: false) + ToSButtonView(stack: CallStack("Preview"), exchangeBaseUrl: nil, viewID: 0, p2p: false) } diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift @@ -33,7 +33,7 @@ struct MainView: View { #endif Group { if controller.backendState == .ready { - Content(symLog: symLog, stack: stack.push(), talerFont: $talerFont) + Content(symLog: symLog, stack: stack.push("Content"), talerFont: $talerFont) // any change to rootViewId triggers popToRootView behaviour .id(viewState.rootViewId) .onAppear() { @@ -78,14 +78,15 @@ extension MainView { } } - let balances = String(localized: "Balances") + let balancesTitle = String(localized: "Balances") let exchanges = String(localized: "Exchanges") + let settingsTitle = String(localized: "Settings") let settings = String(localized: "Settings") var views: [SidebarItem] {[ - SidebarItem(name: balances, + SidebarItem(name: balancesTitle, sysImage: "creditcard.fill", // TODO: Wallet Icon - view: AnyView(BalancesListView(stack: stack.push(balances), - navTitle: balances, + view: AnyView(BalancesListView(stack: stack.push(balancesTitle), + navTitle: balancesTitle, hamburgerAction: hamburgerAction) )), SidebarItem(name: exchanges, @@ -94,10 +95,11 @@ extension MainView { navTitle: exchanges, hamburgerAction: hamburgerAction) )), - SidebarItem(name: settings, // TODO: "About"? + SidebarItem(name: settingsTitle, // TODO: "About"? sysImage: "gearshape.fill", - view: AnyView(SettingsView(navTitle: settings, - hamburgerAction: hamburgerAction) + view: AnyView(SettingsView(stack: stack.push(settingsTitle), + navTitle: settingsTitle, + hamburgerAction: hamburgerAction) )) ]} @State var currentView: Int = 0 diff --git a/TalerWallet1/Views/Main/SideBarView.swift b/TalerWallet1/Views/Main/SideBarView.swift @@ -97,10 +97,10 @@ struct SideBarView_Previews: PreviewProvider { static var views: [SidebarItem] {[ SidebarItem(name: "Balances", sysImage: "creditcard.fill", // TODO: Wallet Icon - view: AnyView(WalletEmptyView())), + view: AnyView(WalletEmptyView(stack: CallStack("Preview")))), SidebarItem(name: "Settings", sysImage: "gearshape.fill", - view: AnyView(WalletEmptyView())) + view: AnyView(WalletEmptyView(stack: CallStack("Preview")))) ]} static var previews: some View { BindingViewContainer(views: views) diff --git a/TalerWallet1/Views/Main/WalletEmptyView.swift b/TalerWallet1/Views/Main/WalletEmptyView.swift @@ -10,6 +10,7 @@ import SymLog struct WalletEmptyView: View { private let symLog = SymLogV(0) + let stack: CallStack @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic var body: some View { @@ -31,13 +32,13 @@ struct WalletEmptyView: View { .accessibilityFont(.title2) .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) .onAppear() { - DebugViewC.shared.setViewID(VIEW_EMPTY) // 10 + DebugViewC.shared.setViewID(VIEW_EMPTY, stack: stack.push("onAppear")) // 10 } } } struct WalletEmptyView_Previews: PreviewProvider { static var previews: some View { - WalletEmptyView() + WalletEmptyView(stack: CallStack("Preview")) } } diff --git a/TalerWallet1/Views/Peer2peer/PaymentPurpose.swift b/TalerWallet1/Views/Peer2peer/PaymentPurpose.swift @@ -86,7 +86,7 @@ struct PaymentPurpose: View { .navigationTitle("Request") .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) .onAppear { - DebugViewC.shared.setViewID(VIEW_RECEIVE_PURPOSE) + DebugViewC.shared.setViewID(VIEW_RECEIVE_PURPOSE, stack: stack.push()) print("❗️ PaymentPurpose onAppear") } .onDisappear { diff --git a/TalerWallet1/Views/Peer2peer/RequestPayment.swift b/TalerWallet1/Views/Peer2peer/RequestPayment.swift @@ -62,7 +62,7 @@ struct RequestPayment: View { .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) .navigationTitle(navTitle) .onAppear { // make CurrencyField show the keyboard - DebugViewC.shared.setViewID(VIEW_RECEIVE_P2P) + DebugViewC.shared.setViewID(VIEW_RECEIVE_P2P, stack: stack.push()) symLog.log("❗️Yikes \(navTitle) onAppear") } .onDisappear { diff --git a/TalerWallet1/Views/Peer2peer/SendAmount.swift b/TalerWallet1/Views/Peer2peer/SendAmount.swift @@ -75,7 +75,7 @@ struct SendAmount: View { .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) .navigationTitle(navTitle) .onAppear { // make CurrencyField show the keyboard - DebugViewC.shared.setViewID(VIEW_SEND_P2P) + DebugViewC.shared.setViewID(VIEW_SEND_P2P, stack: stack.push()) symLog.log("❗️Yikes SendAmount onAppear") } .onDisappear { diff --git a/TalerWallet1/Views/Peer2peer/SendPurpose.swift b/TalerWallet1/Views/Peer2peer/SendPurpose.swift @@ -103,7 +103,7 @@ struct SendPurpose: View { .navigationTitle("Purpose") .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) .onAppear { - DebugViewC.shared.setViewID(VIEW_SEND_PURPOSE) + DebugViewC.shared.setViewID(VIEW_SEND_PURPOSE, stack: stack.push()) print("❗️ SendPurpose onAppear") } .onDisappear { diff --git a/TalerWallet1/Views/Settings/Pending/PendingOpsListView.swift b/TalerWallet1/Views/Settings/Pending/PendingOpsListView.swift @@ -7,6 +7,7 @@ import SymLog struct PendingOpsListView: View { let navTitle = String(localized: "Pending") + let stack: CallStack @EnvironmentObject private var model: WalletModel @@ -14,7 +15,7 @@ struct PendingOpsListView: View { var body: some View { let reloadAction = model.getPendingOperationsM - Content(pendingOperations: $pendingOperations, reloadAction: reloadAction) + Content(stack: stack.push(), pendingOperations: $pendingOperations, reloadAction: reloadAction) .navigationTitle(navTitle) .task { pendingOperations = await reloadAction() @@ -24,6 +25,7 @@ struct PendingOpsListView: View { // MARK: - extension PendingOpsListView { struct Content: View { + let stack: CallStack @Binding var pendingOperations: [PendingOperation] var reloadAction: () async -> [PendingOperation] @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic @@ -34,7 +36,7 @@ extension PendingOpsListView { } .listStyle(myListStyle.style).anyView .onAppear() { - DebugViewC.shared.setViewID(VIEW_PENDING) + DebugViewC.shared.setViewID(VIEW_PENDING, stack: stack.push()) } .refreshable { pendingOperations = await reloadAction() diff --git a/TalerWallet1/Views/Settings/SettingsView.swift b/TalerWallet1/Views/Settings/SettingsView.swift @@ -19,6 +19,7 @@ import SymLog struct SettingsView: View { private let symLog = SymLogV(0) + let stack: CallStack let navTitle: String @EnvironmentObject private var controller: Controller @@ -94,12 +95,12 @@ struct SettingsView: View { if diagnosticModeEnabled { SettingsToggle(name: String(localized: "Developer Mode"), value: $developerMode, description: String(localized: "More information intended for debugging")) { - DebugViewC.shared.setViewID(VIEW_SETTINGS) + DebugViewC.shared.setViewID(VIEW_SETTINGS, stack: stack.push()) withAnimation { showDevelopItems = developerMode } } if showDevelopItems { // show or hide the following items NavigationLink { // whole row like in a tableView - LazyView { PendingOpsListView() } + LazyView { PendingOpsListView(stack: stack.push()) } } label: { SettingsItem(name: String(localized: "Pending Operations"), description: String(localized: "Exchange not yet ready...")) {} @@ -252,7 +253,7 @@ struct SettingsView: View { .navigationBarItems(leading: HamburgerButton(action: hamburgerAction)) .onAppear() { showDevelopItems = developerMode - DebugViewC.shared.setViewID(VIEW_SETTINGS) + DebugViewC.shared.setViewID(VIEW_SETTINGS, stack: stack.push()) } .alert("Reset Wallet", isPresented: $showResetAlert, @@ -286,7 +287,7 @@ extension Bundle { #if DEBUG struct SettingsView_Previews: PreviewProvider { static var previews: some View { - SettingsView(navTitle: "Settings") { } + SettingsView(stack: CallStack("Preview"), navTitle: "Settings") { } } } #endif diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift @@ -50,9 +50,10 @@ struct P2pReceiveURIView: View { .buttonStyle(TalerButtonStyle(type: .prominent)) .padding(.horizontal) } else { - ToSButtonView(exchangeBaseUrl: nil, - viewID: SHEET_RCV_P2P_TOS, - p2p: true) + ToSButtonView(stack: stack.push(), + exchangeBaseUrl: nil, + viewID: SHEET_RCV_P2P_TOS, + p2p: true) } } else { // Yikes no details or no baseURL diff --git a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawTOSView.swift b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawTOSView.swift @@ -7,6 +7,7 @@ import SymLog struct WithdrawTOSView: View { private let symLog = SymLogV(0) + let stack: CallStack @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic let navTitle = String(localized: "Terms of Service") @@ -56,7 +57,7 @@ struct WithdrawTOSView: View { if viewID > SHEET_WITHDRAWAL { DebugViewC.shared.setSheetID(SHEET_WITHDRAW_TOS) } else { - DebugViewC.shared.setViewID(VIEW_WITHDRAW_TOS) + DebugViewC.shared.setViewID(VIEW_WITHDRAW_TOS, stack: stack.push()) } }.task { do { diff --git a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift @@ -60,9 +60,10 @@ struct WithdrawURIView: View { .buttonStyle(TalerButtonStyle(type: .prominent)) .padding(.horizontal) } else { - ToSButtonView(exchangeBaseUrl: exchangeBaseUrl, - viewID: SHEET_WITHDRAW_TOS, - p2p: false) + ToSButtonView(stack: stack.push(), + exchangeBaseUrl: exchangeBaseUrl, + viewID: SHEET_WITHDRAW_TOS, + p2p: false) } } else { // Yikes no details or no baseURL diff --git a/TalerWallet1/Views/Transactions/TransactionDetailView.swift b/TalerWallet1/Views/Transactions/TransactionDetailView.swift @@ -158,7 +158,7 @@ struct TransactionDetailView: View { } .onAppear { symLog.log("onAppear") - DebugViewC.shared.setViewID(VIEW_TRANSACTIONDETAIL) + DebugViewC.shared.setViewID(VIEW_TRANSACTIONDETAIL, stack: stack.push()) } .onDisappear { symLog.log("onDisappear") diff --git a/TalerWallet1/Views/Transactions/TransactionsEmptyView.swift b/TalerWallet1/Views/Transactions/TransactionsEmptyView.swift @@ -10,6 +10,7 @@ import SymLog struct TransactionsEmptyView: View { private let symLog = SymLogV(0) + let stack: CallStack @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic let currency: String @@ -25,13 +26,13 @@ struct TransactionsEmptyView: View { // .padding(.vertical) .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) .onAppear() { - DebugViewC.shared.setViewID(VIEW_EMPTY) // 10 + DebugViewC.shared.setViewID(VIEW_EMPTY, stack: stack.push()) // 10 } } } struct TransactionsEmptyView_Previews: PreviewProvider { static var previews: some View { - TransactionsEmptyView(currency: LONGCURRENCY) + TransactionsEmptyView(stack: CallStack("Preview"), currency: LONGCURRENCY) } } diff --git a/TalerWallet1/Views/Transactions/TransactionsListView.swift b/TalerWallet1/Views/Transactions/TransactionsListView.swift @@ -68,11 +68,11 @@ struct TransactionsListView: View { } .overlay { if transactions.isEmpty { - TransactionsEmptyView(currency: currency) + TransactionsEmptyView(stack: stack.push(), currency: currency) } } .onAppear { - DebugViewC.shared.setViewID(VIEW_TRANSACTIONLIST) + DebugViewC.shared.setViewID(VIEW_TRANSACTIONLIST, stack: stack.push()) } } }