commit b1da0929c1468ca0a44655a775d1f9fb3051faea
parent a81bba71c3175e34fc8f6ddd420d87af1e68606d
Author: Marc Stibane <marc@taler.net>
Date: Sat, 15 Mar 2025 15:18:24 +0100
remove old ErrorView
Diffstat:
6 files changed, 29 insertions(+), 40 deletions(-)
diff --git a/TalerWallet.xcodeproj/project.pbxproj b/TalerWallet.xcodeproj/project.pbxproj
@@ -99,7 +99,6 @@
4E3EAE572A990778009F1BE8 /* quickjs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB0950D2989CB9A0043A8A1 /* quickjs.swift */; };
4E3EAE582A990778009F1BE8 /* CurrencyField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E53A33629F50B7B00830EC2 /* CurrencyField.swift */; };
4E3EAE592A990778009F1BE8 /* Model+Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095102989CBB00043A8A1 /* Model+Settings.swift */; };
- 4E3EAE5A2A990778009F1BE8 /* ErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095452989CBFE0043A8A1 /* ErrorView.swift */; };
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 */; };
@@ -260,7 +259,6 @@
4EB095652989CBFE0043A8A1 /* WithdrawTOSView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095402989CBFE0043A8A1 /* WithdrawTOSView.swift */; };
4EB095672989CBFE0043A8A1 /* LaunchAnimationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095432989CBFE0043A8A1 /* LaunchAnimationView.swift */; };
4EB095682989CBFE0043A8A1 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095442989CBFE0043A8A1 /* MainView.swift */; };
- 4EB095692989CBFE0043A8A1 /* ErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095452989CBFE0043A8A1 /* ErrorView.swift */; };
4EB0956A2989CBFE0043A8A1 /* Buttons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095472989CBFE0043A8A1 /* Buttons.swift */; };
4EB0956B2989CBFE0043A8A1 /* TextFieldAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095482989CBFE0043A8A1 /* TextFieldAlert.swift */; };
4EB0956C2989CBFE0043A8A1 /* AmountRowV.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095492989CBFE0043A8A1 /* AmountRowV.swift */; };
@@ -500,7 +498,6 @@
4EB095402989CBFE0043A8A1 /* WithdrawTOSView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WithdrawTOSView.swift; sourceTree = "<group>"; };
4EB095432989CBFE0043A8A1 /* LaunchAnimationView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LaunchAnimationView.swift; sourceTree = "<group>"; };
4EB095442989CBFE0043A8A1 /* MainView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
- 4EB095452989CBFE0043A8A1 /* ErrorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ErrorView.swift; sourceTree = "<group>"; };
4EB095472989CBFE0043A8A1 /* Buttons.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Buttons.swift; sourceTree = "<group>"; };
4EB095482989CBFE0043A8A1 /* TextFieldAlert.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldAlert.swift; sourceTree = "<group>"; };
4EB095492989CBFE0043A8A1 /* AmountRowV.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmountRowV.swift; sourceTree = "<group>"; };
@@ -898,7 +895,6 @@
children = (
4EB095442989CBFE0043A8A1 /* MainView.swift */,
4EED38542D140C1400F6C038 /* TabBarModel.swift */,
- 4EB095452989CBFE0043A8A1 /* ErrorView.swift */,
4EB095392989CBFE0043A8A1 /* WalletEmptyView.swift */,
);
path = Main;
@@ -1362,7 +1358,6 @@
4E983C292ADBDD3500FA9CC5 /* SingleAxisGeometryReader.swift in Sources */,
4E3EAE592A990778009F1BE8 /* Model+Settings.swift in Sources */,
4EC4008C2AE5664100DF72C7 /* CharacterSet+contains.swift in Sources */,
- 4E3EAE5A2A990778009F1BE8 /* ErrorView.swift in Sources */,
4E847B7F2C9030E0003A164E /* TabBarView.swift in Sources */,
4E4F60A82C3BBF9F003BB669 /* View+Condition.swift in Sources */,
4E96583C2B79656E00404A68 /* DepositAmountV.swift in Sources */,
@@ -1508,7 +1503,6 @@
4E983C2A2ADBDD3500FA9CC5 /* SingleAxisGeometryReader.swift in Sources */,
4EB095152989CBB00043A8A1 /* Model+Settings.swift in Sources */,
4EC4008D2AE5664100DF72C7 /* CharacterSet+contains.swift in Sources */,
- 4EB095692989CBFE0043A8A1 /* ErrorView.swift in Sources */,
4E847B802C9030E0003A164E /* TabBarView.swift in Sources */,
4E4F60A92C3BBF9F003BB669 /* View+Condition.swift in Sources */,
4E96583D2B79656E00404A68 /* DepositAmountV.swift in Sources */,
diff --git a/TalerWallet1/Model/WalletModel.swift b/TalerWallet1/Model/WalletModel.swift
@@ -100,6 +100,13 @@ class WalletModel: ObservableObject {
self.error2 = nil
}
}
+ @MainActor func setMessage(_ title: String,_ theMessage: String?) {
+ if let theMessage {
+ self.error2 = .message(title: title, message: theMessage)
+ } else {
+ self.error2 = nil
+ }
+ }
func sendRequest<T: WalletBackendFormattedRequest> (_ request: T, _ delay: UInt = 0, viewHandles: Bool = false)
async throws -> T.Response { // T for any Thread
diff --git a/TalerWallet1/Views/Main/ErrorView.swift b/TalerWallet1/Views/Main/ErrorView.swift
@@ -1,26 +0,0 @@
-/*
- * This file is part of GNU Taler, ©2022-25 Taler Systems S.A.
- * See LICENSE.md
- */
-/**
- * @author Marc Stibane
- */
-import SwiftUI
-import SymLog
-
-struct ErrorView: View {
- private let symLog = SymLogV(0)
-
- let errortext: String?
-
- var body: some View {
-
- Text(errortext ?? "Couldn't load Wallet-Core!")
- }
-}
-
-struct ErrorView_Previews: PreviewProvider {
- static var previews: some View {
- ErrorView(errortext: EMPTYSTRING)
- }
-}
diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift
@@ -96,7 +96,8 @@ struct MainView: View {
let mainGroup = Group {
switch controller.backendState {
case .ready: mainContent
- case .error: ErrorView(errortext: nil) // TODO: show Error View
+ case .error: ErrorSheet(title: String(localized: ""),
+ copyable: true) {}
default: // show launch animation until either ready or error
LaunchAnimationView()
}
@@ -109,6 +110,7 @@ struct MainView: View {
let sheet = URLSheet(stack: stack.push(),
selectedBalance: $selectedBalance,
urlToOpen: $urlToOpen)
+ .id("onOpenURL")
Sheet(stack: stack.push(), sheetView: AnyView(sheet))
}
.sheet(isPresented: $showScanner,
diff --git a/TalerWallet1/Views/Sheets/QRSheet.swift b/TalerWallet1/Views/Sheets/QRSheet.swift
@@ -15,6 +15,7 @@ struct QRSheet: View {
let stack: CallStack
@Binding var selectedBalance: Balance?
+ @EnvironmentObject private var model: WalletModel
@State private var scannedCode: String?
@State private var urlToOpen: URL?
@@ -36,9 +37,8 @@ struct QRSheet: View {
let _ = symLog.vlog(scannedCode) // just to get the # to compare it with .onAppear & onDisappear
#endif
Group {
+ let errorAnnouncement = String(localized: "Error while scanning QR code", comment: "VoiceOver")
if scannedCode != nil {
-// let _ = symLog(scannedCode!) // TODO: logging
-
if let scannedURL = codeToURL(scannedCode!) {
let scheme = scannedURL.scheme
if scheme?.lowercased() == "taler" {
@@ -47,10 +47,18 @@ struct QRSheet: View {
urlToOpen: $urlToOpen)
} else {
// let _ = print(scannedURL) // TODO: error logging
- ErrorView(errortext: scannedURL.absoluteString)
+ ErrorSheet(title: String(localized: "Scanned QR is no talerURI"),
+ message: scannedURL.absoluteString,
+ copyable: true) {
+ dismissTop(stack.push())
+ }
}
} else {
- ErrorView(errortext: scannedCode)
+ ErrorSheet(title: String(localized: "Scanned QR is no URL"),
+ message: scannedCode,
+ copyable: true) {
+ dismissTop(stack.push())
+ }
}
} else {
CodeScannerView(codeTypes: [AVMetadataObject.ObjectType.qr], showViewfinder: true) { response in
@@ -63,8 +71,8 @@ struct QRSheet: View {
closingAnnouncement = String(localized: "QR code recognized", comment: "VoiceOver")
case .failure(let error):
// TODO: errorAlert
- ErrorView(errortext: error.localizedDescription)
- closingAnnouncement = String(localized: "Error while scanning QR code", comment: "VoiceOver")
+ model.setError(error)
+ closingAnnouncement = errorAnnouncement
}
announce(closingAnnouncement)
}
diff --git a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
@@ -298,7 +298,11 @@ struct TransactionSummaryV: View {
badge: CONFIRM_BANK)
} } } }
@unknown default:
- ErrorView(errortext: "Unknown withdrawal type"); // TODO: l10n
+ ErrorSheet(title: "Unknown withdrawal type", // should not happen, so no L10N
+ message: withdrawalDetails.type.rawValue,
+ copyable: true) {
+ dismissTop(stack.push())
+ }
} // switch
}
}