commit 5f8596d2d55ea615ad2def4b97f109c70438e045
parent cfa93217e17bcb31a0300d950bb78a2fde61746f
Author: Marc Stibane <marc@taler.net>
Date: Sat, 18 Apr 2026 12:00:09 +0200
fix haveProdBalance
Diffstat:
2 files changed, 27 insertions(+), 37 deletions(-)
diff --git a/TalerWallet1/Views/Balances/BalancesListView.swift b/TalerWallet1/Views/Balances/BalancesListView.swift
@@ -76,11 +76,8 @@ struct BalancesListView: View {
let count = controller.balances.count
Group {
List {
- if !controller.haveProdBalance {
- Section {
- ProdSectionView(stack: stack.push(), isEmpty: false, disabled: false)
- }
- .listRowSeparator(.hidden)
+ if !controller.haveProdBalance && !controller.defaultExchanges.isEmpty {
+ ProdSectionView(stack: stack.push(), isEmpty: false, disabled: false)
}
ForEach(Array(controller.balances.enumerated()), id: \.element) { index, balance in
BalancesSectionView(stack: stack.push("\(balance.scopeInfo.currency)"),
diff --git a/TalerWallet1/Views/Main/WalletEmptyView.swift b/TalerWallet1/Views/Main/WalletEmptyView.swift
@@ -24,18 +24,11 @@ struct ProdSectionView: View {
@AppStorage("developerMode") var developerMode: Bool = false
#endif
- @State private var defaultExchanges: [DefaultExchange] = []
@State private var selectedCurrency: Int = 0
- @MainActor
- private func viewDidLoad() async {
-// print("ProdSectionView.viewDidLoad")
- if let exchanges = try? await model.getDefaultExchanges() {
- withAnimation { defaultExchanges = exchanges }
- }
- }
-
var body: some View {
+ let defaultExchanges = controller.defaultExchanges
+ let count = defaultExchanges.count
Section {
if isEmpty {
Text("Welcome to Taler Wallet!")
@@ -55,30 +48,31 @@ struct ProdSectionView: View {
.talerFont(.body)
#endif
- if !defaultExchanges.isEmpty {
#if !TALER_WALLET
- if developerMode {
- if defaultExchanges.count > 1 {
- CurrencyPicker(stack: stack.push(), value: $selectedCurrency,
- exchanges: defaultExchanges) { index in
- selectedCurrency = index
- }
+ if developerMode {
+ if defaultExchanges.count > 1 {
+ CurrencyPicker(stack: stack.push(), value: $selectedCurrency,
+ exchanges: defaultExchanges) { index in
+ selectedCurrency = index
}
}
+ }
#endif
- let defaultExchange = defaultExchanges[selectedCurrency]
- let currency = defaultExchange.currency
- let currencySpec = defaultExchange.currencySpec
- let name = currencySpec.name
- let title = String(localized: "LinkTitle_Withdraw", defaultValue: "Withdraw \(currency)")
- Button(title) {
- if let talerUri = URL(string: defaultExchange.talerUri) {
- controller.talerURI = talerUri
- }
+ let defaultExchange = defaultExchanges[selectedCurrency < count ? selectedCurrency : 0]
+ let currency = defaultExchange.currency
+ let currencySpec = defaultExchange.currencySpec
+ let name = currencySpec.name
+ let title = String(localized: "LinkTitle_Withdraw", defaultValue: "Withdraw \(currency)")
+ Button(title) {
+ if let talerUri = URL(string: defaultExchange.talerUri) {
+ controller.talerURI = talerUri
}
- .buttonStyle(TalerButtonStyle(type: .prominent, narrow: false, disabled: disabled, aligned: .center))
- .padding(.bottom)
}
+ .buttonStyle(TalerButtonStyle(type: isEmpty ? .prominent : .bordered,
+ narrow: false,
+ disabled: disabled,
+ aligned: .center))
+ .padding(.bottom)
} header: {
if isEmpty {
let firstHeader = EMPTYSTRING
@@ -92,10 +86,6 @@ struct ProdSectionView: View {
}
.listRowSeparator(.hidden)
// .listSectionSpacing(.compact) iOS 17
- .task {
- setVoice(to: nil)
- await viewDidLoad()
- }
}
}
@@ -106,6 +96,7 @@ struct WalletEmptyView: View {
private let symLog = SymLogV(0)
let stack: CallStack
+ @EnvironmentObject private var controller: Controller
@EnvironmentObject private var model: WalletModel
@AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
@State private var withDrawStarted = false
@@ -113,7 +104,9 @@ struct WalletEmptyView: View {
var body: some View {
let list = List {
- ProdSectionView(stack: stack.push(), isEmpty: true, disabled: withDrawStarted)
+ if !controller.defaultExchanges.isEmpty {
+ ProdSectionView(stack: stack.push(), isEmpty: true, disabled: withDrawStarted)
+ }
#if GNU_TALER
Text("If you don't have a Swiss bank account, you can simply try out the demo…")
.talerFont(.body)