taler-ios

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

commit ad2a521744b747e145330e326421095fc9e1fda5
parent 94fccfa168c3a2ecc30ab3ee93c13bdb821405a2
Author: Marc Stibane <marc@taler.net>
Date:   Sun,  9 Jun 2024 18:18:03 +0200

formatted

Diffstat:
MTalerWallet1/Helper/CurrencySpecification.swift | 6+++---
MTalerWallet1/Views/Banking/DepositAmountV.swift | 10+++++-----
MTalerWallet1/Views/Banking/DepositIbanV.swift | 4++--
MTalerWallet1/Views/Banking/QuiteSomeCoins.swift | 2+-
MTalerWallet1/Views/HelperViews/AmountInputV.swift | 2+-
MTalerWallet1/Views/HelperViews/AmountV.swift | 2+-
MTalerWallet1/Views/HelperViews/CurrencyField.swift | 2+-
MTalerWallet1/Views/HelperViews/CurrencyInputView.swift | 2+-
MTalerWallet1/Views/HelperViews/QRCodeDetailView.swift | 2+-
MTalerWallet1/Views/HelperViews/SubjectInputV.swift | 4++--
MTalerWallet1/Views/Peer2peer/P2PSubjectV.swift | 6+++---
MTalerWallet1/Views/Peer2peer/SendAmount.swift | 6+++---
MTalerWallet1/Views/Sheets/Payment/PaymentView.swift | 4++--
MTalerWallet1/Views/Transactions/ManualDetailsV.swift | 6+++---
14 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/TalerWallet1/Helper/CurrencySpecification.swift b/TalerWallet1/Helper/CurrencySpecification.swift @@ -33,7 +33,7 @@ extension Locale { } extension Amount { - func string(_ currencyInfo: CurrencyInfo?, useSymbol: Bool = true) -> String { + func formatted(_ currencyInfo: CurrencyInfo?, useSymbol: Bool = true) -> String { if let currencyInfo { return currencyInfo.string(for: valueAsFloatTuple, useSymbol: useSymbol) } else { @@ -41,10 +41,10 @@ extension Amount { } } - func string(useSymbol: Bool = true) -> String { + func formatted(useSymbol: Bool = true) -> String { let controller = Controller.shared if let currencyInfo = controller.info(for: self.currencyStr) { - return self.string(currencyInfo, useSymbol: useSymbol) + return self.formatted(currencyInfo, useSymbol: useSymbol) } return self.readableDescription } diff --git a/TalerWallet1/Views/Banking/DepositAmountV.swift b/TalerWallet1/Views/Banking/DepositAmountV.swift @@ -59,12 +59,12 @@ struct DepositAmountV: View { } private func buttonTitle(_ amount: Amount, _ currencyInfo: CurrencyInfo) -> String { - let amountWithCurrency = amount.string(currencyInfo, useSymbol: false) + let amountWithCurrency = amount.formatted(currencyInfo, useSymbol: false) return String(localized: "Deposit \(amountWithCurrency)", comment: "amount with currency") } private func subjectTitle(_ amount: Amount, _ currencyInfo: CurrencyInfo) -> String { - let amountStr = amount.string(currencyInfo) + let amountStr = amount.formatted(currencyInfo) return String(localized: "NavTitle_Deposit_AmountStr", defaultValue: "Deposit", comment: "NavTitle: Deposit") // defaultValue: "Deposit \(amountStr)", comment: "NavTitle: Deposit 'amountStr'") @@ -89,10 +89,10 @@ struct DepositAmountV: View { let navTitle = String(localized: "NavTitle_Deposit_Currency", defaultValue: "Deposit \(currencySymbol)", comment: "NavTitle: Deposit 'currencySymbol'") - let available = amountAvailable?.string(currencyInfo) ?? "an unknown amount" + let available = amountAvailable?.formatted(currencyInfo) ?? "an unknown amount" let _ = print("available: \(available)") let _ = symLog.log("currency: \(currency), available: \(available)") - let amountVoiceOver = amountToTransfer.string(currencyInfo) + let amountVoiceOver = amountToTransfer.formatted(currencyInfo) let insufficientLabel = String(localized: "You don't have enough \(currency).") let insufficientLabel2 = String(localized: "but you only have \(available) to deposit.") @@ -169,7 +169,7 @@ struct DepositAmountV: View { } else if let paytoUri { if let ppCheck = try? await model.prepareDepositM(paytoUri, amount: amountToTransfer) { if let feeAmount = fee(ppCheck: ppCheck) { - feeStr = feeAmount.string(currencyInfo) + feeStr = feeAmount.formatted(currencyInfo) let feeLabel = feeLabel(feeStr) announce("\(amountVoiceOver), \(feeLabel)") } else { diff --git a/TalerWallet1/Views/Banking/DepositIbanV.swift b/TalerWallet1/Views/Banking/DepositIbanV.swift @@ -31,13 +31,13 @@ struct DepositIbanV: View { @FocusState private var isFocused: Bool private func buttonTitle(_ amount: Amount, _ currencyInfo: CurrencyInfo) -> String { - let amountWithCurrency = amount.string(currencyInfo, useSymbol: false) + let amountWithCurrency = amount.formatted(currencyInfo, useSymbol: false) return String(localized: "Next", comment: "advance Deposit to Amount") return String(localized: "Deposit \(amountWithCurrency)", comment: "amount with currency") } private func subjectTitle(_ amount: Amount, _ currencyInfo: CurrencyInfo) -> String { - let amountStr = amount.string(currencyInfo) + let amountStr = amount.formatted(currencyInfo) return String(localized: "NavTitle_Deposit_AmountStr", defaultValue: "Deposit", comment: "NavTitle: Deposit") // defaultValue: "Deposit \(amountStr)", comment: "NavTitle: Deposit 'amountStr'") diff --git a/TalerWallet1/Views/Banking/QuiteSomeCoins.swift b/TalerWallet1/Views/Banking/QuiteSomeCoins.swift @@ -20,7 +20,7 @@ struct SomeCoins { invalid ? String(localized: "Amount too small!") : tooMany ? String(localized: "Amount too big for a single withdrawal!") : fee.isZero ? String(localized: "No withdrawal fee") - : String(localized: "- \(fee.string(currencyInfo)) fee") + : String(localized: "- \(fee.formatted(currencyInfo)) fee") } else { EMPTYSTRING } diff --git a/TalerWallet1/Views/HelperViews/AmountInputV.swift b/TalerWallet1/Views/HelperViews/AmountInputV.swift @@ -54,7 +54,7 @@ struct AmountInputV: View { let currency = amountToTransfer.currencyStr let currencyInfo = controller.info(for: currency, controller.currencyTicker) let insufficientLabel = String(localized: "You don't have enough \(currency).") - let available = amountAvailable?.string(currencyInfo) ?? nil + let available = amountAvailable?.formatted(currencyInfo) ?? nil let flags = checkAvailable(amount: amountToTransfer) ScrollView { VStack(alignment: .trailing) { if let available { diff --git a/TalerWallet1/Views/HelperViews/AmountV.swift b/TalerWallet1/Views/HelperViews/AmountV.swift @@ -12,7 +12,7 @@ struct AmountV: View { @EnvironmentObject private var controller: Controller var body: some View { - Text(amount.string()) + Text(amount.formatted()) .multilineTextAlignment(.center) .talerFont(large ? .title : .title2) // .fontWeight(large ? .medium : .regular) // @available(iOS 16.0, *) diff --git a/TalerWallet1/Views/HelperViews/CurrencyField.swift b/TalerWallet1/Views/HelperViews/CurrencyField.swift @@ -59,7 +59,7 @@ struct CurrencyField: View { ZStack { // Text view to display the formatted currency // Set as priority so CurrencyInputField size doesn't affect parent - Text(amount.string(currencyInfo)) + Text(amount.formatted(currencyInfo)) .layoutPriority(1) // make the textfield use the whole width for tapping inside to become active .frame(maxWidth: .infinity, alignment: .trailing) diff --git a/TalerWallet1/Views/HelperViews/CurrencyInputView.swift b/TalerWallet1/Views/HelperViews/CurrencyInputView.swift @@ -37,7 +37,7 @@ struct ShortcutButton: View { var body: some View { let shortie = Amount(currency: currency, cent: UInt64(shortcut)) // TODO: adapt for ¥ - let title = shortie.string(currencyInfo) + let title = shortie.formatted(currencyInfo) let shortcutLabel = String(localized: "Shortcut", comment: "VoiceOver: $50,$25,$10,$5 shortcut buttons") Button(action: { action(shortcut, currencyField)} ) { Text(title) diff --git a/TalerWallet1/Views/HelperViews/QRCodeDetailView.swift b/TalerWallet1/Views/HelperViews/QRCodeDetailView.swift @@ -51,7 +51,7 @@ struct QRCodeDetailView: View { .accessibilityLabel("QR Code") .listRowSeparator(.hidden) - let amountStr = amount.string() + let amountStr = amount.formatted() let scanMini = incoming ? String(localized: "Either (payer) Mini 3", defaultValue: "to pay \(amountStr).", comment: "e.g. '5,3 €'") : String(localized: "Either (payee) Mini 3", diff --git a/TalerWallet1/Views/HelperViews/SubjectInputV.swift b/TalerWallet1/Views/HelperViews/SubjectInputV.swift @@ -44,7 +44,7 @@ struct SubjectInputV<TargetView: View>: View { // let insufficientLabel = String(localized: "You don't have enough \(currency).") // let feeLabel = insufficient ? insufficientLabel // : feeLabel(feeStr) - let available = amountAvailable?.string(currencyInfo) ?? nil + let available = amountAvailable?.formatted(currencyInfo) ?? nil // let disabled = insufficient || summary.count == 0 let disabled = summary.count == 0 ScrollView { VStack(alignment: .leading) { @@ -85,7 +85,7 @@ struct SubjectInputV<TargetView: View>: View { } } HStack { - Text(amountToTransfer.string(currencyInfo)) + Text(amountToTransfer.formatted(currencyInfo)) // TODO: hasFees? // Text(feeLabel) } diff --git a/TalerWallet1/Views/Peer2peer/P2PSubjectV.swift b/TalerWallet1/Views/Peer2peer/P2PSubjectV.swift @@ -36,7 +36,7 @@ struct P2PSubjectV: View { @FocusState private var isFocused: Bool private func buttonTitle(_ amount: Amount, _ currencyInfo: CurrencyInfo) -> String { - let amountWithCurrency = amount.string(currencyInfo, useSymbol: false) + let amountWithCurrency = amount.formatted(currencyInfo, useSymbol: false) return amountToSend ? String(localized: "Send \(amountWithCurrency) now", comment: "amount with currency") : String(localized: "Request \(amountWithCurrency)", @@ -44,7 +44,7 @@ struct P2PSubjectV: View { } private func subjectTitle(_ amount: Amount, _ currencyInfo: CurrencyInfo) -> String { - let amountStr = amount.string(currencyInfo) + let amountStr = amount.formatted(currencyInfo) return amountToSend ? String(localized: "NavTitle_Send_AmountStr", defaultValue: "Send \(amountStr)", comment: "NavTitle: Send 'amountStr'") @@ -136,7 +136,7 @@ struct P2PSubjectV: View { if amountToSend && feeLabel == nil { if let ppCheck = try? await model.checkPeerPushDebitM(amountToTransfer) { if let feeAmount = p2pFee(ppCheck: ppCheck) { - let feeStr = feeAmount.string(currencyInfo) + let feeStr = feeAmount.formatted(currencyInfo) myFeeLabel = String(localized: "+ \(feeStr) fee") } else { myFeeLabel = EMPTYSTRING } } diff --git a/TalerWallet1/Views/Peer2peer/SendAmount.swift b/TalerWallet1/Views/Peer2peer/SendAmount.swift @@ -75,10 +75,10 @@ struct SendAmount: View { let navTitle = String(localized: "NavTitle_Send_Currency", defaultValue: "Send \(currencySymbol)", comment: "NavTitle: Send 'currencySymbol'") - let available = amountAvailable.string(currencyInfo) + let available = amountAvailable.formatted(currencyInfo) // let _ = print("available: \(available)") let _ = symLog.log("currency: \(currency), available: \(available)") - let amountVoiceOver = amountToTransfer.string(currencyInfo) + let amountVoiceOver = amountToTransfer.formatted(currencyInfo) let insufficientLabel2 = String(localized: "but you only have \(available) to send.") let inputDestination = LazyView { @@ -155,7 +155,7 @@ struct SendAmount: View { // TODO: set from exchange // agePicker.setAges(ages: peerPushCheck?.ageRestrictionOptions) if let feeAmount = fee(ppCheck: ppCheck) { - feeStr = feeAmount.string(currencyInfo) + feeStr = feeAmount.formatted(currencyInfo) let feeLabel = feeLabel(feeStr) announce("\(amountVoiceOver), \(feeLabel)") } else { diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift @@ -47,10 +47,10 @@ func preparePayForTemplate(model: WalletModel, let amountRaw = ppCheck.amountRaw let currency = amountRaw.currencyStr let currencyInfo = controller.info(for: currency, controller.currencyTicker) - let amountVoiceOver = amountRaw.string(currencyInfo) + let amountVoiceOver = amountRaw.formatted(currencyInfo) let insufficient = ppCheck.status == .insufficientBalance if let feeAmount = templateFee(ppCheck: ppCheck) { - let feeStr = feeAmount.string(currencyInfo) + let feeStr = feeAmount.formatted(currencyInfo) let feeLabel = feeLabel(feeStr) announce("\(amountVoiceOver), \(feeLabel)") return PayForTemplateResult(ppCheck: ppCheck, insufficient: insufficient, diff --git a/TalerWallet1/Views/Transactions/ManualDetailsV.swift b/TalerWallet1/Views/Transactions/ManualDetailsV.swift @@ -165,9 +165,9 @@ struct ManualDetailsV: View { let currencyInfo = CurrencyInfo(scope: myScope, specs: specs, formatter: CurrencyFormatter.formatter(scope: myScope, specs: specs)) - return amount.string(currencyInfo) + return amount.formatted(currencyInfo) } - return amount.string() + return amount.formatted() } var body: some View { @@ -178,7 +178,7 @@ struct ManualDetailsV: View { if let amount = account.transferAmount { let specs = account.currencySpecification let amountStr = amountString(amount, specs: specs) - let obtainStr = common.amountRaw.string() + let obtainStr = common.amountRaw.formatted() if !minimalistic { Text("The Payment Service Provider is waiting for your wire-transfer.") .bold()