taler-ios

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

commit 14b854806aff4cc45cb7d51b7a727bab65b8c32b
parent 32672f97dc777ab606557f7f094d959ace6498c4
Author: Marc Stibane <marc@taler.net>
Date:   Sun, 13 Apr 2025 08:46:57 +0200

UInt64

Diffstat:
MTalerWallet1/Views/OIM/OIMView.swift | 24++++++++++++------------
MTalerWallet1/Views/OIM/OIMcurrency.swift | 16++++++++--------
MTalerWallet1/Views/OIM/OIMcurrencyButton.swift | 11+++++++----
MTalerWallet1/Views/OIM/OIMcurrencyScroller.swift | 10+++++-----
MTalerWallet1/Views/OIM/OIMcurrencyViews2.swift | 12++++++------
MTalerWallet1/Views/OIM/OIMlineViews.swift | 22+++++++++++-----------
6 files changed, 49 insertions(+), 46 deletions(-)

diff --git a/TalerWallet1/Views/OIM/OIMView.swift b/TalerWallet1/Views/OIM/OIMView.swift @@ -8,12 +8,12 @@ import SwiftUI import taler_swift -fileprivate func intValue(_ amount: Amount?) -> Int { +fileprivate func intValue(_ amount: Amount?) -> UInt64 { if let amount { if !amount.isZero { let value = amount.value * 100 // TODO: currency specs instead of 100 // print("intValue: \(Int(value)) \(currency.noteBase)") - return Int(value) + return UInt64(value) } } return 0 @@ -62,10 +62,10 @@ struct OIMView: View { @AppStorage("sierraLeone") var sierraLeone: Bool = false - @State private var amountVal: Int = 0 + @State private var amountVal: UInt64 = 0 @Namespace var namespace - @State private var tappedVal = 0 - @State private var flying = 0 + @State private var tappedVal: UInt64 = 0 + @State private var flying: UInt64 = 0 @State private var shake = false var body: some View { @@ -111,10 +111,10 @@ struct OIMPayView: View { @AppStorage("sierraLeone") var sierraLeone: Bool = false - @State private var amountVal: Int = 0 + @State private var amountVal: UInt64 = 0 @Namespace var namespace - @State private var tappedVal = 0 - @State private var flying = 0 + @State private var tappedVal: UInt64 = 0 + @State private var flying: UInt64 = 0 @State private var shake = false var body: some View { @@ -150,12 +150,12 @@ struct OIMEditView: View { @AppStorage("sierraLeone") var sierraLeone: Bool = false - @State private var amountVal: Int = 0 - @State private var availableVal: Int = 0 + @State private var amountVal: UInt64 = 0 + @State private var availableVal: UInt64 = 0 @Namespace var namespace - @State private var tappedVal = 0 - @State private var flying = 0 + @State private var tappedVal: UInt64 = 0 + @State private var flying: UInt64 = 0 @State private var shake = false var body: some View { diff --git a/TalerWallet1/Views/OIM/OIMcurrency.swift b/TalerWallet1/Views/OIM/OIMcurrency.swift @@ -7,7 +7,7 @@ */ import Foundation -public typealias OIMdenominations = [Int] +public typealias OIMdenominations = [UInt64] public typealias OIMnotesCoins = (OIMdenominations, OIMdenominations) // number of notes and coins // 6 banknotes, 8 coins of which 6 are fractionals < 100 @@ -16,7 +16,7 @@ public let OIMeuros = OIMcurrency(bankNotes: [20000, 10000, 5000, 2000, 1000, 5 coinSizes: [258, 232, 242, 222, 198, 212, 188, 162], noteBase: "EUR", coinBase: "eur") -// 5 banknotes, 5 coins (all fractionals) +// 3 stacks, 5 banknotes, 5 coins (all fractionals) public let OIMleones = OIMcurrency(bankNotes: [20000, 10000, 5000, 2000, 1000, 500, 200, 100], bankCoins: [ 50, 25, 10, 5, 1], coinSizes: [270, 250, 240, 228, 208], @@ -36,7 +36,7 @@ public struct OIMcurrency: Sendable { let noteBase: String let coinBase: String - func coinSize(_ value: Int) -> CGFloat? { + func coinSize(_ value: UInt64) -> CGFloat? { for (index, element) in bankCoins.enumerated() { if element == value { if index < coinSizes.count { @@ -47,14 +47,14 @@ public struct OIMcurrency: Sendable { return nil } - func coinName(_ value: Int) -> String? { + func coinName(_ value: UInt64) -> String? { if bankCoins.contains(value) { return coinBase + "-" + String(value) } return nil } - func noteName(_ value: Int) -> String? { + func noteName(_ value: UInt64) -> String? { if bankNotes.contains(value) { return noteBase + "-" + String(value) } @@ -62,13 +62,13 @@ public struct OIMcurrency: Sendable { } /// spreads out the input value into banknotes and coins of the currency - func notesCoins(_ intVal: Int) -> OIMnotesCoins { + func notesCoins(_ intVal: UInt64) -> OIMnotesCoins { var notes: OIMdenominations = [] var coins: OIMdenominations = [] var value = intVal for (index, element) in bankNotes.enumerated() { - var count = 0 + var count: UInt64 = 0 while value >= element { value = value - element count += 1 @@ -77,7 +77,7 @@ public struct OIMcurrency: Sendable { } for (index, element) in bankCoins.enumerated() { - var count = 0 + var count: UInt64 = 0 while value >= element { value = value - element count += 1 diff --git a/TalerWallet1/Views/OIM/OIMcurrencyButton.swift b/TalerWallet1/Views/OIM/OIMcurrencyButton.swift @@ -8,6 +8,7 @@ import SwiftUI import taler_swift +fileprivate struct OIMbuttonStyle: ButtonStyle { public func makeBody(configuration: OIMbuttonStyle.Configuration) -> some View { @@ -22,6 +23,7 @@ struct OIMbuttonStyle: ButtonStyle { } } +fileprivate struct OIMcurrencyImage { let image: Image let oWidth: CGFloat @@ -40,10 +42,11 @@ struct OIMcurrencyImage { } } +fileprivate struct OIMmod: AnimatableModifier { - let value: Int + let value: UInt64 let name: String? - let availableVal: Int + let availableVal: UInt64 let canEdit: Bool var pct: CGFloat let action: () -> Void @@ -80,9 +83,9 @@ struct OIMmod: AnimatableModifier { /// renders 1 denomination from a currency struct OIMcurrencyButton: View { - let value: Int + let value: UInt64 let currency: OIMcurrency - let availableVal: Int + let availableVal: UInt64 let canEdit: Bool var pct: CGFloat let action: () -> Void diff --git a/TalerWallet1/Views/OIM/OIMcurrencyScroller.swift b/TalerWallet1/Views/OIM/OIMcurrencyScroller.swift @@ -11,15 +11,15 @@ import taler_swift // renders all banknotes and coins in 1 horizontal scrollview struct OIMcurrencyScroller: View { let currency: OIMcurrency - @Binding var availableVal: Int - @Binding var amountVal: Int - @Binding var tappedVal: Int - @Binding var flying: Int + @Binding var availableVal: UInt64 + @Binding var amountVal: UInt64 + @Binding var tappedVal: UInt64 + @Binding var flying: UInt64 @Binding var shake: Bool @EnvironmentObject private var wrapper: NamespaceWrapper - func tap(value: Int, _ delay: Int = 250) { + func tap(value: UInt64, _ delay: Int = 250) { withAnimation(.shake1) { flying = 0 tappedVal = value diff --git a/TalerWallet1/Views/OIM/OIMcurrencyViews2.swift b/TalerWallet1/Views/OIM/OIMcurrencyViews2.swift @@ -13,11 +13,11 @@ import taler_swift // renders a stack of (identical) banknotes with offset 10,20 struct OIMnoteStackV: View { let stack: CallStack - let value: Int + let value: UInt64 let count: Int let currency: OIMcurrency - let tappedVal: Int - @Binding var flying: Int + let tappedVal: UInt64 + @Binding var flying: UInt64 let shake: Bool let canEdit: Bool let action: () -> Void @@ -66,11 +66,11 @@ struct OIMnoteStackV: View { // renders a stack of (identical) coins with offset size/16 struct OIMcoinStackV: View { let stack: CallStack - let value: Int + let value: UInt64 let count: Int let currency: OIMcurrency - let tappedVal: Int - @Binding var flying: Int + let tappedVal: UInt64 + @Binding var flying: UInt64 let shake: Bool let canEdit: Bool let action: () -> Void diff --git a/TalerWallet1/Views/OIM/OIMlineViews.swift b/TalerWallet1/Views/OIM/OIMlineViews.swift @@ -13,9 +13,9 @@ struct OIMnotesView1: View { let stack: CallStack let spread: OIMdenominations let currency: OIMcurrency - @Binding var amountVal: Int - let tappedVal: Int - @Binding var flying: Int + @Binding var amountVal: UInt64 + let tappedVal: UInt64 + @Binding var flying: UInt64 let shake: Bool let canEdit: Bool @@ -30,7 +30,7 @@ struct OIMnotesView1: View { if count > 0 { OIMnoteStackV(stack: stack.push(), value: value, - count: count, + count: Int(count), currency: currency, tappedVal: tappedVal, flying: $flying, @@ -51,9 +51,9 @@ struct OIMcoinsView1: View { let stack: CallStack let spread: OIMdenominations let currency: OIMcurrency - @Binding var amountVal: Int - let tappedVal: Int - @Binding var flying: Int + @Binding var amountVal: UInt64 + let tappedVal: UInt64 + @Binding var flying: UInt64 let shake: Bool let canEdit: Bool @@ -67,7 +67,7 @@ struct OIMcoinsView1: View { if count > 0 { OIMcoinStackV(stack: stack.push(), value: value, - count: count, + count: Int(count), currency: currency, tappedVal: tappedVal, flying: $flying, @@ -89,9 +89,9 @@ fileprivate let vertSpacing: CGFloat = 10 struct OIMlineView: View { let stack: CallStack let currency: OIMcurrency - @Binding var amountVal: Int - let tappedVal: Int - @Binding var flying: Int + @Binding var amountVal: UInt64 + let tappedVal: UInt64 + @Binding var flying: UInt64 let shake: Bool let canEdit: Bool