taler-ios

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

commit 1aa887f015c75dfd06038a666de0ba2a9e93f429
parent d71c88fd9f1e610fe0780097a6aa924800c97413
Author: Marc Stibane <marc@taler.net>
Date:   Sat, 17 May 2025 16:45:07 +0200

Two lines of goals

Diffstat:
DTalerWallet1/Assets.xcassets/OIM-buttons/Goal.imageset/Contents.json | 15---------------
DTalerWallet1/Assets.xcassets/OIM-buttons/Goal.imageset/T25 Goal left.png | 0
MTalerWallet1/Views/Actions/Peer2peer/P2PSubjectV.swift | 3+--
MTalerWallet1/Views/OIM/OIMEditView.swift | 19+++++++++++--------
MTalerWallet1/Views/OIM/OIMSubjectView.swift | 85++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
MTalerWallet1/Views/OIM/OIMView.swift | 18+++++++-----------
MTalerWallet1/Views/OIM/OIMactionButtons.swift | 16+++++++---------
7 files changed, 73 insertions(+), 83 deletions(-)

diff --git a/TalerWallet1/Assets.xcassets/OIM-buttons/Goal.imageset/Contents.json b/TalerWallet1/Assets.xcassets/OIM-buttons/Goal.imageset/Contents.json @@ -1,15 +0,0 @@ -{ - "images" : [ - { - "filename" : "T25 Goal left.png", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - }, - "properties" : { - "template-rendering-intent" : "template" - } -} diff --git a/TalerWallet1/Assets.xcassets/OIM-buttons/Goal.imageset/T25 Goal left.png b/TalerWallet1/Assets.xcassets/OIM-buttons/Goal.imageset/T25 Goal left.png Binary files differ. diff --git a/TalerWallet1/Views/Actions/Peer2peer/P2PSubjectV.swift b/TalerWallet1/Views/Actions/Peer2peer/P2PSubjectV.swift @@ -188,8 +188,7 @@ struct P2PSubjectV: View { available: available, amount: $amountToTransfer, selectedGoal: $iconID, - fwdButtonTapped: $sendOrRequest, - randomGoal: Bool.random()) + fwdButtonTapped: $sendOrRequest) .environmentObject(NamespaceWrapper(namespace)) // keep OIMviews apart } } } diff --git a/TalerWallet1/Views/OIM/OIMEditView.swift b/TalerWallet1/Views/OIM/OIMEditView.swift @@ -21,6 +21,7 @@ struct OIMEditView: View { @EnvironmentObject private var wrapper: NamespaceWrapper + @State private var amount2: Amount? @State private var amountVal: UInt64 = 0 @State private var sending = false // user tapped on Send @State private var availableVal: UInt64 = 0 @@ -82,16 +83,15 @@ struct OIMEditView: View { OIMnavBack(stack: stack.push(), currencyName: noteBase, isFinal: false, - isGoal: true, isSierra: isSierra, isSending: sending, - amount: $amount, + amount: $amount2, action: sendAction ) { ZStack(alignment: .top) { VStack { // OIMtitleView(cash: cash, amount: availRest, isSending: true, secondAmount: amount) - OIMtitleView(cash: cash, amount: available, isSending: true, secondAmount: amount) + OIMtitleView(cash: cash, amount: available, isSending: true, secondAmount: amount2) Spacer() OIMlineView(stack: stack.push(), cash: cash, @@ -102,10 +102,12 @@ struct OIMEditView: View { .zIndex(1) // make notes fly from topZ .scaleEffect(sending ? 0.6 : 1.0) .onChange(of: amountVal) { newVal in - let currencyStr = amount.currencyStr - amount = Amount(currency: currencyStr, cent: UInt64(newVal)) - availableVal = isAvailable - availRest = Amount(currency: currencyStr, cent: UInt64(availableVal)) + if let amountOld = amount2 { + let currencyStr = amountOld.currencyStr + amount2 = Amount(currency: currencyStr, cent: UInt64(newVal)) + availableVal = isAvailable + availRest = Amount(currency: currencyStr, cent: UInt64(availableVal)) + } } if !sending { // need space for currency scroller Spacer() @@ -130,7 +132,8 @@ struct OIMEditView: View { // .border(.red) } // ZStack } - .task { + .task { // re-set cash to amount (once) + amount2 = amount amountVal = amount.centValue availableVal = isAvailable // print("OIMEditView.task", availableVal, amountVal) diff --git a/TalerWallet1/Views/OIM/OIMSubjectView.swift b/TalerWallet1/Views/OIM/OIMSubjectView.swift @@ -8,6 +8,44 @@ import SwiftUI import taler_swift +struct GoalsHStack: View { + let goals: [String] + @Binding var selectedGoal: String? + + @EnvironmentObject private var wrapper: NamespaceWrapper + + var body: some View { + HStack { + ForEach(goals, id: \.self) { goal in + if let selectedGoal { + if goal == selectedGoal { + Image(goal) + .resizable() + .background(Color.white) + .scaledToFit() + .matchedGeometryEffect(id: goal, in: wrapper.namespace) + .onTapGesture { + withAnimation(.basic1) { + self.selectedGoal = nil + } + } + } + } else { + Image(goal) + .resizable() + .background(Color.white) + .scaledToFit() + .matchedGeometryEffect(id: goal, in: wrapper.namespace) + .onTapGesture { + withAnimation(.basic1) { + selectedGoal = goal + } + } + } + } + } + } +} // MARK: - @available(iOS 16.4, *) struct OIMSubjectView: View { @@ -18,10 +56,10 @@ struct OIMSubjectView: View { @Binding var selectedGoal: String? // let decimal: Int // 0 for ¥,HUF; 2 for $,€,£; 3 for ﷼,₯ (arabic) @Binding var fwdButtonTapped: Bool - let randomGoal: Bool @EnvironmentObject private var wrapper: NamespaceWrapper + @State private var amount2: Amount? = nil @State private var amountVal: UInt64 = 0 @State private var sending = false // user tapped on Send @State private var appeared = false @@ -49,50 +87,20 @@ struct OIMSubjectView: View { OIMnavBack(stack: stack.push(), currencyName: noteBase, isFinal: false, - isGoal: false, isSierra: isSierra, isSending: sending, - amount: $amount, + amount: $amount2, action: sendAction ) { VStack { OIMtitleView(cash: cash, amount: available, isSending: true, secondAmount: amount) Spacer() - HStack { - let goals = randomGoal ? goals1 : goals2 - ForEach(goals, id: \.self) { goal in - if let selectedGoal { - if goal == selectedGoal { - Image(goal) - .resizable() - .background(Color.white) - .scaledToFit() -// .id(goal) - .matchedGeometryEffect(id: goal, in: wrapper.namespace) - .onTapGesture { - withAnimation(.basic1) { - self.selectedGoal = nil - } - } - } - } else { - Image(goal) - .resizable() - .background(Color.white) - .scaledToFit() -// .id(goal) - .matchedGeometryEffect(id: goal, in: wrapper.namespace) - .onTapGesture { - withAnimation(.basic1) { - selectedGoal = goal - } - } - } - } - } - .opacity(appeared ? 1.0 : 0.01) - .scaleEffect(appeared ? 1.0 : 0.3) - + GoalsHStack(goals: goals1, selectedGoal: $selectedGoal) + .opacity(appeared ? 1.0 : 0.01) + .scaleEffect(appeared ? 1.0 : 0.3) + GoalsHStack(goals: goals2, selectedGoal: $selectedGoal) + .opacity(appeared ? 1.0 : 0.01) + .scaleEffect(appeared ? 1.0 : 0.3) Spacer() OIMlineView(stack: stack.push(), cash: cash, @@ -103,6 +111,7 @@ struct OIMSubjectView: View { } // .border(.red) }.task { + amount2 = amount amountVal = amount.centValue withAnimation(.basic1) { appeared = true diff --git a/TalerWallet1/Views/OIM/OIMView.swift b/TalerWallet1/Views/OIM/OIMView.swift @@ -15,12 +15,11 @@ let OIMactionSize = 120.0 struct OIMnavBack<Content: View>: View { let stack: CallStack let currencyName: String - let isFinal: Bool - let isGoal: Bool + let isFinal: Bool // bordered action button let isSierra: Bool - let isSending: Bool - @Binding var amount: Amount - let action: () -> Void + let isSending: Bool // move action button + @Binding var amount: Amount? + let action: (() -> Void)? var content: () -> Content @Environment(\.dismiss) var dismiss // pop back once @@ -41,9 +40,8 @@ struct OIMnavBack<Content: View>: View { } .frame(width: OIMbuttonSize, height: OIMbuttonSize) Spacer() - OIMactionButton(type: isGoal ? .goal : .sendP2P, + OIMactionButton(type: .sendP2P, isFinal: isFinal, - enabled: !amount.isZero, action: action) .frame(width: OIMbuttonSize, height: OIMbuttonSize) .matchedGeometryEffect(id: isSending ? "OIMaction" : "OIMaction2", @@ -81,7 +79,7 @@ struct OIMtitleView: View { OIMamountV(amount: secondAmount, currencyName: cash.currency.noteBase) } - OIMactionButton(type: .sendP2P, isFinal: false, enabled: false) {} + OIMactionButton(type: .sendP2P, isFinal: false) {} .frame(width: OIMbuttonSize, height: OIMbuttonSize) .disabled(true) .opacity(0.01) @@ -175,10 +173,8 @@ struct OIMView: View { case .withdrawal: noAction case .deposit: noAction case .requestP2P: noAction - case .goal: noAction } - OIMactionButton(type: button, isFinal: false, - enabled: true, action: action) + OIMactionButton(type: button, isFinal: false, action: action) .frame(width: OIMactionSize, height: OIMactionSize) Spacer() } diff --git a/TalerWallet1/Views/OIM/OIMactionButtons.swift b/TalerWallet1/Views/OIM/OIMactionButtons.swift @@ -12,34 +12,32 @@ enum OIMactions { case deposit case sendP2P case requestP2P - case goal +// case goal // case scanQR } struct OIMactionButton: View { let type: OIMactions let isFinal: Bool - let enabled: Bool - let action: () -> Void + let action: (() -> Void)? var body: some View { let imageName = switch type { - case .goal: "Goal" case .sendP2P : "SendMoney" // "SendTaler" case .withdrawal: "Withdraw" case .deposit: "Deposit" case .requestP2P: "Request" } - Button(action: action) { + let disabled = action == nil + Button(action: action ?? { } ) { Image(imageName) .resizable() .scaledToFit() -// .tint(WalletColors().talerColor) .foregroundStyle(WalletColors().talerColor) } - .tagStyle(isFinal ? .bordered : .borderless) - .opacity(enabled ? 1.0 : 0.01) - .disabled(!enabled) + .tagStyle(isFinal ? .bordered : .borderless) + .opacity(disabled ? 0.01 : 1.0) + .disabled(disabled) } }