taler-ios

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

commit fb90d67fb0f6cb0275bb4ff849e59fac94ed40f7
parent 793029e291013a2c5edc06db5f744f5931ecf674
Author: Marc Stibane <marc@taler.net>
Date:   Thu, 24 Apr 2025 09:43:00 +0200

OIMcoinsView

Diffstat:
ATalerWallet1/Views/OIM/OIMcoinsView.swift | 86+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MTalerWallet1/Views/OIM/OIMlineViews.swift | 37-------------------------------------
2 files changed, 86 insertions(+), 37 deletions(-)

diff --git a/TalerWallet1/Views/OIM/OIMcoinsView.swift b/TalerWallet1/Views/OIM/OIMcoinsView.swift @@ -0,0 +1,86 @@ +/* + * This file is part of GNU Taler, ©2022-25 Taler Systems S.A. + * See LICENSE.md + */ +/** + * @author Marc Stibane + */ +import SwiftUI +import taler_swift + +// MARK: - +// renders a spread of coin-stacks in 1 row +struct OIMcoinsView1: View { + let stack: CallStack + let spread: OIMdenominations + let currency: OIMcurrency + @Binding var amountVal: UInt64 + let tappedVal: UInt64 + @Binding var flying: UInt64 + let shake: Bool + let canEdit: Bool + + var body: some View { + let nrOfCoins = currency.bankCoins.count - 1 + HStack(alignment: .top, spacing: 10) { + ForEach(0...nrOfCoins, id: \.self) { index in + let value = currency.bankCoins[index] + let shouldFly = tappedVal == value + let count = spread[index] + (shouldFly ? 1 : 0) + if count > 0 { + OIMcoinStackV(stack: stack.push(), + value: value, + count: Int(count), + currency: currency, + tappedVal: tappedVal, + flying: $flying, + shake: shake, + canEdit: canEdit + ) { + withAnimation(Animation.easeIn1) { + amountVal -= value + } } } + } // ForEach + } // HStack + } +} +// MARK: - +// renders a spread of coin-stacks in 1 row +struct OIMcoinsView2: View { + let stack: CallStack + let spread: OIMdenominations + @Binding var amountVal: UInt64 + let tappedVal: UInt64 + @Binding var flying: UInt64 + let canEdit: Bool + + @EnvironmentObject private var cash: OIMcash + + var body: some View { + let _ = Self._printChanges() + let currency = cash.currency + let nrOfCoins = currency.bankCoins.count - 1 + HStack(alignment: .top, spacing: 10) { + ForEach(0...nrOfCoins, id: \.self) { index in + let value = currency.bankCoins[index] + let shouldFly = tappedVal == value + let count = spread[index] + (shouldFly ? 1 : 0) + if count > 0 { + OIMcoinStackV2(stack: stack.push(), + value: value, + count: Int(count), + tappedVal: tappedVal, + flying: $flying, + canEdit: canEdit + ) { + withAnimation(Animation.easeIn1) { + amountVal -= value + } } } + } // ForEach + } // HStack + } +} +// MARK: - +//#Preview { +// OIMlineView() +//} diff --git a/TalerWallet1/Views/OIM/OIMlineViews.swift b/TalerWallet1/Views/OIM/OIMlineViews.swift @@ -46,43 +46,6 @@ struct OIMnotesView1: View { } // MARK: - -// renders a spread of coin-stacks in 1 row -struct OIMcoinsView1: View { - let stack: CallStack - let spread: OIMdenominations - let currency: OIMcurrency - @Binding var amountVal: UInt64 - let tappedVal: UInt64 - @Binding var flying: UInt64 - let shake: Bool - let canEdit: Bool - - var body: some View { - let nrOfCoins = currency.bankCoins.count - 1 - HStack(alignment: .top, spacing: 10) { - ForEach(0...nrOfCoins, id: \.self) { index in - let value = currency.bankCoins[index] - let shouldFly = tappedVal == value - let count = spread[index] + (shouldFly ? 1 : 0) - if count > 0 { - OIMcoinStackV(stack: stack.push(), - value: value, - count: Int(count), - currency: currency, - tappedVal: tappedVal, - flying: $flying, - shake: shake, - canEdit: canEdit - ) { - withAnimation(Animation.easeIn1) { - amountVal -= value - } } } - } // ForEach - } // HStack - } -} - -// MARK: - fileprivate let horzSpacing: CGFloat = 20 fileprivate let vertSpacing: CGFloat = 10