taler-ios

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

commit 2720e310a73b3d6fcf09a2af79e4fb29c3325639
parent 32075fd1a6c41ba9d69495f6baeeda23cf1e0992
Author: Marc Stibane <marc@taler.net>
Date:   Mon, 31 Aug 2026 11:29:05 +0200

insufficient

Diffstat:
MTalerCommon/HelperViews/CurrencyInputView.swift | 5+++--
MTalerWallet1/Views/Actions/Banking/DepositAmountView.swift | 1+
MTalerWallet1/Views/Actions/Banking/ManualWithdraw.swift | 1+
MTalerWallet1/Views/Actions/Peer2peer/P2PSubjectV.swift | 6++++--
MTalerWallet1/Views/Actions/Peer2peer/SendAmountView.swift | 45++++++++++++++++++++++++---------------------
MTalerWallet1/Views/HelperViews/AmountInputV.swift | 10+++++-----
6 files changed, 38 insertions(+), 30 deletions(-)

diff --git a/TalerCommon/HelperViews/CurrencyInputView.swift b/TalerCommon/HelperViews/CurrencyInputView.swift @@ -61,6 +61,7 @@ struct CurrencyInputView: View { @Binding var amount: Amount // the `value´ let amountLastUsed: Amount let available: Amount? + let insufficient: Bool let title: String? let a11yTitle: String let shortcutAction: ((_ amount: Amount) -> Void)? @@ -130,7 +131,7 @@ struct CurrencyInputView: View { func heading() -> (String, String)? { if let title { - return (title, title) + return (title, a11yTitle) } if let available { let formatted = available.formatted(scope, isNegative: false) @@ -161,11 +162,11 @@ struct CurrencyInputView: View { .padding(.top) .frame(maxWidth: .infinity, alignment: title != nil ? .leading : .trailing) .talerFont(.title2) + .foregroundColor(insufficient ? WalletColors().errorColor : .primary) .accessibilityLabel(heading.1) .padding(.bottom, -6) } currencyField - .accessibilityLabel(a11yTitle) .frame(maxWidth: .infinity, alignment: .trailing) .foregroundColor(WalletColors().fieldForeground) // text color // .background(WalletColors().fieldBackground) // problem: white corners diff --git a/TalerWallet1/Views/Actions/Banking/DepositAmountView.swift b/TalerWallet1/Views/Actions/Banking/DepositAmountView.swift @@ -120,6 +120,7 @@ struct DepositAmountView: View { amount: $amountToTransfer, amountLastUsed: amountLastUsed, available: amountAvailable, // enable shortcuts if available >= value + insufficient: false, // TODO: insufficient title: amountLabel, a11yTitle: a11yLabel, shortcutAction: nil) diff --git a/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift b/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift @@ -261,6 +261,7 @@ struct ManualWithdrawContent: View { amount: $amountToTransfer, amountLastUsed: amountLastUsed, available: nil, // enable shortcuts always + insufficient: false, // TODO: insufficient title: amountLabel, a11yTitle: a11yLabel, shortcutAction: nil) diff --git a/TalerWallet1/Views/Actions/Peer2peer/P2PSubjectV.swift b/TalerWallet1/Views/Actions/Peer2peer/P2PSubjectV.swift @@ -12,8 +12,10 @@ import SymLog func p2pFee(ppCheck: CheckPeerPushDebitResponse) -> Amount? { do { // Outgoing: fee = effective - raw - let fee = try ppCheck.amountEffective - ppCheck.amountRaw - return fee + if let effective = ppCheck.amountEffective { + let fee = try effective - ppCheck.amountRaw + return fee + } } catch {} return nil } diff --git a/TalerWallet1/Views/Actions/Peer2peer/SendAmountView.swift b/TalerWallet1/Views/Actions/Peer2peer/SendAmountView.swift @@ -54,10 +54,12 @@ struct SendAmountView: View { feeStr.isEmpty ? EMPTYSTRING : String(localized: "+ \(feeStr) fee") } - private func fee(raw: Amount, effective: Amount) -> Amount? { + private func fee(raw: Amount, effective: Amount?) -> Amount? { do { // Outgoing: fee = effective - raw - let fee = try effective - raw - return fee + if let effective { + let fee = try effective - raw + return fee + } } catch {} return nil } @@ -84,21 +86,22 @@ struct SendAmountView: View { do { let ppCheck = try await model.checkPeerPushDebit(amount, scope: balance.scopeInfo, viewHandles: true) let raw = ppCheck.amountRaw - let effective = ppCheck.amountEffective - if let fee = fee(raw: raw, effective: effective) { - feeString = fee.formatted(balance.scopeInfo, isNegative: false) - symLog.log("Fee = \(feeString.0)") - let insufficient = (try? effective > amountAvailable) ?? true + if let effective = ppCheck.amountEffective { + if let fee = fee(raw: raw, effective: effective) { + feeString = fee.formatted(balance.scopeInfo, isNegative: false) + symLog.log("Fee = \(feeString.0)") + let insufficient = (try? effective > amountAvailable) ?? true - peerPushCheck = ppCheck - let feeLabel = (feeLabel(feeString.0), feeLabel(feeString.1)) -// announce("\(amountVoiceOver), \(feeLabel)") - return ComputeFeeResult(insufficient: insufficient, - feeAmount: fee, - feeStr: feeLabel, - numCoins: nil) - } else { - peerPushCheck = nil + peerPushCheck = ppCheck + let feeLabel = (feeLabel(feeString.0), feeLabel(feeString.1)) +// announce("\(amountVoiceOver), \(feeLabel)") + return ComputeFeeResult(insufficient: insufficient, + feeAmount: fee, + feeStr: feeLabel, + numCoins: nil) + } else { + peerPushCheck = nil + } } } catch { // handle cancel, errors @@ -141,7 +144,7 @@ struct SendAmountView: View { let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear #endif Group { - let availableStr = amountAvailable.formatted(balance.scopeInfo, isNegative: false) +// let availableStr = amountAvailable.formatted(balance.scopeInfo, isNegative: false) // let availableA11y = amountAvailable.formatted(currencyInfo, isNegative: false, useISO: true, a11y: ".") // let amountVoiceOver = amountToTransfer.formatted(currencyInfo, isNegative: false) // let insufficientLabel2 = String(localized: "but you only have \(availableStr) to send.") @@ -172,12 +175,12 @@ struct SendAmountView: View { NavLink($buttonSelected) { inputDestination } NavLink($shortcutSelected) { shortcutDestination } } - let a11yLabel = String(localized: "Amount to send:", comment: "a11y, no abbreviations") +// let a11yLabel = String(localized: "Amount to send:", comment: "a11y, no abbreviations") AmountInputV(stack: stack.push(), scope: balance.scopeInfo, amountAvailable: $amountAvailable, - amountLabel: nil, // will use "Available for transfer: xxx", trailing - a11yLabel: a11yLabel, + amountLabel: nil, // will use "Available for transfer: xxx", trailing + a11yLabel: EMPTYSTRING, // a11yLabel, amountToTransfer: $amountToTransfer, amountLastUsed: amountLastUsed, wireFee: nil, diff --git a/TalerWallet1/Views/HelperViews/AmountInputV.swift b/TalerWallet1/Views/HelperViews/AmountInputV.swift @@ -98,25 +98,25 @@ struct AmountInputV: View { var body: some View { let currency = amountToTransfer.currencyStr + let coinData = CoinData(coins: numCoins, fee: feeAmount) + let flags = checkAvailable(coinData) + let hint = String(localized: "enabled when amount is non-zero", comment: "a11y") ScrollView { VStack(alignment: .trailing) { CurrencyInputView(scope: scope, amount: $amountToTransfer, amountLastUsed: amountLastUsed, available: isIncoming ? nil : amountAvailable, + insufficient: flags.insufficient, title: amountLabel, a11yTitle: a11yLabel, shortcutAction: shortcutAction) // .accessibility(sortPriority: 2) - - let coinData = CoinData(coins: numCoins, fee: feeAmount) QuiteSomeCoins(scope: scope, coinData: coinData, shouldShowFee: true, // TODO: set to false if we never charge withdrawal fees feeIsNegative: isIncoming) - let flags = checkAvailable(coinData) - let hint = String(localized: "enabled when amount is non-zero", comment: "a11y") Button("Next") { buttonAction() } - .buttonStyle(TalerButtonStyle(type: .prominent, disabled: flags.disabled)) + .buttonStyle(TalerButtonStyle(type: .prominent, )) .disabled(flags.disabled) .accessibilityHint(flags.disabled ? hint : EMPTYSTRING) .padding(.bottom, 333)