taler-ios

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

commit f6d7c049423170d88d85ed77f226ab4eead63fb2
parent ca2329e8edbe4029c99c13e666b485ae8781c92f
Author: Marc Stibane <marc@taler.net>
Date:   Thu, 18 Jan 2024 09:36:59 +0100

cleanup, preview

Diffstat:
MTalerWallet1/Helper/CurrencySpecification.swift | 14++++++++++++++
MTalerWallet1/Views/HelperViews/QRCodeDetailView.swift | 20+++++++++-----------
2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/TalerWallet1/Helper/CurrencySpecification.swift b/TalerWallet1/Helper/CurrencySpecification.swift @@ -253,3 +253,17 @@ public class CurrencyFormatter: NumberFormatter { fatalError("init(coder:) has not been implemented") } } +// MARK: - +#if DEBUG +func PreviewCurrencyInfo(_ currency: String, digits: Int) -> CurrencyInfo { + let unitName = digits == 0 ? "テ" : "ク" // do not use real currency symbols like "¥" : "€" + let scope = ScopeInfo(type: .global, currency: currency) + let specs = CurrencySpecification(name: currency, + fractionalInputDigits: digits, + fractionalNormalDigits: digits, + fractionalTrailingZeroDigits: digits, + altUnitNames: [0 : unitName]) + let previewFormatter = CurrencyFormatter.formatter(scope: scope, specs: specs) + return CurrencyInfo(scope: scope, specs: specs, formatter: previewFormatter) +} +#endif diff --git a/TalerWallet1/Views/HelperViews/QRCodeDetailView.swift b/TalerWallet1/Views/HelperViews/QRCodeDetailView.swift @@ -10,12 +10,12 @@ import AVFoundation struct QRCodeDetailView: View { let talerURI: String let incoming: Bool - let amount: Amount? + let amount: Amount var body: some View { if talerURI.count > 10 { Section { - Text("Either", comment: "Either (copy/share)") + Text("Either", comment: "Either (copy/share the payment link to the ...)") .multilineTextAlignment(.leading) .accessibilityFont(.title3) // .padding(.vertical) @@ -28,7 +28,8 @@ struct QRCodeDetailView: View { let otherParty = incoming ? String(localized: "payer", comment: "the payment link to the (otherParty), or") : String(localized: "payee", comment: "the payment link to the (otherParty), or") - Text("the payment link to the \(otherParty), or", comment: "...the payment link to the (payer/payee), or") + Text("the payment link to the \(otherParty), or", + comment: "(Either copy/share the payment link) to the (payer/payee), or") .multilineTextAlignment(.leading) .accessibilityFont(.title3) .listRowSeparator(.hidden) @@ -41,14 +42,11 @@ struct QRCodeDetailView: View { } .listRowSeparator(.hidden) - // TODO: use currency formatter instead of .readableDescription - let hintStr = (amount == nil) ? - (incoming ? String(localized: "let the payer scan this QR code to pay.") - : String(localized: "let the payee scan this QR code to receive.")) - : (incoming ? String(localized: "let the payer scan this QR code to pay \(amount!.readableDescription).", - comment: "e.g. '5,3 €'") - : String(localized: "let the payee scan this QR code to receive \(amount!.readableDescription).", - comment: "e.g. '$ 7.41'")) + let amountStr = amount.readableDescription // TODO: currency formatter? + let hintStr = incoming ? String(localized: "let the payer scan this QR code to pay \(amountStr).", + comment: "e.g. '5,3 €'") + : String(localized: "let the payee scan this QR code to receive \(amountStr).", + comment: "e.g. '$ 7.41'") Text(hintStr) .fixedSize(horizontal: false, vertical: true) // wrap in scrollview .accessibilityFont(.title3)