taler-ios

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

commit c3931a39adeddb2d16fb19d54da5b3d48d017e59
parent 6591f07e94b8361d94dee0174816181f8f6f14b7
Author: Marc Stibane <marc@taler.net>
Date:   Mon,  9 Dec 2024 20:09:47 +0100

Iban -> Select

Diffstat:
MTalerWallet.xcodeproj/project.pbxproj | 12++++++------
MTalerWallet1/Views/Actions/Banking/DepositAmountV.swift | 14+++++++-------
DTalerWallet1/Views/Actions/Banking/DepositIbanV.swift | 130-------------------------------------------------------------------------------
ATalerWallet1/Views/Actions/Banking/DepositSelectV.swift | 131+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MTalerWallet1/Views/Main/MainView.swift | 6+++---
5 files changed, 147 insertions(+), 146 deletions(-)

diff --git a/TalerWallet.xcodeproj/project.pbxproj b/TalerWallet.xcodeproj/project.pbxproj @@ -267,8 +267,8 @@ 4EBA563F2A7FD9390084948B /* SuperScriptDigits.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EBA563E2A7FD9390084948B /* SuperScriptDigits.swift */; }; 4EBA82AB2A3EB2CA00E5F39A /* TransactionButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EBA82AA2A3EB2CA00E5F39A /* TransactionButton.swift */; }; 4EBA82AD2A3F580500E5F39A /* QuiteSomeCoins.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EBA82AC2A3F580500E5F39A /* QuiteSomeCoins.swift */; }; - 4EBC0F012B7B3CD600C0CB19 /* DepositIbanV.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EBC0F002B7B3CD600C0CB19 /* DepositIbanV.swift */; }; - 4EBC0F022B7B3CD600C0CB19 /* DepositIbanV.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EBC0F002B7B3CD600C0CB19 /* DepositIbanV.swift */; }; + 4EBC0F012B7B3CD600C0CB19 /* DepositSelectV.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EBC0F002B7B3CD600C0CB19 /* DepositSelectV.swift */; }; + 4EBC0F022B7B3CD600C0CB19 /* DepositSelectV.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EBC0F002B7B3CD600C0CB19 /* DepositSelectV.swift */; }; 4EC400892AE3E7E800DF72C7 /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EC400882AE3E7E800DF72C7 /* AboutView.swift */; }; 4EC4008A2AE3E7E800DF72C7 /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EC400882AE3E7E800DF72C7 /* AboutView.swift */; }; 4EC4008C2AE5664100DF72C7 /* CharacterSet+contains.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EC4008B2AE5664100DF72C7 /* CharacterSet+contains.swift */; }; @@ -495,7 +495,7 @@ 4EBA563E2A7FD9390084948B /* SuperScriptDigits.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SuperScriptDigits.swift; sourceTree = "<group>"; }; 4EBA82AA2A3EB2CA00E5F39A /* TransactionButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransactionButton.swift; sourceTree = "<group>"; }; 4EBA82AC2A3F580500E5F39A /* QuiteSomeCoins.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuiteSomeCoins.swift; sourceTree = "<group>"; }; - 4EBC0F002B7B3CD600C0CB19 /* DepositIbanV.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DepositIbanV.swift; sourceTree = "<group>"; }; + 4EBC0F002B7B3CD600C0CB19 /* DepositSelectV.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DepositSelectV.swift; sourceTree = "<group>"; }; 4EC400882AE3E7E800DF72C7 /* AboutView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = "<group>"; }; 4EC4008B2AE5664100DF72C7 /* CharacterSet+contains.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CharacterSet+contains.swift"; sourceTree = "<group>"; }; 4EC4008E2AE8019700DF72C7 /* ExchangeRowView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExchangeRowView.swift; sourceTree = "<group>"; }; @@ -946,7 +946,7 @@ 4EFDC38E2CBE8D4E00BE8DBC /* Banking */ = { isa = PBXGroup; children = ( - 4EBC0F002B7B3CD600C0CB19 /* DepositIbanV.swift */, + 4EBC0F002B7B3CD600C0CB19 /* DepositSelectV.swift */, 4E96583B2B79656E00404A68 /* DepositAmountV.swift */, 4EE9864E2CE26E0F00F75634 /* DepositAmountView.swift */, 4E50B34F2A1BEE8000F9F01C /* ManualWithdraw.swift */, @@ -1259,7 +1259,7 @@ 4E4A3F0B2CD4B6CD00CA6A90 /* View+NavLink.swift in Sources */, 4E448AB72C4A4109007D5C92 /* BalancesPendingRowV.swift in Sources */, 4E3EAE2D2A990778009F1BE8 /* Model+Exchange.swift in Sources */, - 4EBC0F012B7B3CD600C0CB19 /* DepositIbanV.swift in Sources */, + 4EBC0F012B7B3CD600C0CB19 /* DepositSelectV.swift in Sources */, 4E3EAE2E2A990778009F1BE8 /* QRCodeDetailView.swift in Sources */, 4E3EAE2F2A990778009F1BE8 /* TransactionsEmptyView.swift in Sources */, 4EEBEFB02C8982180020D340 /* View+innerSize.swift in Sources */, @@ -1398,7 +1398,7 @@ 4E4A3F0C2CD4B6CD00CA6A90 /* View+NavLink.swift in Sources */, 4E448AB82C4A4109007D5C92 /* BalancesPendingRowV.swift in Sources */, 4E3B4BC92A42BC4800CC88B8 /* Model+Exchange.swift in Sources */, - 4EBC0F022B7B3CD600C0CB19 /* DepositIbanV.swift in Sources */, + 4EBC0F022B7B3CD600C0CB19 /* DepositSelectV.swift in Sources */, 4E5A88F52A38A4FD00072618 /* QRCodeDetailView.swift in Sources */, 4E87C8732A31CB7F001C6406 /* TransactionsEmptyView.swift in Sources */, 4EEBEFB12C8982180020D340 /* View+innerSize.swift in Sources */, diff --git a/TalerWallet1/Views/Actions/Banking/DepositAmountV.swift b/TalerWallet1/Views/Actions/Banking/DepositAmountV.swift @@ -9,7 +9,7 @@ import SwiftUI import taler_swift import SymLog -// Called from DepositIbanV +// Called from DepositSelectV struct DepositAmountV: View { private let symLog = SymLogV(0) let stack: CallStack @@ -83,12 +83,12 @@ struct DepositAmountV: View { .padding(.bottom, 4) } DepositAmountView(stack: stack.push(), - balance: $balance, - balanceIndex: $balanceIndex, - amountLastUsed: $amountLastUsed, - amountToTransfer: $amountToTransfer, - amountAvailable: amountAvailable, - paytoUri: paytoUri) + balance: $balance, + balanceIndex: $balanceIndex, + amountLastUsed: $amountLastUsed, + amountToTransfer: $amountToTransfer, + amountAvailable: amountAvailable, + paytoUri: paytoUri) } // ScrollView .navigationTitle(navTitle) .frame(maxWidth: .infinity, alignment: .leading) diff --git a/TalerWallet1/Views/Actions/Banking/DepositIbanV.swift b/TalerWallet1/Views/Actions/Banking/DepositIbanV.swift @@ -1,130 +0,0 @@ -/* - * This file is part of GNU Taler, ©2022-24 Taler Systems S.A. - * See LICENSE.md - */ -/** - * @author Marc Stibane - */ -import SwiftUI -import taler_swift -import SymLog - -// Called when tapping [􁾩Deposit] -struct DepositIbanV: View { - private let symLog = SymLogV(0) - let stack: CallStack - @Binding var selectedBalance: Balance? - @Binding var amountLastUsed: Amount - -// let amountAvailable: Amount? -// @Binding var depositIBAN: String - - @EnvironmentObject private var controller: Controller - @EnvironmentObject private var model: WalletModel - @Environment(\.colorScheme) private var colorScheme - @Environment(\.colorSchemeContrast) private var colorSchemeContrast - @AppStorage("minimalistic") var minimalistic: Bool = false - @AppStorage("depositIBAN") var depositIBAN: String = EMPTYSTRING - @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic - - @State private var myFeeLabel: String = EMPTYSTRING - @State private var transactionStarted: Bool = false - @FocusState private var isFocused: Bool - @State private var currencyName: String = UNKNOWN - @State private var currencySymbol: String = UNKNOWN - @State private var amountAvailable = Amount.zero(currency: EMPTYSTRING) // Update currency when used - @State private var amountToTransfer = Amount.zero(currency: EMPTYSTRING) // Update currency when used - @State private var bankAccounts: [BankAccountsInfo] = [] - - - private var subjectTitle: String { - return String(localized: "NavTitle_Deposit_AmountStr", - defaultValue: "Select account", - comment: "NavTitle: Deposit") - } - - @MainActor - private func viewDidLoad() async { - if let accounts = try? await model.listBankAccounts() { - withAnimation { bankAccounts = accounts } - } - } - - var body: some View { -#if PRINT_CHANGES - let _ = Self._printChanges() - let _ = symLog.vlog(amountToTransfer.readableDescription) // just to get the # -#endif - let depositHint = Text("You can only deposit to a bank account that you control, otherwise you will not be able to fulfill the regulatory requirements.") - - List { - Section { - depositHint - } - Section { - if bankAccounts.isEmpty { - let bankAccountsTitle = String(localized: "TitleBankAccounts", defaultValue: "Bank Accounts") - let bankAccountsDest = BankListView(stack: stack.push(bankAccountsTitle), - navTitle: bankAccountsTitle) - NavigationLink { // whole row like in a tableView - bankAccountsDest - } label: { - SettingsItem(name: bankAccountsTitle, id1: "bankAccounts", - description: minimalistic ? nil : String(localized: "Your accounts for deposit...")) {} - } - } else { - ForEach(bankAccounts, id: \.self) { account in -// let disabled = (accountHolder.count < 1) || paytoUri == nil // TODO: check amountAvailable - let payURL = URL(string: account.paytoUri) - let iban = payURL?.iban - let xTaler = payURL?.xTaler - let alias = account.label - let kyc = account.kycCompleted ? String(localized: "verified") - : String(localized: "not yet verified") - - let destination = DepositAmountV(stack: stack.push(), - selectedBalance: $selectedBalance, - amountLastUsed: $amountLastUsed, - paytoUri: account.paytoUri) - NavigationLink(destination: destination) { - VStack { - if let iban { - Text("IBAN: \(iban)") - } else if let xTaler { - Text("xTaler: \(xTaler)") - } else { - Text("unknown payment method") - } - Text("Status: \(kyc)") - .padding(.leading) - if let alias { - Text(alias) - } - } - } - } - } - } - } - .listStyle(myListStyle.style).anyView - .refreshable { - controller.hapticNotification(.success) - symLog.log("refreshing") - await viewDidLoad() - } - .task { await viewDidLoad() } - .navigationTitle(subjectTitle) -// .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) - .onAppear { - DebugViewC.shared.setViewID(VIEW_DEPOSIT_ACCEPT, stack: stack.push()) -// print("❗️ P2PSubjectV onAppear") - } - .onDisappear { -// print("❗️ P2PSubjectV onDisappear") - } -// .task(id: depositIBAN) { await validateIban() } - } -} -// MARK: - -#if DEBUG -#endif diff --git a/TalerWallet1/Views/Actions/Banking/DepositSelectV.swift b/TalerWallet1/Views/Actions/Banking/DepositSelectV.swift @@ -0,0 +1,131 @@ +/* + * This file is part of GNU Taler, ©2022-24 Taler Systems S.A. + * See LICENSE.md + */ +/** + * @author Marc Stibane + */ +import SwiftUI +import taler_swift +import SymLog + +// Called when tapping [􁾩Deposit] +// user chooses a bank account +struct DepositSelectV: View { + private let symLog = SymLogV(0) + let stack: CallStack + @Binding var selectedBalance: Balance? + @Binding var amountLastUsed: Amount + +// let amountAvailable: Amount? +// @Binding var depositIBAN: String + + @EnvironmentObject private var controller: Controller + @EnvironmentObject private var model: WalletModel + @Environment(\.colorScheme) private var colorScheme + @Environment(\.colorSchemeContrast) private var colorSchemeContrast + @AppStorage("minimalistic") var minimalistic: Bool = false + @AppStorage("depositIBAN") var depositIBAN: String = EMPTYSTRING + @AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic + + @State private var myFeeLabel: String = EMPTYSTRING + @State private var transactionStarted: Bool = false + @FocusState private var isFocused: Bool + @State private var currencyName: String = UNKNOWN + @State private var currencySymbol: String = UNKNOWN + @State private var amountAvailable = Amount.zero(currency: EMPTYSTRING) // Update currency when used + @State private var amountToTransfer = Amount.zero(currency: EMPTYSTRING) // Update currency when used + @State private var bankAccounts: [BankAccountsInfo] = [] + + + private var subjectTitle: String { + return String(localized: "NavTitle_Deposit_AmountStr", + defaultValue: "Select account", + comment: "NavTitle: Deposit") + } + + @MainActor + private func viewDidLoad() async { + if let accounts = try? await model.listBankAccounts() { + withAnimation { bankAccounts = accounts } + } + } + + var body: some View { +#if PRINT_CHANGES + let _ = Self._printChanges() + let _ = symLog.vlog(amountToTransfer.readableDescription) // just to get the # +#endif + let depositHint = Text("You can only deposit to a bank account that you control, otherwise you will not be able to fulfill the regulatory requirements.") + + List { + Section { + depositHint + } + Section { + if bankAccounts.isEmpty { + let bankAccountsTitle = String(localized: "TitleBankAccounts", defaultValue: "Bank Accounts") + let bankAccountsDest = BankListView(stack: stack.push(bankAccountsTitle), + navTitle: bankAccountsTitle) + NavigationLink { // whole row like in a tableView + bankAccountsDest + } label: { + SettingsItem(name: bankAccountsTitle, id1: "bankAccounts", + description: minimalistic ? nil : String(localized: "Your accounts for deposit...")) {} + } + } else { + ForEach(bankAccounts, id: \.self) { account in +// let disabled = (accountHolder.count < 1) || paytoUri == nil // TODO: check amountAvailable + let payURL = URL(string: account.paytoUri) + let iban = payURL?.iban + let xTaler = payURL?.xTaler + let alias = account.label + let kyc = account.kycCompleted ? String(localized: "verified") + : String(localized: "not yet verified") + + let destination = DepositAmountV(stack: stack.push(), + selectedBalance: $selectedBalance, + amountLastUsed: $amountLastUsed, + paytoUri: account.paytoUri) + NavigationLink(destination: destination) { + VStack { + if let iban { + Text("IBAN: \(iban)") + } else if let xTaler { + Text("xTaler: \(xTaler)") + } else { + Text("unknown payment method") + } + Text("Status: \(kyc)") + .padding(.leading) + if let alias { + Text(alias) + } + } + } + } + } + } + } + .listStyle(myListStyle.style).anyView + .refreshable { + controller.hapticNotification(.success) + symLog.log("refreshing") + await viewDidLoad() + } + .task { await viewDidLoad() } + .navigationTitle(subjectTitle) +// .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all)) + .onAppear { + DebugViewC.shared.setViewID(VIEW_DEPOSIT_ACCEPT, stack: stack.push()) +// print("❗️ P2PSubjectV onAppear") + } + .onDisappear { +// print("❗️ P2PSubjectV onDisappear") + } +// .task(id: depositIBAN) { await validateIban() } + } +} +// MARK: - +#if DEBUG +#endif diff --git a/TalerWallet1/Views/Main/MainView.swift b/TalerWallet1/Views/Main/MainView.swift @@ -322,9 +322,9 @@ extension MainView { selectedBalance: $selectedBalance, amountLastUsed: $amountLastUsed, // currency needs to be updated! summary: $summary) - let depositDest = DepositIbanV(stack: stack.push(Self.name), - selectedBalance: $selectedBalance, - amountLastUsed: $amountLastUsed) + let depositDest = DepositSelectV(stack: stack.push(Self.name), + selectedBalance: $selectedBalance, + amountLastUsed: $amountLastUsed) let manualWithdrawDest = ManualWithdraw(stack: stack.push(Self.name), selectedBalance: $selectedBalance, amountLastUsed: $amountLastUsed, // currency needs to be updated!