taler-ios

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

commit ee29984692835ed6d70b0c8d66950c83abf7f730
parent 81e160b603c3f07dadf0dc9e6b2717220e980fd7
Author: Marc Stibane <marc@taler.net>
Date:   Mon, 28 Apr 2025 01:12:58 +0200

OIMpayView

Diffstat:
MTalerWallet1/Views/OIM/OIMView.swift | 45---------------------------------------------
ATalerWallet1/Views/OIM/OIMpayView.swift | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MTalerWallet1/Views/Sheets/Payment/PaymentView.swift | 2+-
3 files changed, 60 insertions(+), 46 deletions(-)

diff --git a/TalerWallet1/Views/OIM/OIMView.swift b/TalerWallet1/Views/OIM/OIMView.swift @@ -160,44 +160,6 @@ struct OIMView: View { } // MARK: - @available(iOS 16.4, *) -struct OIMPayView: View { - let stack: CallStack - let amount: Amount? -// let decimal: Int // 0 for ¥,HUF; 2 for $,€,£; 3 for ﷼,₯ (arabic) - - @EnvironmentObject private var wrapper: NamespaceWrapper - @StateObject private var cash = OIMcash() - - @State private var amountVal: UInt64 = 0 - @State private var tappedVal: UInt64 = 0 - - var body: some View { -// let _ = Self._printChanges() - let currency = cash.currency - - OIMbackground() { - VStack { - Spacer() - OIMlineView(stack: stack.push(), - amountVal: $amountVal, - tappedVal: $tappedVal, - canEdit: true) - .matchedGeometryEffect(id: "OIMline", in: wrapper.namespace,isSource: true) - Spacer() - } -#if DEBUG - .border(.red) -#endif - } - .environmentObject(cash) - .task { - amountVal = intValue(amount) - } - - } -} -// MARK: - -@available(iOS 16.4, *) struct OIMEditView: View { let stack: CallStack @Binding var amount: Amount @@ -311,10 +273,3 @@ struct OIMSubjectView: View { } } } - - - -// MARK: - -//#Preview { -// OIMView() -//} diff --git a/TalerWallet1/Views/OIM/OIMpayView.swift b/TalerWallet1/Views/OIM/OIMpayView.swift @@ -0,0 +1,59 @@ +/* + * This file is part of GNU Taler, ©2022-25 Taler Systems S.A. + * See LICENSE.md + */ +/** + * @author Marc Stibane + */ +import SwiftUI +import taler_swift + +fileprivate func intValue(_ amount: Amount?) -> UInt64 { + if let amount { + if !amount.isZero { + let int = amount.integer * 100 // TODO: currency specs instead of 100 + let frac = amount.fraction / 1_000_000 // drop 6 zeroes + return int + UInt64(frac) + } + } + return 0 +} + +// MARK: - +@available(iOS 16.4, *) +struct OIMpayView: View { + let stack: CallStack + let amount: Amount? +// let decimal: Int // 0 for ¥,HUF; 2 for $,€,£; 3 for ﷼,₯ (arabic) + + @EnvironmentObject private var wrapper: NamespaceWrapper + + @StateObject private var cash = OIMcash() + @State private var amountVal: UInt64 = 0 + @State private var tappedVal: UInt64 = 0 + + var body: some View { +// let _ = Self._printChanges() + let currency = cash.currency + + OIMbackground() { + VStack { + Spacer() + OIMlineView(stack: stack.push(), + amountVal: $amountVal, + tappedVal: $tappedVal, + canEdit: true) + .matchedGeometryEffect(id: "OIMline", in: wrapper.namespace,isSource: true) + Spacer() + } +#if DEBUG + .border(.red) +#endif + } + .environmentObject(cash) + .task { + amountVal = intValue(amount) + } + + } +} diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift @@ -302,7 +302,7 @@ struct PaymentView: View, Sendable { .overlay { if #available(iOS 16.4, *) { if controller.oimSheetActive { - OIMPayView(stack: stack.push(), + OIMpayView(stack: stack.push(), amount: effective) } }