taler-ios

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

commit 6e46ea3807758eb9a7d062e12fc851e8413a833f
parent 5e6109af466353c5257de3e6b8b8bd00e3d699c4
Author: Marc Stibane <marc@taler.net>
Date:   Fri,  7 Aug 2026 10:31:24 +0200

improve ErrorView

Diffstat:
MTalerWallet1/Model/Model+Withdraw.swift | 2+-
MTalerWallet1/Model/Transaction.swift | 4++--
MTalerWallet1/Views/Actions/Banking/ManualWithdraw.swift | 6++----
MTalerWallet1/Views/Main/ErrorView.swift | 14+++++++++-----
MTalerWallet1/Views/Main/MainView.swift | 9++++++---
MTalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawUriScan.swift | 5+----
MTalerWallet1/Views/Transactions/TransactionSummaryList.swift | 6++----
7 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/TalerWallet1/Model/Model+Withdraw.swift b/TalerWallet1/Model/Model+Withdraw.swift @@ -45,7 +45,7 @@ struct TransferOption: Codable, Hashable { var qrReferenceNumber: String? // only if type == chQrBill } -struct ExchangeAccountDetails: Decodable, Hashable { +struct ExchangeAccountDetails: Codable, Hashable { var status: String // "OK" or "error" - then conversionError var paytoUri: String var transferAmount: Amount? // only if "OK" diff --git a/TalerWallet1/Model/Transaction.swift b/TalerWallet1/Model/Transaction.swift @@ -439,8 +439,8 @@ struct TransactionCommon: Decodable, Sendable { } } // MARK: - Withdrawal -struct WithdrawalDetails: Decodable { - enum WithdrawalType: String, Decodable { +struct WithdrawalDetails: Codable { + enum WithdrawalType: String, Codable { case manual = "manual-transfer" case bankIntegrated = "taler-bank-integration-api" } diff --git a/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift b/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift @@ -93,10 +93,8 @@ struct ManualWithdraw: View { amountToTransfer: $amountToTransfer, exchange: exchange) } else { // should never happen, we either have an exchange or a balance - let title = "ManualWithdrawContent: Cannot determine scope" // should not happen, so no L10N - ErrorView(stack.push("ManualWithdraw"), title: title, message: nil, copyable: true) { - dismissTop(stack.push()) - } + ErrorView(stack.push(), title: "ManualWithdraw", + message: "ManualWithdrawContent: Cannot determine scope", copyable: true) } } // ScrollView .navigationTitle(navTitle) diff --git a/TalerWallet1/Views/Main/ErrorView.swift b/TalerWallet1/Views/Main/ErrorView.swift @@ -72,10 +72,10 @@ struct ErrorView: View { var requestUrl: String? = nil var copyable: Bool - var onDismiss: () -> Void + var onDismiss: (() -> Void)? init(_ stack: CallStack, title: String, message: String? = nil, - requestUrl: String? = nil, copyable: Bool, onDismiss: @escaping () -> Void) { + requestUrl: String? = nil, copyable: Bool = false, onDismiss: (() -> Void)? = nil) { self.stack = stack self.title = title self.message = message @@ -84,7 +84,7 @@ struct ErrorView: View { self.onDismiss = onDismiss } - init(_ stack: CallStack, error: Error, devMode: Bool, onDismiss: @escaping () -> Void) { + init(_ stack: CallStack, error: Error, devMode: Bool, onDismiss: (() -> Void)? = nil) { let internetError = String(localized: "Network problem") let internetMessage = String(localized: "Please check your internet connection and try again.") let walletCoreError = String(localized: "Internal core error") @@ -134,7 +134,7 @@ struct ErrorView: View { } } - init(_ stack: CallStack, data: ErrorData, devMode: Bool, onDismiss: @escaping () -> Void) { + init(_ stack: CallStack, data: ErrorData, devMode: Bool, onDismiss: (() -> Void)? = nil) { switch data { case .message(let title, let message): self.init(stack, title: title, message: message, copyable: false, onDismiss: onDismiss) @@ -184,7 +184,11 @@ struct ErrorView: View { .padding() .safeAreaInset(edge: .bottom) { Button("OK", role: .cancel) { - onDismiss() + if let onDismiss { + onDismiss() + } else { + dismissTop(stack.push()) + } } .buttonStyle(TalerButtonStyle(type: .bordered)) .padding(.bottom) diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift @@ -199,9 +199,12 @@ struct MainView: View { // show launch animation until either ready or error switch controller.backendState { case .ready: mainContent - case .error(let error): ErrorView(stack.push("mainGroup"), - title: EMPTYSTRING, // TODO: String(localized: ""), - copyable: true) {} + case .error(let error): + ErrorView(stack.push("mainGroup"), + title: "Launch error", // TODO: String(localized: "") + message: error.localizedDescription, + copyable: true + ) {} default: LaunchAnimationView() } }.animation(.linear(duration: LAUNCHDURATION), value: controller.backendState) diff --git a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawUriScan.swift b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawUriScan.swift @@ -217,10 +217,7 @@ struct WithdrawUriScan: View { ErrorView(stack.push(), title: String(localized: "Error loading payment service details:"), message: message, - copyable: true - ) { - dismissTop(stack.push()) - } + copyable: true) } else { // no details or no exchange #if DEBUG let message = url.host diff --git a/TalerWallet1/Views/Transactions/TransactionSummaryList.swift b/TalerWallet1/Views/Transactions/TransactionSummaryList.swift @@ -425,10 +425,8 @@ struct TransactionSummaryList: View { @unknown default: ErrorView(stack.push(), title: "Unknown withdrawal type", // should not happen, so no L10N - message: withdrawalDetails.type.rawValue, - copyable: true) { - dismissTop(stack.push()) - } + message: withdrawalDetails.toJSON(), + copyable: true) } // switch } }