taler-ios

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

commit b12b7cb4ae03411017746732a760b4c295a0f5a6
parent 855f07b71b14bd20ee476ed8dff9968893b74742
Author: Marc Stibane <marc@taler.net>
Date:   Wed, 23 Jul 2025 15:44:58 +0200

centValue factor

Diffstat:
MTalerWallet1/Views/OIM/OIMEditView.swift | 9+++++----
MTalerWallet1/Views/OIM/OIMSubjectView.swift | 2+-
MTalerWallet1/Views/OIM/OIMbackground.swift | 8++++++--
MTalerWallet1/Views/OIM/OIMbalances.swift | 6+++---
MTalerWallet1/Views/OIM/OIMcurrency.swift | 6++++++
MTalerWallet1/Views/OIM/OIMp2pReceiveView.swift | 2+-
MTalerWallet1/Views/OIM/OIMpayView.swift | 2+-
MTalerWallet1/Views/OIM/OIMtransactions.swift | 2+-
MTalerWallet1/Views/OIM/OIMviews.swift | 4++--
9 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/TalerWallet1/Views/OIM/OIMEditView.swift b/TalerWallet1/Views/OIM/OIMEditView.swift @@ -48,8 +48,8 @@ struct OIMEditView: View { // available minus amountVal - what's still available from the balance when amount is on the table var isAvailable: UInt64 { if useAvailable { - let have = available.centValue - let want = amountToTransfer.centValue + let have = available.centValue // TODO: centValue factor + let want = amountToTransfer.centValue // TODO: centValue factor if have > want { return have - want } @@ -131,7 +131,8 @@ struct OIMEditView: View { } VStack { Spacer() - let maxAvailable = useAvailable ? cash.max(available: available.centValue) : 0 + let availableCent = available.centValue // TODO: centValue factor + let maxAvailable = useAvailable ? cash.max(available: availableCent) : 0 OIMcurrencyDrawer(stack: stack.push(), cash: cash, availableVal: $availableVal, // ==> available - amount @@ -149,7 +150,7 @@ struct OIMEditView: View { } .task { // re-set cash to amount (once) // amount2 = amountToTransfer - amountVal = amountToTransfer.centValue + amountVal = amountToTransfer.centValue // TODO: centValue factor availableVal = isAvailable // print("OIMEditView.task", availableVal, amountVal) cash.update2(amountVal, state: .idle) diff --git a/TalerWallet1/Views/OIM/OIMSubjectView.swift b/TalerWallet1/Views/OIM/OIMSubjectView.swift @@ -120,7 +120,7 @@ struct OIMSubjectView: View { // .border(.red) }.task { amount2 = amountToTransfer - amountVal = amountToTransfer.centValue + amountVal = amountToTransfer.centValue // TODO: centValue factor withAnimation(.basic1) { appeared = true } diff --git a/TalerWallet1/Views/OIM/OIMbackground.swift b/TalerWallet1/Views/OIM/OIMbackground.swift @@ -15,6 +15,7 @@ public let OIMBACKLIGHT = "andrey-haimin-VFUTPASjhB8-unsplash" struct OIMamountV: View { let amount: Amount? let currencyName: String + let factor: Int // workaround because TEST has no large denominations, so we multiply with 100 @State private var color = WalletColors().talerColor @@ -29,8 +30,10 @@ struct OIMamountV: View { #endif } var body: some View { - if let amount { - AmountV(currencyName, amount: amount, isNegative: nil) + if let amount { + if let amount2 = try? amount * UInt32(factor) { // workaround for CFA, HUF, JPY +// print(amount2.readableDescription) + AmountV(currencyName, amount: amount2, isNegative: nil) .ignoresSafeArea(edges: .top) .foregroundColor(color) .task { @@ -61,6 +64,7 @@ struct OIMamountV: View { updateColor() } } + } } } // MARK: - diff --git a/TalerWallet1/Views/OIM/OIMbalances.swift b/TalerWallet1/Views/OIM/OIMbalances.swift @@ -105,7 +105,7 @@ struct OIMbalances: View { // cash.setIndex(index) cash.setCurrency(oimCurrency) available = balance.available - availableVal = balance.available.centValue + availableVal = balance.available.centValue // TODO: centValue factor cash.update2(availableVal, state: .chestOpening, duration, initial) // set cash to available let maxAvailable = cash.max(available: availableVal) print("OIMView.openChest availableVal", availableVal, maxAvailable) @@ -182,7 +182,7 @@ struct OIMbalances: View { .opacity(showSend ? 1 : INVISIBLE) } - let maxAvailable = cash.max(available: available?.centValue ?? 0) + let maxAvailable = cash.max(available: available?.centValue ?? 0) // TODO: centValue factor // let _ = print("maxAvailable", maxAvailable) let sidePosition = HStack { @@ -272,7 +272,7 @@ struct OIMbalances: View { .onAppear { if let selectedBalance { available = selectedBalance.available - availableVal = available?.centValue ?? 0 + availableVal = available?.centValue ?? 0 // TODO: centValue factor cash.update2(availableVal) // set cash to available if viewState == .historyTapped { withAnimation(.basic1) { diff --git a/TalerWallet1/Views/OIM/OIMcurrency.swift b/TalerWallet1/Views/OIM/OIMcurrency.swift @@ -25,6 +25,7 @@ func oimCurrency(_ balance: Balance?) -> OIMcurrency { public let OIMeuros = OIMcurrency(bankNotes: [20000, 10000, 5000, 2000, 1000, 500], bankCoins: [200, 100, 50, 20, 10, 5, 2, 1], coinSizes: [258, 232, 242, 222, 198, 212, 188, 162], + factor: 1, noteBase: "EUR", coinBase: "eur", currencyStr: "EUR", chest: "EUR") @@ -32,12 +33,14 @@ public let OIMeuros = OIMcurrency(bankNotes: [20000, 10000, 5000, 2000, 1000, 5 public let OIMxofN = OIMcurrency(bankNotes: [10000, 5000, 2000, 1000, 500], bankCoins: [200, 100, 50, 25, 10, 5, 1], coinSizes: [180, 207, 174, 207, 175, 150, 131], + factor: 100, noteBase: "XOFn", coinBase: "xof", currencyStr: "CFA", chest: "CdI") // 4 banknotes, 8 coins (no fractionals) public let OIMxofC = OIMcurrency(bankNotes: [10000, 5000, 2000, 1000], bankCoins: [500, 200, 100, 50, 25, 10, 5, 1], coinSizes: [200, 180, 207, 174, 207, 175, 150, 131], + factor: 100, noteBase: "XOFn", coinBase: "xof", currencyStr: "CFA", chest: "CdI") // 1 stack, 5 banknotes, 5 coins (all fractionals) @@ -45,6 +48,7 @@ public let OIMleones = OIMcurrency(bankNotes: [ 10000, 2000, 1000, 500, 200, 100 bankCoins: [ 50, 10, 5, 1], coinSizes: [270, 240, 228, 208], // [ 260mm 270px, 240mm 250px, 230mm 240px, 225mm 228px, 200mm 208px] + factor: 1, noteBase: "SLE", coinBase: "sle", currencyStr: "SLE", chest: "SLE") @@ -52,6 +56,7 @@ public let OIMleones = OIMcurrency(bankNotes: [ 10000, 2000, 1000, 500, 200, 100 public let OIMdollars = OIMcurrency(bankNotes: [10000, 5000, 2000, 1000, 500, 200], // XXX x 265 bankCoins: [100, 50, 25, 10, 5, 1], coinSizes: [265, 306, 243, 180, 212, 190], + factor: 1, noteBase: "USD", coinBase: "usd", currencyStr: "USD", chest: "DEU") // MARK: - @@ -59,6 +64,7 @@ public struct OIMcurrency: Sendable { let bankNotes: OIMdenominations // values of each banknote, in cents, descending let bankCoins: OIMdenominations // values of each coin let coinSizes: [CGFloat] // coin sizes + let factor: Int // for TestKudos TODO: remove this once we have a proper installation let noteBase: String let coinBase: String let currencyStr: String diff --git a/TalerWallet1/Views/OIM/OIMp2pReceiveView.swift b/TalerWallet1/Views/OIM/OIMp2pReceiveView.swift @@ -62,7 +62,7 @@ struct OIMp2pReceiveView: View { .scaleEffect(appeared ? 1 : 0.3) .task { amount = effective - amountVal = effective.centValue + amountVal = effective.centValue // TODO: centValue factor withAnimation(.basic1) { appeared = true } diff --git a/TalerWallet1/Views/OIM/OIMpayView.swift b/TalerWallet1/Views/OIM/OIMpayView.swift @@ -39,7 +39,7 @@ struct OIMpayView: View { #endif } .task { - amountVal = amount?.centValue ?? 0 + amountVal = amount?.centValue ?? 0 // TODO: centValue factor } } diff --git a/TalerWallet1/Views/OIM/OIMtransactions.swift b/TalerWallet1/Views/OIM/OIMtransactions.swift @@ -174,7 +174,7 @@ struct OIMtransactions: View { } .onAppear { available = balance.available - availableVal = available?.centValue ?? 0 + availableVal = available?.centValue ?? 0 // TODO: centValue factor cash.update2(availableVal) // set cash to available cash.setTarget(.history) debugTick += 1 diff --git a/TalerWallet1/Views/OIM/OIMviews.swift b/TalerWallet1/Views/OIM/OIMviews.swift @@ -86,12 +86,12 @@ struct OIMtitleView: View { Spacer() } // balance - OIMamountV(amount: amount, currencyName: cash.currency.currencyStr) + OIMamountV(amount: amount, currencyName: cash.currency.currencyStr, factor: cash.currency.factor) if !history { if let secondAmount { Spacer() // amountToSend - OIMamountV(amount: secondAmount, currencyName: cash.currency.currencyStr) + OIMamountV(amount: secondAmount, currencyName: cash.currency.currencyStr, factor: cash.currency.factor) } // invisible - source for money (target) flying out of and back in the open chest OIMactionButton(type: .sendP2P, isFinal: false, action: nil)