taler-ios

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

commit 2611e634387eff0b4cf7113b88577a4aa18ec1f4
parent 0a36ba7163bb40172df42437741f0a685d9e68b8
Author: Marc Stibane <marc@taler.net>
Date:   Tue,  8 Jul 2025 00:23:50 +0200

rename

Diffstat:
MTalerWallet1/Views/OIM/OIMEditView.swift | 12++++++------
MTalerWallet1/Views/OIM/OIMView.swift | 12++++++------
ATalerWallet1/Views/OIM/OIMcurrencyDrawer.swift | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DTalerWallet1/Views/OIM/OIMcurrencyScroller.swift | 93-------------------------------------------------------------------------------
4 files changed, 105 insertions(+), 105 deletions(-)

diff --git a/TalerWallet1/Views/OIM/OIMEditView.swift b/TalerWallet1/Views/OIM/OIMEditView.swift @@ -122,12 +122,12 @@ struct OIMEditView: View { VStack { Spacer() let maxAvailable = useAvailable ? cash.max(available: available.centValue) : 0 - OIMcurrencyScroller(stack: stack.push(), - cash: cash, - availableVal: $availableVal, // ==> available - amount - tappedVal: $tappedVal, - scrollPosition: maxAvailable, // max note or coin (available) - canEdit: true) + OIMcurrencyDrawer(stack: stack.push(), + cash: cash, + availableVal: $availableVal, // ==> available - amount + tappedVal: $tappedVal, + scrollPosition: maxAvailable, // max note or coin (available) + canEdit: true) .zIndex(2) // make notes fly from topZ .clipped(antialiased: true) .padding(.horizontal, 5) diff --git a/TalerWallet1/Views/OIM/OIMView.swift b/TalerWallet1/Views/OIM/OIMView.swift @@ -253,12 +253,12 @@ struct OIMView: View { VStack { Spacer() - OIMcurrencyScroller(stack: stack.push(), - cash: cash, - availableVal: $availableVal, - tappedVal: $tappedVal, - scrollPosition: maxAvailable, - canEdit: false) + OIMcurrencyDrawer(stack: stack.push(), + cash: cash, + availableVal: $availableVal, + tappedVal: $tappedVal, + scrollPosition: maxAvailable, + canEdit: false) .clipped(antialiased: true) .padding(.horizontal, 5) .ignoresSafeArea(edges: .horizontal) diff --git a/TalerWallet1/Views/OIM/OIMcurrencyDrawer.swift b/TalerWallet1/Views/OIM/OIMcurrencyDrawer.swift @@ -0,0 +1,93 @@ +/* + * This file is part of GNU Taler, ©2022-25 Taler Systems S.A. + * See LICENSE.md + */ +/** + * @author Marc Stibane + */ +import SwiftUI +import taler_swift + +// renders all banknotes and coins in 1 horizontal scrollview +struct OIMcurrencyDrawer: View { + let stack: CallStack + let cash: OIMcash + @Binding var availableVal: UInt64 + @Binding var tappedVal: UInt64 + let scrollPosition: UInt64 + let canEdit: Bool + + @EnvironmentObject private var wrapper: NamespaceWrapper + + var body: some View { + var debugTick = 0 +// let _ = Self._printChanges() + + let currency = cash.currency + let taskID = currency.noteBase + String(scrollPosition) + ScrollViewReader { proxy in + ScrollView(.horizontal) { + HStack(alignment: .bottom, spacing: 10) { + ForEach(currency.bankNotes, id: \.self) { value in + let sourceID = -Int(value) + let fund = OIMfund(id: sourceID, state: .idle, value: value) + OIMcurrencyButton(stack: stack.push(), + fund: fund, + currency: currency, + availableVal: availableVal, + canEdit: canEdit, + pct: 0.9, // hover a bit above the desk + action: { tappedVal = value } + ) + .id(currency.noteBase + String(sourceID)) + .matchedGeometryEffect(id: String(sourceID), in: wrapper.namespace, isSource: true) + } + ForEach(currency.bankCoins, id: \.self) { value in + let sourceID = -Int(value) + let fund = OIMfund(id: sourceID, state: .idle, value: value) + OIMcurrencyButton(stack: stack.push(), + fund: fund, + currency: currency, + availableVal: availableVal, + canEdit: canEdit, + pct: 0.9, + action: { tappedVal = value } + ) + .id(currency.noteBase + String(sourceID)) + .matchedGeometryEffect(id: String(sourceID), in: wrapper.namespace, isSource: true) + } + }.padding(.trailing, UIScreen.hasNotch ? UIScreen.horzInsets : 0) // ensure scrolling over the FaceID notch + } + .onAppear { + if scrollPosition > 0 { +// print(">>> OIMcurrencyScroller.onAppear scrolling to", scrollPosition, canEdit) + proxy.scrollTo(currency.noteBase + String(-Int(scrollPosition)), anchor: .leading) +// DispatchQueue.main.async { +// print(">>> OIMcurrencyScroller.onAppear scrolling AGAIN to", scrollPosition, canEdit) +// proxy.scrollTo(-Int(scrollPosition), anchor: .leading) +// } + debugTick += 1 + } else { // should only happen if available is zero + print("❗️❗️ OIMcurrencyScroller.onAppear scrolling to", scrollPosition, canEdit) // , stack.peek()?.file) + } + } + .task(id: taskID) { + if !canEdit && scrollPosition > 0 { + debugTick += 1 +// print(">>❗️ OIMcurrencyScroller.task", cash.currency.noteBase, availableVal, scrollPosition) + proxy.scrollTo(currency.noteBase + String(-Int(scrollPosition)), anchor: .leading) + debugTick += 1 + } + } + .viewExtractor { view in + if let scrollView = view as? UIScrollView { + if #available(iOS 17.4, *) { + scrollView.bouncesVertically = false + } else { // Fallback on earlier versions + scrollView.bounces = false + } + } + } + } + } +} diff --git a/TalerWallet1/Views/OIM/OIMcurrencyScroller.swift b/TalerWallet1/Views/OIM/OIMcurrencyScroller.swift @@ -1,93 +0,0 @@ -/* - * This file is part of GNU Taler, ©2022-25 Taler Systems S.A. - * See LICENSE.md - */ -/** - * @author Marc Stibane - */ -import SwiftUI -import taler_swift - -// renders all banknotes and coins in 1 horizontal scrollview -struct OIMcurrencyScroller: View { - let stack: CallStack - let cash: OIMcash - @Binding var availableVal: UInt64 - @Binding var tappedVal: UInt64 - let scrollPosition: UInt64 - let canEdit: Bool - - @EnvironmentObject private var wrapper: NamespaceWrapper - - var body: some View { - var debugTick = 0 -// let _ = Self._printChanges() - - let currency = cash.currency - let taskID = currency.noteBase + String(scrollPosition) - ScrollViewReader { proxy in - ScrollView(.horizontal) { - HStack(alignment: .bottom, spacing: 10) { - ForEach(currency.bankNotes, id: \.self) { value in - let sourceID = -Int(value) - let fund = OIMfund(id: sourceID, state: .idle, value: value, flippedVal: nil) - OIMcurrencyButton(stack: stack.push(), - fund: fund, - currency: currency, - availableVal: availableVal, - canEdit: canEdit, - pct: 0.9, - action: { tappedVal = value } - ) - .id(currency.noteBase + String(sourceID)) - .matchedGeometryEffect(id: String(sourceID), in: wrapper.namespace, isSource: true) - } - ForEach(currency.bankCoins, id: \.self) { value in - let sourceID = -Int(value) - let fund = OIMfund(id: sourceID, state: .idle, value: value, flippedVal: nil) - OIMcurrencyButton(stack: stack.push(), - fund: fund, - currency: currency, - availableVal: availableVal, - canEdit: canEdit, - pct: 0.9, - action: { tappedVal = value } - ) - .id(currency.noteBase + String(sourceID)) - .matchedGeometryEffect(id: String(sourceID), in: wrapper.namespace, isSource: true) - } - }.padding(.trailing, UIScreen.hasNotch ? UIScreen.horzInsets : 0) // ensure scrolling over the FaceID notch - } - .onAppear { - if scrollPosition > 0 { -// print(">>> OIMcurrencyScroller.onAppear scrolling to", scrollPosition, canEdit) - proxy.scrollTo(currency.noteBase + String(-Int(scrollPosition)), anchor: .leading) -// DispatchQueue.main.async { -// print(">>> OIMcurrencyScroller.onAppear scrolling AGAIN to", scrollPosition, canEdit) -// proxy.scrollTo(-Int(scrollPosition), anchor: .leading) -// } - debugTick += 1 - } else { // should only happen if available is zero - print("❗️❗️ OIMcurrencyScroller.onAppear scrolling to", scrollPosition, canEdit) // , stack.peek()?.file) - } - } - .task(id: taskID) { - if !canEdit && scrollPosition > 0 { - debugTick += 1 -// print(">>❗️ OIMcurrencyScroller.task", cash.currency.noteBase, availableVal, scrollPosition) - proxy.scrollTo(currency.noteBase + String(-Int(scrollPosition)), anchor: .leading) - debugTick += 1 - } - } - .viewExtractor { view in - if let scrollView = view as? UIScrollView { - if #available(iOS 17.4, *) { - scrollView.bouncesVertically = false - } else { // Fallback on earlier versions - scrollView.bounces = false - } - } - } - } - } -}