commit 8bcf88fd27528950b5ecc95cf0414ee8b10fc924
parent ac5aa3eed2ea4bff24f80d863ee1d52a0d156b4b
Author: Marc Stibane <marc@taler.net>
Date: Thu, 24 Apr 2025 10:25:13 +0200
remove OIM for iOS15
Diffstat:
7 files changed, 30 insertions(+), 283 deletions(-)
diff --git a/TalerWallet1/Views/Actions/Peer2peer/P2PSubjectV.swift b/TalerWallet1/Views/Actions/Peer2peer/P2PSubjectV.swift
@@ -178,6 +178,7 @@ struct P2PSubjectV: View {
scrollView
#if OIM
.overlay {
+ if #available(iOS 16.4, *) {
if controller.oimModeActive {
OIMSubjectView(stack: stack.push(),
scope: scope,
@@ -185,6 +186,7 @@ struct P2PSubjectV: View {
fwdButtonTapped: $sendOrRequest)
.environmentObject(NamespaceWrapper(namespace)) // keep OIMviews apart
}
+ }
}
#endif
}
diff --git a/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift b/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift
@@ -106,6 +106,7 @@ struct SendAmountV: View {
.task(id: balanceIndex + (1000 * controller.currencyTicker)) { await newBalance() }
#if OIM
.overlay {
+ if #available(iOS 16.4, *) {
if controller.oimModeActive {
OIMEditView(stack: stack.push(),
scope: balance?.scopeInfo,
@@ -115,6 +116,7 @@ struct SendAmountV: View {
fwdButtonTapped: $buttonSelected)
.environmentObject(NamespaceWrapper(namespace)) // keep OIMviews apart
}
+ }
}
#endif
if #available(iOS 16.4, *) {
diff --git a/TalerWallet1/Views/Balances/BalancesListView.swift b/TalerWallet1/Views/Balances/BalancesListView.swift
@@ -71,6 +71,7 @@ struct BalancesListView: View {
}
#if OIM
.overlay {
+ if #available(iOS 16.4, *) {
if controller.oimModeActive {
let balance = controller.balances.first
OIMView(stack: stack.push(),
@@ -79,6 +80,7 @@ struct BalancesListView: View {
qrButtonTapped: $qrButtonTapped)
.environmentObject(NamespaceWrapper(namespace)) // keep OIMviews apart
}
+ }
}
#endif
}
diff --git a/TalerWallet1/Views/OIM/OIM15Views.swift b/TalerWallet1/Views/OIM/OIM15Views.swift
@@ -1,190 +0,0 @@
-/*
- * This file is part of GNU Taler, ©2022-25 Taler Systems S.A.
- * See LICENSE.md
- */
-/**
- * @author Marc Stibane
- */
-import SwiftUI
-import SymLog
-//import taler_swift
-
-// These views are for iOS 15 only - remove once iOS 16 is the Minimum Deployment
-// MARK: -
-// renders a stack of (identical) banknotes with offset 10,20
-struct OIMnoteStackV: View {
- private let symLog = SymLogV(0)
- let stack: CallStack
- let value: UInt64
- let count: Int
- let currency: OIMcurrency
- let tappedVal: UInt64
- @Binding var flying: UInt64
- let canEdit: Bool
- let action: () -> Void
-
- @EnvironmentObject private var wrapper: NamespaceWrapper
-
- var body: some View {
-// let _ = Self._printChanges()
- let maxIndex = count - 1
- ZStack {
- ForEach(0...maxIndex, id: \.self) { index in
- let match = tappedVal == value && index == maxIndex
- let isFlying = flying > 0
- let matchNotFlying = match && !isFlying
- let isTarget = matchNotFlying // && isTop
- let targetID = isTarget ? String(-Int(value))
- : String(value) + "+" + String(index)
- let xOffset = CGFloat(10 * index)
- let yOffset = CGFloat(20 * index)
- let _ = print("targetID \(targetID), flying \(flying)")
- let fund = OIMfund(id: Int(value), state: .idle, value: value, flippedVal: nil)
- OIMcurrencyButton(stack: stack.push(),
-// value: value,
- fund: fund,
- currency: currency,
- availableVal: value,
- canEdit: canEdit,
-// isFlipped: false, // TODO: Flip coin
- pct: match ? 0.0 : 1.0,
- action: action)
- .offset(x: xOffset, y: yOffset)
- .matchedGeometryEffect(id: targetID, in: wrapper.namespace, isSource: false)
- .onAppear {
- print("start flying \(targetID)")
- withAnimation(.move1) {
- flying = value // start flying
- }
- }
- .zIndex(5)
- }
- }
- .padding(.trailing, CGFloat(10 * maxIndex))
- .padding(.bottom, CGFloat(20 * maxIndex))
- }
-}
-// MARK: -
-// renders a stack of (identical) coins with offset size/16
-struct OIMcoinStackV: View {
- let stack: CallStack
- let value: UInt64
- let count: Int
- let currency: OIMcurrency
- let tappedVal: UInt64
- @Binding var flying: UInt64
- let canEdit: Bool
- let action: () -> Void
-
- @EnvironmentObject private var wrapper: NamespaceWrapper
-
- var body: some View {
- let maxIndex = count - 1
- if let size = currency.coinSize(value) {
- let offset = size / 16
- ZStack {
- ForEach(0...maxIndex, id: \.self) { index in
- let match = tappedVal == value && index == maxIndex
- let isFlying = flying > 0
- let matchNotFlying = match && !isFlying
- let isTarget = matchNotFlying // && isTop
- let targetID = isTarget ? String(-Int(value))
- : String(value) + "+" + String(index)
- let yOffset = offset * CGFloat(index)
- let xOffset = yOffset / 2
- let _ = print("targetID \(targetID), flying \(flying)")
- let fund = OIMfund(id: Int(value), state: .idle, value: value, flippedVal: nil) // TODO: Flip coin
- OIMcurrencyButton(stack: stack.push(),
-// value: value,
- fund: fund,
- currency: currency,
- availableVal: value,
- canEdit: canEdit,
-// isFlipped: false, // TODO: Flip coin
- pct: match ? 0.0 : 1.0,
- action: action)
- .offset(x: xOffset, y: yOffset)
- .matchedGeometryEffect(id: targetID, in: wrapper.namespace, isSource: false)
- .onAppear {
- print("start flying \(targetID)")
- withAnimation(.move1) {
- flying = value // start flying
- }
- }
- .zIndex(5)
- }
- }
- .padding(.trailing, offset * CGFloat(maxIndex))
- .padding(.bottom, offset * CGFloat(maxIndex))
- }
- }
-}
-// MARK: -
-// renders a spread of banknote-stacks in 1 row
-struct OIMnotesView1: View {
- let stack: CallStack
- let spread: OIMdenominations
- let currency: OIMcurrency
- @Binding var amountVal: UInt64
- let tappedVal: UInt64
- @Binding var flying: UInt64
- let canEdit: Bool
-
- var body: some View {
-// let _ = Self._printChanges()
- let nrOfNotes = currency.bankNotes.count - 1
- HStack(alignment: .center, spacing: 10) {
- ForEach(0...nrOfNotes, id: \.self) { index in
- let value = currency.bankNotes[index]
- let shouldFly = tappedVal == value
- let count = spread[index] + (shouldFly ? 1 : 0)
- if count > 0 {
- OIMnoteStackV(stack: stack.push(),
- value: value,
- count: Int(count),
- currency: currency,
- tappedVal: tappedVal,
- flying: $flying,
- canEdit: canEdit
- ) {
- withAnimation(.easeOut1) {
- amountVal -= value // remove on button press
- } } }
- } // ForEach
- } // HStack
- }
-}
-// 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 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,
- canEdit: canEdit
- ) {
- withAnimation(.easeIn1) {
- amountVal -= value
- } } }
- } // ForEach
- } // HStack
- }
-}
diff --git a/TalerWallet1/Views/OIM/OIMView.swift b/TalerWallet1/Views/OIM/OIMView.swift
@@ -60,6 +60,7 @@ struct OIMnavBack<Content: View>: View {
}
}
// MARK: -
+@available(iOS 16.4, *)
struct OIMView: View {
let stack: CallStack
let scope: ScopeInfo?
@@ -159,6 +160,7 @@ struct OIMView: View {
}
}
// MARK: -
+@available(iOS 16.4, *)
struct OIMPayView: View {
let stack: CallStack
let scope: ScopeInfo?
@@ -197,6 +199,7 @@ struct OIMPayView: View {
}
}
// MARK: -
+@available(iOS 16.4, *)
struct OIMEditView: View {
let stack: CallStack
let scope: ScopeInfo?
diff --git a/TalerWallet1/Views/OIM/OIMlineView.swift b/TalerWallet1/Views/OIM/OIMlineView.swift
@@ -12,6 +12,7 @@ import SymLog
fileprivate let horzSpacing: CGFloat = 20
fileprivate let vertSpacing: CGFloat = 10
+@available(iOS 16.4, *)
struct OIMlineView: View {
private let symLog = SymLogV(0)
let stack: CallStack
@@ -35,86 +36,27 @@ struct OIMlineView: View {
let blue = debug ? Color.blue : Color.clear
let orange = debug ? Color.orange : Color.clear
#endif
- let currency = cash.currency
- Group {
- if #available(iOS 16.4, *) {
- let notes = OIMlayoutView(stack: stack.push(),
- funds: cash.notes(),
- amountVal: $amountVal,
- canEdit: canEdit)
- let coins = OIMlayoutView(stack: stack.push(),
- funds: cash.coins(),
- amountVal: $amountVal,
- canEdit: canEdit)
- LayoutThatFits([HStackLayout(alignment: .center), VStackLayout()]) {
- notes
-#if DEBUG
- .padding(1)
- .border(green)
-#endif
- coins
- }
+ let notes = OIMlayoutView(stack: stack.push(),
+ funds: cash.notes(),
+ amountVal: $amountVal,
+ canEdit: canEdit)
+ let coins = OIMlayoutView(stack: stack.push(),
+ funds: cash.coins(),
+ amountVal: $amountVal,
+ canEdit: canEdit)
+ LayoutThatFits([HStackLayout(alignment: .center), VStackLayout()]) {
+ notes
#if DEBUG
.padding(1)
- .border(orange)
-#endif
- } else { // iOS 15
- let result = currency.notesCoins(amountVal)
- // Text("notes: \(result.0), coins: \(result.1)")
- let notes = OIMnotesView1(stack: stack.push(),
- spread: result.0,
- currency: currency,
- amountVal: $amountVal,
- tappedVal: myTappedVal,
- flying: $flying,
- canEdit: canEdit
- ).id("notes")
- .matchedGeometryEffect(id: "notes", in: wrapper.namespace)
-#if DEBUG
- .border(blue)
+ .border(green)
#endif
- let coins = OIMcoinsView1(stack: stack.push(),
- spread: result.1,
- currency: currency,
- amountVal: $amountVal,
- tappedVal: myTappedVal,
- flying: $flying,
- canEdit: canEdit
- ).id("coins")
- .matchedGeometryEffect(id: "coins", in: wrapper.namespace)
-#if DEBUG
- .border(red)
-#endif
-
- ScrollView(.horizontal) {
- if oimTwoRows {
- VStack(spacing: vertSpacing) {
- notes
- coins
- }
-#if DEBUG
- .padding(1)
- .border(green)
-#endif
- } else {
- HStack(alignment: .center, spacing: horzSpacing) {
- notes
- coins
- }
-#if DEBUG
- .padding(1)
- .border(green)
-#endif
- }
- }
+ coins
+ }
#if DEBUG
- .padding(1)
- .border(orange)
+ .padding(1)
+ .border(orange)
#endif
- .clipped()
- } // iOS 15
- }
.onChange(of: tappedVal) { newVal in
if newVal > 0 {
symLog.log(">>tapped \(newVal)")
@@ -122,25 +64,9 @@ struct OIMlineView: View {
DispatchQueue.main.async { // next layout cycle
withAnimation(.move1) {
- if #available(iOS 16.0, *) {
- symLog.log(">>addCash \(newVal)")
- cash.addCash(value: newVal)
- amountVal += newVal // update directly
- } else {
- symLog.log("\n>>start flying \(newVal) \(flying)")
- myTappedVal = newVal
- }
- }
- if #unavailable(iOS 16.0) {
- symLog.log("\n>>reset flying \(newVal) \(flying)")
- flying = 0 // remove immediately after it flew in, but outside of the animation block
- DispatchQueue.main.asyncAfter(deadline: .now() + cash.delay) {
- symLog.log("\n>>dissolve \(newVal) \(flying)")
- withAnimation(.basic1) {
- amountVal += newVal // update after value flew in
- myTappedVal = 0
- }
- }
+ symLog.log(">>addCash \(newVal)")
+ cash.addCash(value: newVal)
+ amountVal += newVal // update directly
}
}
}
diff --git a/TalerWallet1/Views/Sheets/Payment/PaymentView.swift b/TalerWallet1/Views/Sheets/Payment/PaymentView.swift
@@ -300,9 +300,11 @@ struct PaymentView: View, Sendable {
}
#if OIM
.overlay {
+ if #available(iOS 16.4, *) {
if controller.oimSheetActive {
OIMPayView(stack: stack.push(), scope: firstScope, amount: effective)
}
+ }
}
#endif
} else {