taler-ios

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

commit 60521c141021f3ab549951e8a22e62daf1396f80
parent 158edf1535d92e7ed17875bc360aca4143f849d5
Author: Marc Stibane <marc@taler.net>
Date:   Sat, 12 Apr 2025 13:14:03 +0200

localizedCause

Diffstat:
MTalerWallet1/Model/WalletModel.swift | 26++++++++++++++++++++++++++
MTalerWallet1/Views/Sheets/Payment/PaymentView.swift | 21+++------------------
2 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/TalerWallet1/Model/WalletModel.swift b/TalerWallet1/Model/WalletModel.swift @@ -30,6 +30,32 @@ enum InsufficientBalanceHint: String, Codable { /// Even though the balance looks sufficient for the instructed amount, /// the fees can be covered by neither the merchant nor the remaining wallet balance case feesNotCovered = "fees-not-covered" + + func localizedCause(_ currency: String) -> String { + switch self { + case .merchantAcceptInsufficient: + String(localized: "payment_balance_insufficient_hint_merchant_accept_insufficient", + defaultValue: "Merchant doesn't accept money from one or more providers in this wallet") + case .merchantDepositInsufficient: + String(localized: "payment_balance_insufficient_hint_merchant_deposit_insufficient", + defaultValue: "Merchant doesn't accept the wire method of the provider, this likely means it is misconfigured") + case .ageRestricted: + String(localized: "payment_balance_insufficient_hint_age_restricted", + defaultValue: "Purchase not possible due to age restriction") + case .walletBalanceMaterialInsufficient: + String(localized: "payment_balance_insufficient_hint_wallet_balance_material_insufficient", + defaultValue: "Some of the coins needed for this purchase are currently unavailable") + case .walletBalanceAvailableInsufficient: + String(localized: "payment_balance_insufficient_hint_fees_not_covered", + defaultValue: "You don't have enough \(currency).") + case .exchangeMissingGlobalFees: + String(localized: "payment_balance_insufficient_hint_exchange_missing_global_fees", + defaultValue: "Provider is missing the global fee configuration, this likely means it is misconfigured") + case .feesNotCovered: + String(localized: "payment_balance_insufficient_hint_fees_not_covered", + defaultValue: "Not enough funds to pay the provider fees not covered by the merchant") + } + } } struct InsufficientBalanceDetailsPerExchange: Codable, Hashable { diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift @@ -207,24 +207,9 @@ struct PaymentView: View, Sendable { products: terms.products) // TODO: payment: popup with all possible exchanges, check fees } else if let balanceDetails = preparePayResult.balanceDetails { // Insufficient - Group { - switch balanceDetails.causeHint { - case .merchantAcceptInsufficient: - Text("Merchant doesn't accept money from one or more providers in this wallet") - case .merchantDepositInsufficient: - Text("Merchant doesn't accept the wire method of the provider, this likely means it is misconfigured") - case .ageRestricted: - Text("Purchase not possible due to age restriction") - case .walletBalanceMaterialInsufficient: - Text("Some of the coins needed for this purchase are currently unavailable") - case .walletBalanceAvailableInsufficient: - Text("You don't have enough \(currency).") - case .exchangeMissingGlobalFees: - Text("Provider is missing the global fee configuration, this likely means it is misconfigured") - case .feesNotCovered: - Text("Not enough funds to pay the provider fees not covered by the merchant") - } - }.talerFont(.headline) + let localizedCause = balanceDetails.causeHint.localizedCause(currency) + Text(localizedCause) + .talerFont(.headline) ThreeAmountsSection(stack: stack.push(), scope: firstScope, topTitle: topTitle,