taler-ios

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

commit 41780f096a4e3e68efc07eed7bce1b6af8c524ef
parent f59d556a29ffa55e5ba490caff815a0f2895f507
Author: Marc Stibane <marc@taler.net>
Date:   Fri,  9 May 2025 21:35:49 +0000

iconID

Diffstat:
MTalerWallet1/Views/Actions/Peer2peer/P2PReadyV.swift | 3++-
MTalerWallet1/Views/Actions/Peer2peer/P2PSubjectV.swift | 6+++++-
MTalerWallet1/Views/Actions/Peer2peer/RequestPayment.swift | 11+++++++++--
MTalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift | 12+++++++++---
MTalerWallet1/Views/Actions/Peer2peer/SendAmountView.swift | 3+++
MTalerWallet1/Views/Main/MainView.swift | 9++++++---
MTalerWallet1/Views/OIM/OIMSubjectView.swift | 9++++++---
7 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/TalerWallet1/Views/Actions/Peer2peer/P2PReadyV.swift b/TalerWallet1/Views/Actions/Peer2peer/P2PReadyV.swift @@ -15,6 +15,7 @@ struct P2PReadyV: View { let stack: CallStack let scope: ScopeInfo let summary: String + let iconID: String? let expireDays: UInt let outgoing: Bool let amountToTransfer: Amount @@ -50,7 +51,7 @@ struct P2PReadyV: View { let terms = PeerContractTerms(amount: amountToTransfer, summary: summary, purse_expiration: timestamp, - icon_id: nil) + icon_id: iconID) if outgoing { // TODO: let user choose baseURL if let response = try? await model.initiatePeerPushDebit(scope: scope, terms: terms) { diff --git a/TalerWallet1/Views/Actions/Peer2peer/P2PSubjectV.swift b/TalerWallet1/Views/Actions/Peer2peer/P2PSubjectV.swift @@ -29,6 +29,7 @@ struct P2PSubjectV: View { let outgoing: Bool @Binding var amountToTransfer: Amount @Binding var summary: String + @Binding var iconID: String? @Binding var expireDays: UInt @EnvironmentObject private var controller: Controller @@ -146,6 +147,7 @@ struct P2PSubjectV: View { let destination = P2PReadyV(stack: stack.push(), scope: scope, summary: summary.count > 0 ? summary : placeHolder, + iconID: iconID, expireDays: expireDays, outgoing: outgoing, amountToTransfer: amountToTransfer, @@ -185,7 +187,9 @@ struct P2PSubjectV: View { cash: cash, available: available, amount: $amountToTransfer, - fwdButtonTapped: $sendOrRequest) + selectedGoal: $iconID, + fwdButtonTapped: $sendOrRequest, + randomGoal: Bool.random()) .environmentObject(NamespaceWrapper(namespace)) // keep OIMviews apart } } } diff --git a/TalerWallet1/Views/Actions/Peer2peer/RequestPayment.swift b/TalerWallet1/Views/Actions/Peer2peer/RequestPayment.swift @@ -16,6 +16,7 @@ struct RequestPayment: View { let selectedBalance: Balance? @Binding var amountLastUsed: Amount @Binding var summary: String + @Binding var iconID: String? @EnvironmentObject private var controller: Controller @@ -31,7 +32,8 @@ struct RequestPayment: View { selectedBalance: Balance?, selectedIndex: Int?, amountLastUsed: Binding<Amount>, - summary: Binding<String> + summary: Binding<String>, + iconID: Binding<String?> ) { // SwiftUI ensures that the initialization uses the // closure only once during the lifetime of the view, so @@ -40,6 +42,7 @@ struct RequestPayment: View { self.selectedBalance = selectedBalance self._amountLastUsed = amountLastUsed self._summary = summary + self._iconID = iconID //#if OIM let currency = selectedIndex == 1 ? OIMleones : OIMeuros self._cash = StateObject(wrappedValue: { OIMcash(currency) }()) @@ -102,7 +105,8 @@ struct RequestPayment: View { balance: balance, amountLastUsed: $amountLastUsed, amountToTransfer: $amountToTransfer, - summary: $summary) + summary: $summary, + iconID: $iconID) } else { // TODO: Error no balance - Yikes Text("No balance. There seems to be a problem with the database...") } @@ -130,6 +134,7 @@ struct RequestPaymentContent: View { @Binding var amountLastUsed: Amount @Binding var amountToTransfer: Amount @Binding var summary: String + @Binding var iconID: String? @EnvironmentObject private var controller: Controller @EnvironmentObject private var model: WalletModel @@ -258,6 +263,7 @@ struct RequestPaymentContent: View { outgoing: false, amountToTransfer: $amountToTransfer, summary: $summary, + iconID: $iconID, expireDays: $expireDays) let shortcutDestination = P2PSubjectV(stack: stack.push(), cash: cash, @@ -268,6 +274,7 @@ struct RequestPaymentContent: View { outgoing: false, amountToTransfer: $amountShortcut, summary: $summary, + iconID: $iconID, expireDays: $expireDays) let actions = Group { NavLink($buttonSelected) { inputDestination } diff --git a/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift b/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift @@ -16,6 +16,7 @@ struct SendAmountV: View { let selectedBalance: Balance? // coming from transaction list or OIM @Binding var amountLastUsed: Amount @Binding var summary: String + @Binding var iconID: String? @EnvironmentObject private var controller: Controller @EnvironmentObject private var model: WalletModel @@ -35,7 +36,8 @@ struct SendAmountV: View { selectedBalance: Balance?, selectedIndex: Int?, amountLastUsed: Binding<Amount>, - summary: Binding<String> + summary: Binding<String>, + iconID: Binding<String?> ) { // SwiftUI ensures that the initialization uses the // closure only once during the lifetime of the view, so @@ -44,6 +46,7 @@ struct SendAmountV: View { self.selectedBalance = selectedBalance self._amountLastUsed = amountLastUsed self._summary = summary + self._iconID = iconID //#if OIM let currency = selectedIndex == 1 ? OIMleones : OIMeuros self._cash = StateObject(wrappedValue: { OIMcash(currency) }()) @@ -118,7 +121,8 @@ struct SendAmountV: View { amountLastUsed: $amountLastUsed, amountToTransfer: $amountToTransfer, amountAvailable: $amountAvailable, - summary: $summary) + summary: $summary, + iconID: $iconID) } else { // TODO: Error no balance - Yikes Text("No balance. There seems to be a problem with the database...") } @@ -163,6 +167,7 @@ struct SendAmountV: View { fileprivate struct Preview_Content: View { @State private var amountToPreview = Amount(currency: DEMOCURRENCY, cent: 510) @State private var summary: String = EMPTYSTRING + @State private var iconID: String? = nil @State private var currencyInfoL: CurrencyInfo = CurrencyInfo.zero(DEMOCURRENCY) @State private var noBalance: Balance? = nil @@ -187,7 +192,8 @@ fileprivate struct Preview_Content: View { selectedBalance: noBalance, selectedIndex: nil, amountLastUsed: $amountToPreview, - summary: $summary) + summary: $summary, + iconID: $iconID) } } diff --git a/TalerWallet1/Views/Actions/Peer2peer/SendAmountView.swift b/TalerWallet1/Views/Actions/Peer2peer/SendAmountView.swift @@ -20,6 +20,7 @@ struct SendAmountView: View { @Binding var amountToTransfer: Amount @Binding var amountAvailable: Amount @Binding var summary: String + @Binding var iconID: String? @EnvironmentObject private var controller: Controller @EnvironmentObject private var model: WalletModel @@ -150,6 +151,7 @@ struct SendAmountView: View { outgoing: true, amountToTransfer: $amountToTransfer, // from the textedit summary: $summary, + iconID: $iconID, expireDays: $expireDays) let shortcutDestination = P2PSubjectV(stack: stack.push(), cash: cash, @@ -160,6 +162,7 @@ struct SendAmountView: View { outgoing: true, amountToTransfer: $amountShortcut, // from the tapped shortcut button summary: $summary, + iconID: $iconID, expireDays: $expireDays) let actions = Group { NavLink($buttonSelected) { inputDestination } diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift @@ -296,6 +296,7 @@ extension MainView { @State private var amountToTransfer = Amount.zero(currency: EMPTYSTRING) // Update currency when used @State private var amountLastUsed = Amount.zero(currency: EMPTYSTRING) // Update currency when used @State private var summary: String = EMPTYSTRING + @State private var iconID: String? = nil private var openKycButton: some View { Button("KYC") { @@ -352,12 +353,14 @@ extension MainView { selectedBalance: selectedBalance, // if nil shows currency picker selectedIndex: selectedIndex, // selected savings box from OIMview amountLastUsed: $amountLastUsed, // currency needs to be updated! - summary: $summary) + summary: $summary, + iconID: $iconID) let requestDest = RequestPayment(stack: stack.push(Self.name), selectedBalance: selectedBalance, - selectedIndex: selectedIndex, // selected savings box from OIMview + selectedIndex: selectedIndex, // selected savings box from OIMview amountLastUsed: $amountLastUsed, // currency needs to be updated! - summary: $summary) + summary: $summary, + iconID: $iconID) let depositDest = DepositSelectV(stack: stack.push(Self.name), selectedBalance: selectedBalance, amountLastUsed: $amountLastUsed) diff --git a/TalerWallet1/Views/OIM/OIMSubjectView.swift b/TalerWallet1/Views/OIM/OIMSubjectView.swift @@ -15,8 +15,10 @@ struct OIMSubjectView: View { let cash: OIMcash let available: Amount @Binding var amount: Amount + @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 @@ -24,8 +26,6 @@ struct OIMSubjectView: View { @State private var sending = false // user tapped on Send @State private var appeared = false @State private var ignoreTapped: UInt64 = 0 - @State private var selectedGoal: String? - let goals = ["Buy goods in shop", "Rent", "Schooling", "Repay loan", "Medical or health issue"] func sendAction() { withAnimation(.basic1) { @@ -43,10 +43,12 @@ struct OIMSubjectView: View { let currency = cash.currency let noteBase = currency.noteBase let isSierra = noteBase == "SLE" + let goals1 = ["shopping", "Rent", "Schooling", "Repay loan", "Medical"].shuffled() + let goals2 = ["Phone", "Electricity", "gas pump", "Hammer", "Water"].shuffled() OIMnavBack(stack: stack.push(), currencyName: noteBase, - isFinal: true, + isFinal: false, isGoal: false, isSierra: isSierra, isSending: sending, @@ -57,6 +59,7 @@ struct OIMSubjectView: View { 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 {