commit 2387c4f4627d3ce7fc22d61beceb67573ea677b4 parent 6e44b574388ad563782c193c822ee536e2954ce4 Author: Marc Stibane <marc@taler.net> Date: Fri, 8 Dec 2023 18:13:51 +0100 LoadingView Diffstat:
15 files changed, 81 insertions(+), 113 deletions(-)
diff --git a/TalerWallet.xcodeproj/project.pbxproj b/TalerWallet.xcodeproj/project.pbxproj @@ -85,7 +85,6 @@ 4E3EAE5B2A990778009F1BE8 /* View+Notification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E3B4BC62A429F2A00CC88B8 /* View+Notification.swift */; }; 4E3EAE5C2A990778009F1BE8 /* Model+Pending.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB0954C2989CBFE0043A8A1 /* Model+Pending.swift */; }; 4E3EAE5D2A990778009F1BE8 /* ExchangeListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095292989CBFE0043A8A1 /* ExchangeListView.swift */; }; - 4E3EAE5E2A990778009F1BE8 /* WithdrawProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB0953F2989CBFE0043A8A1 /* WithdrawProgressView.swift */; }; 4E3EAE5F2A990778009F1BE8 /* QRSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EEC157929F9427F00D46A03 /* QRSheet.swift */; }; 4E3EAE602A990778009F1BE8 /* P2pReceiveURIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E3B4BC02A41E6C200CC88B8 /* P2pReceiveURIView.swift */; }; 4E3EAE612A990778009F1BE8 /* ListStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6EDD862A363D8D0031D520 /* ListStyle.swift */; }; @@ -208,7 +207,6 @@ 4EB095602989CBFE0043A8A1 /* BalancesSectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB0953A2989CBFE0043A8A1 /* BalancesSectionView.swift */; }; 4EB095612989CBFE0043A8A1 /* WithdrawURIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB0953C2989CBFE0043A8A1 /* WithdrawURIView.swift */; }; 4EB095622989CBFE0043A8A1 /* Model+Withdraw.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB0953D2989CBFE0043A8A1 /* Model+Withdraw.swift */; }; - 4EB095642989CBFE0043A8A1 /* WithdrawProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB0953F2989CBFE0043A8A1 /* WithdrawProgressView.swift */; }; 4EB095652989CBFE0043A8A1 /* WithdrawTOSView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095402989CBFE0043A8A1 /* WithdrawTOSView.swift */; }; 4EB095662989CBFE0043A8A1 /* SideBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095422989CBFE0043A8A1 /* SideBarView.swift */; }; 4EB095672989CBFE0043A8A1 /* LaunchAnimationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095432989CBFE0043A8A1 /* LaunchAnimationView.swift */; }; @@ -385,7 +383,6 @@ 4EB0953A2989CBFE0043A8A1 /* BalancesSectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BalancesSectionView.swift; sourceTree = "<group>"; }; 4EB0953C2989CBFE0043A8A1 /* WithdrawURIView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WithdrawURIView.swift; sourceTree = "<group>"; }; 4EB0953D2989CBFE0043A8A1 /* Model+Withdraw.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Model+Withdraw.swift"; sourceTree = "<group>"; }; - 4EB0953F2989CBFE0043A8A1 /* WithdrawProgressView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WithdrawProgressView.swift; sourceTree = "<group>"; }; 4EB095402989CBFE0043A8A1 /* WithdrawTOSView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WithdrawTOSView.swift; sourceTree = "<group>"; }; 4EB095422989CBFE0043A8A1 /* SideBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideBarView.swift; sourceTree = "<group>"; }; 4EB095432989CBFE0043A8A1 /* LaunchAnimationView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LaunchAnimationView.swift; sourceTree = "<group>"; }; @@ -712,7 +709,6 @@ children = ( 4EB0953C2989CBFE0043A8A1 /* WithdrawURIView.swift */, 4E5A88F62A3B9E5B00072618 /* WithdrawAcceptDone.swift */, - 4EB0953F2989CBFE0043A8A1 /* WithdrawProgressView.swift */, 4EB095402989CBFE0043A8A1 /* WithdrawTOSView.swift */, ); path = WithdrawBankIntegrated; @@ -1110,7 +1106,6 @@ 4E3EAE5B2A990778009F1BE8 /* View+Notification.swift in Sources */, 4E3EAE5C2A990778009F1BE8 /* Model+Pending.swift in Sources */, 4E3EAE5D2A990778009F1BE8 /* ExchangeListView.swift in Sources */, - 4E3EAE5E2A990778009F1BE8 /* WithdrawProgressView.swift in Sources */, E37AA62E2AF19BE0003850CF /* RefundURIView.swift in Sources */, 4E3EAE5F2A990778009F1BE8 /* QRSheet.swift in Sources */, 4E3EAE602A990778009F1BE8 /* P2pReceiveURIView.swift in Sources */, @@ -1218,7 +1213,6 @@ 4E3B4BC72A429F2A00CC88B8 /* View+Notification.swift in Sources */, 4EB0956E2989CBFE0043A8A1 /* Model+Pending.swift in Sources */, 4EB095522989CBFE0043A8A1 /* ExchangeListView.swift in Sources */, - 4EB095642989CBFE0043A8A1 /* WithdrawProgressView.swift in Sources */, E37AA62F2AF19BE0003850CF /* RefundURIView.swift in Sources */, 4EEC157A29F9427F00D46A03 /* QRSheet.swift in Sources */, 4E3B4BC12A41E6C200CC88B8 /* P2pReceiveURIView.swift in Sources */, diff --git a/TalerWallet1/Views/Exchange/ManualWithdraw.swift b/TalerWallet1/Views/Exchange/ManualWithdraw.swift @@ -90,8 +90,7 @@ struct ManualWithdraw: View { symLog.log("❗️ \(navTitle) onDisappear") } } else { - WithdrawProgressView(message: exchangeBaseUrl.trimURL()) - .navigationTitle("Contacting Exchange") + LoadingView(url: nil, message: exchangeBaseUrl.trimURL()) } } .task(id: amountToTransfer.value) { // re-run this whenever amountToTransfer changes symLog.log("getExchangeByUrl(\(exchangeBaseUrl))") diff --git a/TalerWallet1/Views/Exchange/ManualWithdrawDone.swift b/TalerWallet1/Views/Exchange/ManualWithdrawDone.swift @@ -45,8 +45,7 @@ struct ManualWithdrawDone: View { .interactiveDismissDisabled() // can only use "Done" button to dismiss // .navigationTitle(navTitle) } else { - WithdrawProgressView(message: exchange.exchangeBaseUrl.trimURL()) - .navigationTitle("Loading " + navTitle) + LoadingView(url: nil, message: exchange.exchangeBaseUrl.trimURL()) } }.onAppear() { symLog.log("onAppear") diff --git a/TalerWallet1/Views/HelperViews/LoadingView.swift b/TalerWallet1/Views/HelperViews/LoadingView.swift @@ -7,22 +7,49 @@ import SymLog struct LoadingView: View { private let symLog = SymLogV(0) - let navTitle = String(localized: "Loading...") - let backButtonHidden: Bool + let url:URL? + let message: String? + +// let backButtonHidden: Bool + let navTitle = String(localized: "Loading…") + + @State private var rotationEnabled = true var body: some View { - LaunchAnimationView() - .navigationBarBackButtonHidden(backButtonHidden) - .navigationTitle(navTitle) - .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center) -// .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) + VStack(alignment: .center) { + Spacer() + RotatingTaler(size: 100, rotationEnabled: $rotationEnabled) + .onTapGesture(count: 2) { + rotationEnabled.toggle() + } + Spacer() + if let url { + if let urlStr = url.host { + Text(urlStr) + } else { + Text("Error in URL: \(url)") + } + Spacer() + } + if let message { + Text(message) + } else { + Text(EMPTYSTRING) + } + Spacer() + Spacer() + } + .frame(maxWidth: .infinity) + .accessibilityFont(.title) + .navigationTitle("Loading…") + .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) } } // MARK: - struct LoadingView_Previews: PreviewProvider { static var previews: some View { NavigationView { - LoadingView(backButtonHidden: true) + LoadingView(url: nil, message: "test message") // , backButtonHidden: true) .navigationBarTitleDisplayMode(.automatic) }.navigationViewStyle(.stack) } diff --git a/TalerWallet1/Views/Peer2peer/P2PReadyV.swift b/TalerWallet1/Views/Peer2peer/P2PReadyV.swift @@ -51,7 +51,7 @@ struct P2PReadyV: View { .navigationBarBackButtonHidden(true) .interactiveDismissDisabled() // can only use "Done" button to dismiss } else { - WithdrawProgressView(message: "Loading...") + LoadingView(url: nil, message: "for \(amountToTransfer.currencyStr)") } } .navigationTitle(navTitle) diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pPayURIView.swift b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pPayURIView.swift @@ -51,25 +51,21 @@ struct P2pPayURIView: View { .buttonStyle(TalerButtonStyle(type: .prominent)) .padding(.horizontal) } else { - WithdrawProgressView(message: url.host ?? "Yikes❗️ no valid URL") - .navigationTitle("Contacting Exchange") + LoadingView(url: url, message: nil) + .task { do { + symLog.log(".task") + let ppDebitResponse = try await model.preparePeerPullDebitM(url.absoluteString) + peerPullDebitResponse = ppDebitResponse + } catch { // TODO: error + symLog.log(error.localizedDescription) + peerPullDebitResponse = nil + } } } } .onAppear() { symLog.log("onAppear") DebugViewC.shared.setSheetID(SHEET_PAY_P2P) } - .task { - do { // TODO: cancelled - symLog.log(".task") - let ppDebitResponse = try await model.preparePeerPullDebitM(url.absoluteString) - peerPullDebitResponse = ppDebitResponse - } catch { // TODO: error - symLog.log(error.localizedDescription) - peerPullDebitResponse = nil - } - } - } } // MARK: - diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift @@ -60,9 +60,7 @@ struct P2pReceiveURIView: View { p2p: true) } } else { - // Yikes no details or no baseURL - WithdrawProgressView(message: url.host ?? badURL) - .navigationTitle("Contacting Exchange") + LoadingView(url: url, message: nil) } } .onAppear() { diff --git a/TalerWallet1/Views/Sheets/Payment/PayTemplateView.swift b/TalerWallet1/Views/Sheets/Payment/PayTemplateView.swift @@ -103,9 +103,7 @@ struct PayTemplateView: View { DebugViewC.shared.setSheetID(SHEET_PAY_TEMPLATE) } } else { - let badURL = "Error in Link: \(url)" - WithdrawProgressView(message: url.host ?? badURL) - .navigationTitle("Find Exchange") + LoadingView(url: url, message: nil) .task { do { symLog.log(".task") diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift @@ -99,9 +99,7 @@ struct PaymentView: View { DebugViewC.shared.setSheetID(SHEET_PAYMENT) } } else { - let badURL = "Error in Link: \(url)" - WithdrawProgressView(message: url.host ?? badURL) - .navigationTitle("Find Exchange") + LoadingView(url: url, message: nil) .task { do { symLog.log(".task") diff --git a/TalerWallet1/Views/Sheets/Refund/RefundURIView.swift b/TalerWallet1/Views/Sheets/Refund/RefundURIView.swift @@ -34,9 +34,7 @@ struct RefundURIView: View { suspendAction: model.suspendTransaction, resumeAction: model.resumeTransaction) } else { - let badURL = "Error in Link: \(url)" - WithdrawProgressView(message: url.host ?? badURL) - .navigationTitle("Find Exchange") + LoadingView(url: url, message: nil) .task { do { symLog.log(".task") diff --git a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptDone.swift b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptDone.swift @@ -44,8 +44,8 @@ struct WithdrawAcceptDone: View { .interactiveDismissDisabled() // can only use "Done" button to dismiss .navigationTitle(navTitle) } else { - WithdrawProgressView(message: "Bank Confirmation") - .navigationTitle("Loading...") + LoadingView(url: nil, message: exchangeBaseUrl?.trimURL() + ?? "Bank Confirmation") } }.onAppear() { symLog.log("onAppear") diff --git a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawProgressView.swift b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawProgressView.swift @@ -1,32 +0,0 @@ -/* - * This file is part of GNU Taler, ©2022-23 Taler Systems S.A. - * See LICENSE.md - */ -import SwiftUI - -struct WithdrawProgressView: View { - let message: String - - var body: some View { - VStack { - Spacer() - ProgressView() - Spacer() - HStack { - Spacer() - Text(message) - .accessibilityFont(.title) - Spacer() - } - Spacer() - Spacer() - } - .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) - } -} - -struct WithdrawProgressView_Previews: PreviewProvider { - static var previews: some View { - WithdrawProgressView(message: "message") - } -} diff --git a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawTOSView.swift b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawTOSView.swift @@ -22,11 +22,11 @@ struct WithdrawTOSView: View { @State var exchangeTOS: ExchangeTermsOfService? var body: some View { - VStack { + if let exchangeTOS { Content(symLog: symLog, exchangeTOS: exchangeTOS, myListStyle: $myListStyle) { Task { // runs on MainActor do { - if let exchangeBaseUrl, let exchangeTOS { + if let exchangeBaseUrl { _ = try await model.setExchangeTOSAcceptedM(exchangeBaseUrl, etag: exchangeTOS.currentEtag) if acceptAction != nil { acceptAction!() @@ -42,35 +42,32 @@ struct WithdrawTOSView: View { } } .navigationTitle(navTitle) - .overlay { - if exchangeTOS == nil { + .onAppear() { + if viewID > SHEET_WITHDRAWAL { + DebugViewC.shared.setSheetID(SHEET_WITHDRAW_TOS) + } else { + DebugViewC.shared.setViewID(VIEW_WITHDRAW_TOS, stack: stack.push()) + } + } + } else { + LoadingView(url: nil, message: exchangeBaseUrl?.trimURL() ?? "No exchangeBaseUrl!") +// ContactingExchangeV(url: nil, message: exchangeBaseUrl?.trimURL() +// ?? "No exchangeBaseUrl!") + .task { do { if let exchangeBaseUrl { - WithdrawProgressView(message: exchangeBaseUrl.trimURL()) - .navigationTitle("Loading " + navTitle) + let acceptedFormat: [String] = [MARKDOWN, PLAINTEXT] + let someTOS = try await model.loadExchangeTermsOfServiceM(exchangeBaseUrl, + acceptedFormat: acceptedFormat) + exchangeTOS = someTOS } else { - // Yikes! - WithdrawProgressView(message: "No exchangeBaseUrl!") - .navigationTitle("Loading " + navTitle) + // TODO: Yikes! No baseURL + + + } - } - } - }.onAppear() { - if viewID > SHEET_WITHDRAWAL { - DebugViewC.shared.setSheetID(SHEET_WITHDRAW_TOS) - } else { - DebugViewC.shared.setViewID(VIEW_WITHDRAW_TOS, stack: stack.push()) - } - }.task { - do { - if let exchangeBaseUrl { - let acceptedFormat: [String] = [MARKDOWN, PLAINTEXT] - let someTOS = try await model.loadExchangeTermsOfServiceM(exchangeBaseUrl, - acceptedFormat: acceptedFormat) - exchangeTOS = someTOS - } - } catch { // TODO: error - symLog.log(error.localizedDescription) - } + } catch { // TODO: error + symLog.log(error.localizedDescription) + } } } } } diff --git a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawURIView.swift @@ -25,7 +25,6 @@ struct WithdrawURIView: View { @State private var exchange: Exchange? = nil var body: some View { - let badURL = "Error in URL: \(url)" VStack { if let withdrawalAmountDetails, let exchange { List { @@ -70,10 +69,8 @@ struct WithdrawURIView: View { viewID: SHEET_WITHDRAW_TOS, p2p: false) } - } else { - // Yikes no details or no exchange - WithdrawProgressView(message: url.host ?? badURL) - .navigationTitle("Contacting Exchange") + } else { // no details or no exchange + LoadingView(url: url, message: nil) } } .onAppear() { diff --git a/TalerWallet1/Views/Sheets/WithdrawExchangeV.swift b/TalerWallet1/Views/Sheets/WithdrawExchangeV.swift @@ -28,8 +28,7 @@ struct WithdrawExchangeV: View { exchangeBaseUrl: exchangeBaseUrl, amountToTransfer: $amountToTransfer) } else { - WithdrawProgressView(message: exchangeBaseUrl?.trimURL() ?? "No exchangeBaseUrl!") -// ContactingExchangeV(url: url, message: nil) + LoadingView(url: url, message: "No exchangeBaseUrl!") } } .task {