taler-ios

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

commit 6e39cf5dc877112ecf209443720d65c2249b80c9
parent 7fadf6fb30ab53d59141434bbd06f62070a050a7
Author: Marc Stibane <marc@taler.net>
Date:   Fri, 10 Jul 2026 07:20:44 +0200

fix addExchange

Diffstat:
MTalerWallet1/Controllers/Controller.swift | 2+-
MTalerWallet1/Controllers/PublicConstants.swift | 4++++
MTalerWallet1/Views/Main/MainView.swift | 5+++++
MTalerWallet1/Views/Settings/Exchange/ExchangeListView.swift | 22++++++++++++++--------
MTalerWallet1/Views/Settings/SettingsView.swift | 8+++-----
MTalerWallet1/Views/Sheets/URLSheet.swift | 5+++--
6 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/TalerWallet1/Controllers/Controller.swift b/TalerWallet1/Controllers/Controller.swift @@ -93,7 +93,7 @@ enum UrlCommand: String, Codable { case .unknown: .dummy case .withdraw: .withdrawal case .withdrawExchange: .withdrawal - case .addExchange: .withdrawal + case .addExchange: .dummy case .pay: .payment case .payPull: .scanPullDebit case .payPush: .scanPushCredit diff --git a/TalerWallet1/Controllers/PublicConstants.swift b/TalerWallet1/Controllers/PublicConstants.swift @@ -185,6 +185,10 @@ public let TESTCURRENCY = "TESTKUDOS" //public let LONGCURRENCY = "gold-pressed Latinum" // 20 characters, with dash and space public let LONGCURRENCY = "GOLDLATINUM" // 11 characters, no dash, no space +// MARK: - Titles + +public let TITLE_EXCHANGES = String(localized: "TitleExchanges", defaultValue: "Payment Services") + // MARK: - Keys used in JSON public let PLAINTEXT = "text/plain" diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift @@ -237,12 +237,14 @@ struct MainView: View { actionSheet() case .scanner: qrSheet() + .environmentObject(tabBarModel) case .url(let url): let uSheet = URLSheet(stack.push(), selectedBalance: selectedBalance, sheetURL: url) .id("onOpenURL") Sheet(stack: stack.push(), sheetView: AnyView(uSheet)) + .environmentObject(tabBarModel) } } .sheet(isPresented: $showUrlSheet, @@ -252,15 +254,18 @@ struct MainView: View { urlToOpen: $urlToOpen) .id("onOpenURL") Sheet(stack: stack.push(), sheetView: AnyView(sheet)) + .environmentObject(tabBarModel) } // UrlSheet .sheet(isPresented: $showScanner, onDismiss: dismissSheet) { qrSheet() + .environmentObject(tabBarModel) } // QR Scanner .sheet(isPresented: $showActionSheet, onDismiss: dismissActionSheet ) { actionSheet() + .environmentObject(tabBarModel) } // ActionSheet } // VStack { networkUnavailable + mainGroup } #if OIM diff --git a/TalerWallet1/Views/Settings/Exchange/ExchangeListView.swift b/TalerWallet1/Views/Settings/Exchange/ExchangeListView.swift @@ -29,7 +29,8 @@ func addExchange(_ exchange: String, model: WalletModel) -> Void { struct ExchangeListView: View { private let symLog = SymLogV(0) let stack: CallStack - let navTitle: String + @Binding var url: URL? + @EnvironmentObject private var model: WalletModel @EnvironmentObject private var controller: Controller #if DEBUG @@ -49,11 +50,18 @@ struct ExchangeListView: View { let addTitleStr = String(localized: "Add payment service", comment: "title of the addExchange alert") let addButtonStr = String(localized: "Add", comment: "button in the addExchange alert") let enterURL = String(localized: "Enter the URL") + let listView = ExchangeListCommonV(symLog: symLog, stack: stack.push(), developerMode: developerMode) + .navigationTitle(TITLE_EXCHANGES) + .navigationBarItems(trailing: plusButton) + .task { + if let newUrl = url { + newExchange = newUrl.absoluteString + showAlert = true + url = nil + } + } if #available(iOS 16.4, *) { - ExchangeListCommonV(symLog: symLog, stack: stack.push(), developerMode: developerMode) - .navigationTitle(navTitle) - .navigationBarItems(trailing: plusButton) - .alert(addTitleStr, isPresented: $showAlert) { + listView.alert(addTitleStr, isPresented: $showAlert) { TextField("Address of the payment service", text: $newExchange) .accessibilityLabel(enterURL) // .textFieldStyle(.roundedBorder) Yikes: when adding style the alert will stop showing the textfield! Don't do this. @@ -66,9 +74,7 @@ struct ExchangeListView: View { .accessibilityHidden(true) } } else { // iOS 15 cannot have a textfield in an alert, so we must - ExchangeListCommonV(symLog: symLog, stack: stack.push(), developerMode: developerMode) - .navigationTitle(navTitle) - .navigationBarItems(trailing: plusButton) + listView .textFieldAlert(isPresented: $showAlert, title: addTitleStr, doneText: addButtonStr, diff --git a/TalerWallet1/Views/Settings/SettingsView.swift b/TalerWallet1/Views/Settings/SettingsView.swift @@ -125,15 +125,13 @@ struct SettingsView: View { SettingsItem(name: aboutStr, id1: "about", imageName: TALER_LOGO) {} } - let exchangesTitle = String(localized: "TitleExchanges", defaultValue: "Payment Services") - let exchangesDest = ExchangeListView(stack: stack.push(exchangesTitle), - navTitle: exchangesTitle) NavigationLink { // whole row like in a tableView - exchangesDest + ExchangeListView(stack: stack.push(), url: .constant(nil)) } label: { - SettingsItem(name: exchangesTitle, id1: "exchanges", imageName: EXCHANGE_LOGO, + SettingsItem(name: TITLE_EXCHANGES, id1: "exchanges", imageName: EXCHANGE_LOGO, description: String(localized: "Manage payment services")) {} } + let bankAccountsTitle = String(localized: "TitleBankAccounts", defaultValue: "Bank Accounts") let bankAccountsDest = BankListView(stack: stack.push(bankAccountsTitle), navTitle: bankAccountsTitle) diff --git a/TalerWallet1/Views/Sheets/URLSheet.swift b/TalerWallet1/Views/Sheets/URLSheet.swift @@ -55,8 +55,9 @@ struct URLSheet: View { #endif if let urlCommand, let passedURL { switch urlCommand { - case .addExchange, // TODO: just check the ToS - .withdraw: + case .addExchange: // TODO: just check the ToS + ExchangeListView(stack: stack.push(), url: $passedURL) + case .withdraw: WithdrawURIView(stack: stack.push(), url: passedURL) case .withdrawExchange: WithdrawExchangeV(stack: stack.push(),