commit 9d5526f246f406a446fd80af53a198da7cc0ea77
parent 907adfcb4df77a4d5bd7d649b3694a6e11089918
Author: Marc Stibane <marc@taler.net>
Date: Sun, 22 Nov 2026 09:12:35 +0100
disable balances with exchangeLegacyKeys
Diffstat:
2 files changed, 31 insertions(+), 35 deletions(-)
diff --git a/TalerWallet1/Backend/WalletBackendRequest.swift b/TalerWallet1/Backend/WalletBackendRequest.swift
@@ -49,6 +49,12 @@ struct ScopeInfo: Codable, Hashable {
var noFees: Bool? // only for "global". Regional have this field per Exchange
var url: String? // only for "exchange", "auditor" and "exchange-legacy-keys"
var masterPub: String? // only for "exchange-legacy-keys": the superseded key
+ var isValid: Bool {
+ switch type {
+ case .global, .exchange, .auditor: return true
+ default: return false
+ }
+ }
public static func zero() -> ScopeInfo {
ScopeInfo(type: .unknown, currency: UNKNOWN)
diff --git a/TalerWallet1/Views/HelperViews/ScopePicker.swift b/TalerWallet1/Views/HelperViews/ScopePicker.swift
@@ -106,11 +106,12 @@ struct ScopePicker: View {
#endif
let count = controller.balances.count
if let balance = safeBalance(controller.balances, selected) {
- let currencyInfo = controller.info(for: balance.scopeInfo, controller.currencyTicker)
- let available = balance.available
+ let scope = balance.scopeInfo
+ let currencyInfo = controller.info(for: scope, controller.currencyTicker)
+ let available = scope.isValid ? balance.available : Amount.zero(currency: scope.currency)
let availableA11y = available.formatted(currencyInfo, isNegative: false,
useISO: true, a11yDecSep: ".")
- let url = balance.scopeInfo.url?.trimURL ?? EMPTYSTRING
+ let url = scope.url?.trimURL ?? EMPTYSTRING
// let a11yLabel = url + ", " + availableA11y
let chooseHint = String(localized: "Choose the payment service:", comment: "a11y")
let disabled = (count == 1)
@@ -120,29 +121,9 @@ struct ScopePicker: View {
.accessibilityHidden(true)
.foregroundColor(disabled ? .secondary : .primary)
- if #available(iOS 16.4, *) {
- ScopeDropDown(selection: $selected,
- onlyNonZero: onlyNonZero,
- disabled: disabled)
- } else {
- Picker(EMPTYSTRING, selection: $selected) {
- ForEach(0..<count, id: \.self) { index in
- let balance = controller.balances[index]
- let currencyInfo = controller.info(for: balance.scopeInfo, controller.currencyTicker)
- let pickerRow = pickerRow(balance, currencyInfo)
- Text(pickerRow.0)
- .accessibilityLabel(pickerRow.1)
- .tag(index)
-// .selectionDisabled(balance.available.isZero) needs iOS 17
- }
- }
- .disabled(disabled)
- .frame(maxWidth: .infinity)
-// .border(.red) // debugging
- .pickerStyle(.menu)
-// .accessibilityLabel(a11yLabel)
- .labelsHidden() // be sure to use valid labels for a11y
- }
+ ScopeDropDown(selection: $selected,
+ onlyNonZero: onlyNonZero,
+ disabled: disabled)
}
.talerFont(.picker)
// .accessibilityLabel(a11yLabel)
@@ -165,7 +146,6 @@ struct ScopePicker: View {
}
}
// MARK: -
-@available(iOS 16.4, *)
struct ScopeDropDown: View {
@Binding var selection: Int
let onlyNonZero: Bool
@@ -186,10 +166,13 @@ struct ScopeDropDown: View {
@ViewBuilder
func dropDownRow(_ balance: Balance, _ currencyInfo: CurrencyInfo, _ first: Bool = false) -> some View {
+ let scope = balance.scopeInfo
let urlOrCurrency = urlOrCurrency(balance)
let text = Text(urlOrCurrency)
let formatted = formattedAmount(balance, currencyInfo)
- let amount = Text(formatted.0.nbs)
+ let amountString = Text(formatted.0.nbs)
+ .strikethrough(!scope.isValid, color: WalletColors().attention)
+
if first {
let a11yLabel = String(localized: "via \(urlOrCurrency)", comment: "a11y")
text
@@ -199,22 +182,28 @@ struct ScopeDropDown: View {
let hLayout = HStack(alignment: .firstTextBaseline) {
text
Spacer()
- amount
+ amountString
}.padding(.vertical, 4)
let vLayout = VStack(alignment: .leading) {
text
HStack {
Spacer()
- amount
+ amountString
Spacer()
}
}
- ViewThatFits(in: .horizontal) {
- hLayout
+ if #available(iOS 16.4, *) {
+ ViewThatFits(in: .horizontal) {
+ hLayout
+ vLayout
+ }
+ .accessibilityElement(children: .combine)
+ .accessibilityLabel(a11yLabel)
+ } else {
vLayout
+ .accessibilityElement(children: .combine)
+ .accessibilityLabel(a11yLabel)
}
- .accessibilityElement(children: .combine)
- .accessibilityLabel(a11yLabel)
}
}
@@ -229,7 +218,8 @@ struct ScopeDropDown: View {
let theList = LazyVStack(spacing: 0) {
ForEach(0..<otherBalances.count, id: \.self) { index in
let balance = otherBalances[index]
- let disablePeerPayments = balance.disablePeerPayments ?? false
+ let scope = balance.scopeInfo
+ let disablePeerPayments = scope.isValid ? (balance.disablePeerPayments ?? false) : true
let rowDisabled = disablePeerPayments || (onlyNonZero ? balance.available.isZero : false)
Button(action: {
withAnimation {