taler-ios

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

commit 84bd2b8a419db56c09281227c6974f09e375bbfb
parent 670083e3c71390f9c446e9b26d564d14839fed00
Author: Marc Stibane <marc@taler.net>
Date:   Wed, 12 Aug 2026 04:24:45 +0200

cleanup stage

Diffstat:
MTalerWallet1/Controllers/Controller.swift | 8+++++---
MTalerWallet1/Controllers/TalerWallet1App.swift | 3+--
MTalerWallet1/Model/Model+Exchange.swift | 16++++++----------
MTalerWallet1/Views/HelperViews/ScopePicker.swift | 42++++++++++++++++--------------------------
4 files changed, 28 insertions(+), 41 deletions(-)

diff --git a/TalerWallet1/Controllers/Controller.swift b/TalerWallet1/Controllers/Controller.swift @@ -536,7 +536,7 @@ class Controller: ObservableObject { } // MARK: - @MainActor - func initWalletCore(_ model: WalletModel, stage: Bool, setTesting: Bool, delay: TimeInterval) + func initWalletCore(_ model: WalletModel, setTesting: Bool, delay: TimeInterval) async throws { if backendState == .instantiated { backendState = .initing @@ -559,9 +559,10 @@ class Controller: ObservableObject { try await model.devExperimentT( "taler://dev-experiment/demo-shortcuts?val=KUDOS:4,KUDOS:8,KUDOS:16,KUDOS:32") } - defaultExchanges = await model.getDefaultExchanges(stage: stage) + defaultExchanges = await model.getDefaultExchanges() +#if GNU_TALER if defaultExchanges.count == 1 { - if stage, let talerOps = defaultExchanges.first { + if let talerOps = defaultExchanges.first { let stageURI = "taler://withdraw-exchange/exchange.stage.taler-ops.ch" if talerOps.talerUri != stageURI { let stageExc = DefaultExchange(talerUri: stageURI, @@ -572,6 +573,7 @@ class Controller: ObservableObject { } } } +#endif DispatchQueue.main.asyncAfter(deadline: .now() + delay) { self.backendState = .ready // dismiss the launch animation } diff --git a/TalerWallet1/Controllers/TalerWallet1App.swift b/TalerWallet1/Controllers/TalerWallet1App.swift @@ -126,8 +126,7 @@ struct TalerWallet1App: App { let testing = false let delay: TimeInterval = 2.25 #endif - try! await controller.initWalletCore(model, stage: developerMode, - setTesting: testing, delay: delay) // will (and should) crash on failure + try! await controller.initWalletCore(model, setTesting: testing, delay: delay) // will (and should) crash on failure } if #available(iOS 16.4, *) { return WindowGroup { diff --git a/TalerWallet1/Model/Model+Exchange.swift b/TalerWallet1/Model/Model+Exchange.swift @@ -129,15 +129,15 @@ struct Exchange: Codable, Hashable, Identifiable { } } // MARK: - -struct DefaultExchange: Codable { +struct DefaultExchange: Codable, Hashable { var talerUri: String // taler://withdraw-exchange/exchange.taler-ops.ch/ var currency: String // CHF var currencySpec: CurrencySpecification // .name = "Swiss Francs"... alt_unit_names":{"0":"Fr.","-2":"Rp."} // var restrictions: [String] // ["Swiss bank accounts only"] } + extension DefaultExchange: Identifiable { var id: String { talerUri } - } // MARK: - /// A request to list exchanges names for a currency @@ -161,12 +161,8 @@ fileprivate struct ListExchanges: WalletBackendFormattedRequest { fileprivate struct DefaultExchanges: WalletBackendFormattedRequest { var operation: String { "getDefaultExchanges" } func args() -> Args { Args() } -// func args() -> Args { Args(stage: stage) } - var stage: Bool - struct Args: Encodable { -// var stage: Bool - } + struct Args: Encodable {} struct Response: Decodable { // list of known exchanges var defaultExchanges: [DefaultExchange] @@ -292,10 +288,10 @@ extension WalletModel { } /// ask wallet-core for its list of default exchanges ==> currently only taler-ops.ch - nonisolated func getDefaultExchanges(stage: Bool, viewHandles: Bool = false) - async -> [DefaultExchange] { // M for MainActor + nonisolated func getDefaultExchanges(viewHandles: Bool = false) + async -> [DefaultExchange] { // M for MainActor do { - let request = DefaultExchanges(stage: stage) + let request = DefaultExchanges() let response = try await sendRequest(request, viewHandles: viewHandles) return response.defaultExchanges } catch { diff --git a/TalerWallet1/Views/HelperViews/ScopePicker.swift b/TalerWallet1/Views/HelperViews/ScopePicker.swift @@ -32,36 +32,26 @@ struct CurrencyPicker: View { @State private var selected = 0 - func base(_ index: Int, _ count: Int) -> String { - if index != 0 && index == count - 1 { - return " (stage)" - } - return " (prod)" - } - var body: some View { -#if PRINT_CHANGES - let _ = Self._printChanges() -#endif - let count = exchanges.count - if (count > 0) { // TODO: 1? - Picker(EMPTYSTRING, selection: $selected) { - ForEach(0..<count, id: \.self) { index in - let exchange = exchanges[index] - Text(exchange.currencySpec.name + base(index, count)) + Picker(EMPTYSTRING, selection: $selected) { + ForEachWithIndex(data: exchanges) { index, exchange in + if exchange.talerUri.contains("exchange.stage.taler-ops.ch") { + Text(exchange.currencySpec.name + " (stage)") + .tag(index) + } else { + Text(exchange.currencySpec.name) .tag(index) } } - .talerFont(.title3) - .task() { - // FIXME: check balance for non-zero and disable-peer-payments - withAnimation { selected = value } - } - .onChange(of: selected) { newValue in - action(newValue) - } - - } // TODO: else show static text? + } + .talerFont(.title3) + .task() { + // FIXME: check balance for non-zero and disable-peer-payments + withAnimation { selected = value } + } + .onChange(of: selected) { newValue in + action(newValue) + } } } struct ScopePicker: View {