taler-ios

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

commit 50348b69d2373edde55289f01e7f10e83382ec97
parent 94c4ae0e8f81a46fc1d63193a28447e9a35a5918
Author: Marc Stibane <marc@taler.net>
Date:   Sat,  6 Sep 2025 07:43:31 +0200

pass ScopeInfo

Diffstat:
MTalerWallet1/Views/Actions/Peer2peer/RequestPayment.swift | 2+-
MTalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift | 8++++----
MTalerWallet1/Views/OIM/OIMbalances.swift | 4++--
MTalerWallet1/Views/OIM/OIMcurrency.swift | 13++++++++-----
MTalerWallet1/Views/Transactions/TransactionsListView.swift | 2+-
5 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/TalerWallet1/Views/Actions/Peer2peer/RequestPayment.swift b/TalerWallet1/Views/Actions/Peer2peer/RequestPayment.swift @@ -43,7 +43,7 @@ struct RequestPayment: View { self._amountLastUsed = amountLastUsed self._summary = summary self._iconID = iconID - let oimCurrency = oimCurrency(selectedBalance) // might be nil ==> OIMeuros + let oimCurrency = oimCurrency(selectedBalance?.scopeInfo) // might be nil ==> OIMeuros let oimCash = OIMcash(oimCurrency) self._cash = StateObject(wrappedValue: { oimCash }()) } diff --git a/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift b/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift @@ -46,7 +46,7 @@ struct SendAmountV: View { self._amountLastUsed = amountLastUsed self._summary = summary self._iconID = iconID - let oimCurrency = oimCurrency(selectedBalance.wrappedValue) // might be nil ==> OIMeuros + let oimCurrency = oimCurrency(selectedBalance.wrappedValue?.scopeInfo) // might be nil ==> OIMeuros let oimCash = OIMcash(oimCurrency) self._cash = StateObject(wrappedValue: { oimCash }()) } @@ -86,9 +86,9 @@ struct SendAmountV: View { // TODO: Error amountAvailable = balance.available } - print("🚩SendAmountV.newBalance() set selectedBalance and cash.currency") + print("🚩SendAmountV.newBalance() set selectedBalance and cash.currency") + let oimCurrency = oimCurrency(balance.scopeInfo) // might be nil ==> OIMeuros selectedBalance = balance - let oimCurrency = oimCurrency(balance) // might be nil ==> OIMeuros cash.currency = oimCurrency } } @@ -136,7 +136,7 @@ struct SendAmountV: View { .task(id: taskID) { let avail = amountAvailable await newBalance() -// print(">>> SendAmountV.task", taskID, avail, amountAvailable, stack.peek()?.file) +// print(">>> SendAmountV.task", taskID, avail, amountAvailable, stack.peek()?.file) } #if OIM .overlay { if #available(iOS 16.4, *) { diff --git a/TalerWallet1/Views/OIM/OIMbalances.swift b/TalerWallet1/Views/OIM/OIMbalances.swift @@ -55,7 +55,7 @@ struct OIMbalances: View { self._qrButtonTapped = qrButtonTapped self._historyTapped = historyTapped - let oimCurrency = oimCurrency(selectedBalance.wrappedValue) // might be nil ==> OIMeuros + let oimCurrency = oimCurrency(selectedBalance.wrappedValue?.scopeInfo) // might be nil ==> OIMeuros let oimCash = OIMcash(oimCurrency) self._cash = StateObject(wrappedValue: { oimCash }()) } @@ -239,7 +239,7 @@ struct OIMbalances: View { Spacer() HStack(spacing: 30) { ForEach(Array(controller.balances.enumerated()), id: \.element) { index, balance in - let oimCurrency = oimCurrency(balance) + let oimCurrency = oimCurrency(balance.scopeInfo) let itsMe = selectedBalance == balance let isClosed = selectedBalance == nil let size = isClosed ? 160.0 : OIMbuttonSize diff --git a/TalerWallet1/Views/OIM/OIMcurrency.swift b/TalerWallet1/Views/OIM/OIMcurrency.swift @@ -11,18 +11,21 @@ public typealias OIMdenominations = [UInt64] public typealias OIMnotesCoins = (OIMdenominations, OIMdenominations) // number of notes and coins public let OIMcurrencies = [OIMeuros, OIMleones, OIMxofN, OIMfrancs] -func oimCurrency(_ balance: Balance?) -> OIMcurrency { - let currency = balance?.scopeInfo.currency - if currency == DEMOCURRENCY { + +func oimCurrency(_ scopeInfo: ScopeInfo?) -> OIMcurrency { + let currency = scopeInfo?.currency + if currency == DEMOCURRENCY { // map KUDOS to Leones return OIMcurrencies[1] - } else if currency == TESTCURRENCY { + } else if currency == TESTCURRENCY { // map TESTKUDOS to CFA return OIMcurrencies[2] } else if currency == "CHF" { return OIMcurrencies[3] } - return OIMcurrencies[0] + return OIMcurrencies[0] // fall back to Euros } + + // 6 banknotes, 8 coins of which 6 are fractionals < 100 public let OIMeuros = OIMcurrency(bankNotes: [20000, 10000, 5000, 2000, 1000, 500], bankCoins: [200, 100, 50, 20, 10, 5, 2, 1], diff --git a/TalerWallet1/Views/Transactions/TransactionsListView.swift b/TalerWallet1/Views/Transactions/TransactionsListView.swift @@ -51,7 +51,7 @@ struct TransactionsListView: View { self._transactions = transactions self.reloadAllAction = reloadAllAction self._selectedBalance = selectedBalance - let oimCurrency = oimCurrency(balance) + let oimCurrency = oimCurrency(balance.scopeInfo) let oimCash = OIMcash(oimCurrency) self._cash = StateObject(wrappedValue: { oimCash }()) }