taler-ios

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

commit fe00a3cf63abeb0cc7429327e3257b992f9bf597
parent 5398fe5fcd944245c759282fd9ce220acadfb0f2
Author: Marc Stibane <marc@taler.net>
Date:   Sat, 19 Oct 2024 16:46:07 +0200

-Binding

Diffstat:
MTalerWallet1/Helper/CurrencySpecification.swift | 2+-
MTalerWallet1/Views/Actions/Banking/DepositAmountV.swift | 2+-
MTalerWallet1/Views/Actions/Banking/ManualWithdraw.swift | 2+-
MTalerWallet1/Views/HelperViews/AmountInputV.swift | 2+-
MTalerWallet1/Views/HelperViews/CurrencyField.swift | 10+++++-----
MTalerWallet1/Views/HelperViews/CurrencyInputView.swift | 12++++++------
6 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/TalerWallet1/Helper/CurrencySpecification.swift b/TalerWallet1/Helper/CurrencySpecification.swift @@ -60,7 +60,7 @@ extension Amount { func formatted(_ scope: ScopeInfo, isNegative: Bool, useISO: Bool = false, a11y: String? = nil) -> String { let controller = Controller.shared - if let currencyInfo = controller.info2(for: self.currencyStr) { + if let currencyInfo = controller.info(for: scope) { return self.formatted(currencyInfo, isNegative: isNegative, useISO: useISO, a11y: a11y) } return self.readableDescription diff --git a/TalerWallet1/Views/Actions/Banking/DepositAmountV.swift b/TalerWallet1/Views/Actions/Banking/DepositAmountV.swift @@ -108,7 +108,7 @@ struct DepositAmountV: View { Text("Available:\t\(available)") .talerFont(.title3) .padding(.bottom, 2) - CurrencyInputView(currencyInfo: $currencyInfo, + CurrencyInputView(currencyInfo: currencyInfo, amount: $amountToTransfer, amountLastUsed: amountLastUsed, available: nil, // amountAvailable, diff --git a/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift b/TalerWallet1/Views/Actions/Banking/ManualWithdraw.swift @@ -73,7 +73,7 @@ struct ManualWithdraw: View { .multilineTextAlignment(.center) .talerFont(.body) if tosAccepted { - CurrencyInputView(currencyInfo: $currencyInfo, + CurrencyInputView(currencyInfo: currencyInfo, amount: $amountToTransfer, amountLastUsed: amountLastUsed, available: nil, diff --git a/TalerWallet1/Views/HelperViews/AmountInputV.swift b/TalerWallet1/Views/HelperViews/AmountInputV.swift @@ -93,7 +93,7 @@ struct AmountInputV: View { // .foregroundColor(WalletColors().secondary(colorScheme, colorSchemeContrast)) // .padding(4) // } - CurrencyInputView(currencyInfo: $currencyInfo, + CurrencyInputView(currencyInfo: currencyInfo, amount: $amountToTransfer, amountLastUsed: amountLastUsed, available: amountAvailable, diff --git a/TalerWallet1/Views/HelperViews/CurrencyField.swift b/TalerWallet1/Views/HelperViews/CurrencyField.swift @@ -30,7 +30,7 @@ import SymLog @MainActor struct CurrencyField: View { private let symLog = SymLogV(0) - @Binding var currencyInfo: CurrencyInfo + let currencyInfo: CurrencyInfo @Binding var amount: Amount // the `value´ private var currencyFieldRepresentable: CurrencyTextfieldRepresentable! = nil @@ -47,11 +47,11 @@ struct CurrencyField: View { currencyFieldRepresentable.updateText(amount: amount) } - public init(_ currencyInfo: Binding<CurrencyInfo>, amount: Binding<Amount>) { + public init(_ currencyInfo: CurrencyInfo, amount: Binding<Amount>) { self._amount = amount - self._currencyInfo = currencyInfo + self.currencyInfo = currencyInfo self.currencyFieldRepresentable = - CurrencyTextfieldRepresentable(currencyInfo: self.$currencyInfo, + CurrencyTextfieldRepresentable(currencyInfo: self.currencyInfo, amount: self.$amount) } @@ -97,7 +97,7 @@ class NoCaretTextField: UITextField { // MARK: - @MainActor struct CurrencyTextfieldRepresentable: UIViewRepresentable { - @Binding var currencyInfo: CurrencyInfo + let currencyInfo: CurrencyInfo @Binding var amount: Amount private let textField = NoCaretTextField(frame: .zero) diff --git a/TalerWallet1/Views/HelperViews/CurrencyInputView.swift b/TalerWallet1/Views/HelperViews/CurrencyInputView.swift @@ -12,7 +12,7 @@ fileprivate let replaceable = 500 fileprivate let shortcutValues = [5000,2500,1000] // TODO: adapt for ¥ struct ShortcutButton: View { - @Binding var currencyInfo: CurrencyInfo + let currencyInfo: CurrencyInfo let currency: String let currencyField: CurrencyField let shortcut: Int @@ -20,7 +20,7 @@ struct ShortcutButton: View { let action: (Int, CurrencyField) -> Void func makeButton(with newShortcut: Int) -> ShortcutButton { - ShortcutButton(currencyInfo: $currencyInfo, + ShortcutButton(currencyInfo: currencyInfo, currency: currency, currencyField: currencyField, shortcut: newShortcut, @@ -61,7 +61,7 @@ struct ShortcutButton: View { } // MARK: - struct CurrencyInputView: View { - @Binding var currencyInfo: CurrencyInfo + let currencyInfo: CurrencyInfo @Binding var amount: Amount // the `value´ let amountLastUsed: Amount let available: Amount? @@ -97,7 +97,7 @@ struct CurrencyInputView: View { if !shortcutValues.contains(lastUsedI) { shortcut = lastUsedI } } } - return ShortcutButton(currencyInfo: $currencyInfo, + return ShortcutButton(currencyInfo: currencyInfo, currency: amount.currencyStr, currencyField: currencyField, shortcut: shortcut, @@ -135,7 +135,7 @@ struct CurrencyInputView: View { // let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear #endif let currency = amount.currencyStr - let currencyField = CurrencyField($currencyInfo, amount: $amount) + let currencyField = CurrencyField(currencyInfo, amount: $amount) VStack (alignment: .center) { // center shortcut buttons if let heading = heading() { Text(heading) @@ -226,7 +226,7 @@ fileprivate struct Previews: PreviewProvider { @State var amountLastUsed = Amount(currency: LONGCURRENCY, cent: 170) @State private var currencyInfoL: CurrencyInfo = CurrencyInfo.zero(LONGCURRENCY) var body: some View { - CurrencyInputView(currencyInfo: $currencyInfoL, + CurrencyInputView(currencyInfo: currencyInfoL, amount: $amountToPreview, amountLastUsed: amountLastUsed, available: Amount(currency: LONGCURRENCY, cent: 2000),