diff options
author | Marc Stibane <marc@taler.net> | 2024-04-05 21:42:54 +0200 |
---|---|---|
committer | Marc Stibane <marc@taler.net> | 2024-04-05 21:42:54 +0200 |
commit | 6dd8c3b196206bcf00d425e9bf518d2e599ce69d (patch) | |
tree | 2142d29c32954461f42d5ec4c01e479986c274fd | |
parent | 0812c33177f3433f1e12d4f85db77917c2118201 (diff) | |
download | taler-ios-6dd8c3b196206bcf00d425e9bf518d2e599ce69d.tar.gz taler-ios-6dd8c3b196206bcf00d425e9bf518d2e599ce69d.tar.bz2 taler-ios-6dd8c3b196206bcf00d425e9bf518d2e599ce69d.zip |
prepare DepositWithdrawV
-rw-r--r-- | TalerWallet.xcodeproj/project.pbxproj | 6 | ||||
-rw-r--r-- | TalerWallet1/Views/Banking/DepositWithdrawV.swift | 92 |
2 files changed, 98 insertions, 0 deletions
diff --git a/TalerWallet.xcodeproj/project.pbxproj b/TalerWallet.xcodeproj/project.pbxproj index 7b0aa13..9e801c2 100644 --- a/TalerWallet.xcodeproj/project.pbxproj +++ b/TalerWallet.xcodeproj/project.pbxproj @@ -177,6 +177,8 @@ 4E983C2C2ADC416800FA9CC5 /* View+fitsSideBySide.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E983C2B2ADC416800FA9CC5 /* View+fitsSideBySide.swift */; }; 4E983C2D2ADC416800FA9CC5 /* View+fitsSideBySide.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E983C2B2ADC416800FA9CC5 /* View+fitsSideBySide.swift */; }; 4EA076B12BBEED7E00685A10 /* LocalConsole in Frameworks */ = {isa = PBXBuildFile; productRef = 4EA076B02BBEED7E00685A10 /* LocalConsole */; }; + 4EA076B32BC0607400685A10 /* DepositWithdrawV.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EA076B22BC0607400685A10 /* DepositWithdrawV.swift */; }; + 4EA076B42BC0607400685A10 /* DepositWithdrawV.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EA076B22BC0607400685A10 /* DepositWithdrawV.swift */; }; 4EA1ABBE29A3833A008821EA /* PublicConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EA1ABBD29A3833A008821EA /* PublicConstants.swift */; }; 4EA551252A2C923600FEC9A8 /* CurrencyInputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EA551242A2C923600FEC9A8 /* CurrencyInputView.swift */; }; 4EAD117629F672FA008EDD0B /* KeyboardResponder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EAD117529F672FA008EDD0B /* KeyboardResponder.swift */; }; @@ -373,6 +375,7 @@ 4E97968F2A3765ED006F73BC /* AgePicker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AgePicker.swift; sourceTree = "<group>"; }; 4E983C282ADBDD3500FA9CC5 /* SingleAxisGeometryReader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleAxisGeometryReader.swift; sourceTree = "<group>"; }; 4E983C2B2ADC416800FA9CC5 /* View+fitsSideBySide.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "View+fitsSideBySide.swift"; sourceTree = "<group>"; }; + 4EA076B22BC0607400685A10 /* DepositWithdrawV.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DepositWithdrawV.swift; sourceTree = "<group>"; }; 4EA1ABBD29A3833A008821EA /* PublicConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublicConstants.swift; sourceTree = "<group>"; }; 4EA551242A2C923600FEC9A8 /* CurrencyInputView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrencyInputView.swift; sourceTree = "<group>"; }; 4EAD117529F672FA008EDD0B /* KeyboardResponder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyboardResponder.swift; sourceTree = "<group>"; }; @@ -710,6 +713,7 @@ 4EB095292989CBFE0043A8A1 /* ExchangeListView.swift */, 4EC90C772A1B528B0071DC58 /* ExchangeSectionView.swift */, 4EC4008E2AE8019700DF72C7 /* ExchangeRowView.swift */, + 4EA076B22BC0607400685A10 /* DepositWithdrawV.swift */, 4EBC0F002B7B3CD600C0CB19 /* DepositIbanV.swift */, 4E96583B2B79656E00404A68 /* DepositAmountV.swift */, 4E50B34F2A1BEE8000F9F01C /* ManualWithdraw.swift */, @@ -1192,6 +1196,7 @@ 4E3EAE6C2A990778009F1BE8 /* ExchangeSectionView.swift in Sources */, 4E3EAE6D2A990778009F1BE8 /* P2PSubjectV.swift in Sources */, 4E6EF56B2B65A33300AF252A /* PaymentDone.swift in Sources */, + 4EA076B32BC0607400685A10 /* DepositWithdrawV.swift in Sources */, 4E3EAE6E2A990778009F1BE8 /* Model+P2P.swift in Sources */, 4E3EAE6F2A990778009F1BE8 /* TalerStrings.swift in Sources */, 4E3EAE702A990778009F1BE8 /* CurrencyInputView.swift in Sources */, @@ -1308,6 +1313,7 @@ 4EC90C782A1B528B0071DC58 /* ExchangeSectionView.swift in Sources */, 4E7940DE29FC307C00A9AEA1 /* P2PSubjectV.swift in Sources */, 4E6EF56C2B65A33300AF252A /* PaymentDone.swift in Sources */, + 4EA076B42BC0607400685A10 /* DepositWithdrawV.swift in Sources */, 4ECB62802A0BA6DF004ABBB7 /* Model+P2P.swift in Sources */, 4EB0950A2989CB7C0043A8A1 /* TalerStrings.swift in Sources */, 4EA551252A2C923600FEC9A8 /* CurrencyInputView.swift in Sources */, diff --git a/TalerWallet1/Views/Banking/DepositWithdrawV.swift b/TalerWallet1/Views/Banking/DepositWithdrawV.swift new file mode 100644 index 0000000..6bff91d --- /dev/null +++ b/TalerWallet1/Views/Banking/DepositWithdrawV.swift @@ -0,0 +1,92 @@ +/* + * 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 + +struct DepositWithdrawV: View { + private let symLog = SymLogV(0) + let stack: CallStack + let scopeInfo: ScopeInfo + let amountAvailable: Amount? + let currency: String // this is the currency to be used + @Binding var amountToTransfer: Amount // does still have the wrong currency + + @EnvironmentObject private var model: WalletModel + @AppStorage("minimalistic") var minimalistic: Bool = false + @State private var buttonSelected: Int? = nil + @State private var myExchange: Exchange? = nil + + func selectAndUpdate(_ button: Int) { + amountToTransfer.setCurrency(currency) + buttonSelected = button // will trigger NavigationLink + // after user tapped a button, while navigation animation runs, contact Exchange to update Fees + Task { // runs on MainActor + do { + try await model.updateExchange(scopeInfo: scopeInfo) + } catch { // TODO: error handling - couldn't updateExchange + symLog.log("error: \(error)") + } + } + } + + var body: some View { + let depositTitle0 = String(localized: "DepositButton_Short", defaultValue: "Deposit", + comment: "Abbreviation of `Deposit (currency)´") + let depositTitle1 = String(localized: "Deposit\t\(currency)", + comment: "Button `Deposit (currency)´, must have ONE \\t and ONE %@") + + let withdrawTitle0 = String(localized: "WithdrawButton_Short", defaultValue: "Withdraw", + comment: "Abbreviation of `Withdraw (currency)´") + let withdrawTitle1 = String(localized: "Withdraw\t\(currency)", + comment: "Button `Withdraw (currency)´, must have ONE \\t and ONE %@") + let deposit = LazyView { + DepositIbanV(stack: stack.push(), + feeLabel: nil, + feeIsNotZero: nil, + amountAvailable: amountAvailable, +// depositIBAN: $depositIBAN, +// accountHolder: $accountHolder, + amountToTransfer: $amountToTransfer) + } + let manualWithdraw = LazyView { + ManualWithdraw(stack: stack.push(), + isSheet: false, + scopeInfo: scopeInfo, + exchange: $myExchange, + amountToTransfer: $amountToTransfer) + } + let disableDeposit = amountAvailable?.isZero ?? false + let twoRowButtons = TwoRowButtons(stack: stack.push(), + sendTitle: minimalistic ? depositTitle0 : depositTitle1, + recvTitle: minimalistic ? withdrawTitle0 : withdrawTitle1, + fitsSideBySide: false, + lineLimit: 5, + sendDisabled: disableDeposit, + sendAction: { selectAndUpdate(1) }, + recvAction: { selectAndUpdate(2) }) + Group { + if #available(iOS 16.0, *) { + ViewThatFits(in: .horizontal) { + HStack(spacing: HSPACING) { + twoRowButtons.makeCopy(fitsSideBySide: true) + } + VStack { twoRowButtons } + } + } else { // view for iOS 15 + VStack { twoRowButtons } + } + } + .background( Group { + NavigationLink(destination: deposit, tag: 1, selection: $buttonSelected) + { EmptyView() }.frame(width: 0).opacity(0).hidden() + NavigationLink(destination: manualWithdraw, tag: 2, selection: $buttonSelected) + { EmptyView() }.frame(width: 0).opacity(0).hidden() + }) + } +} |