taler-ios

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

commit 681ecf201912436204538356f541a4149f8af599
parent b6df844c281d1e2e1ef4befb729051c5f4931171
Author: Marc Stibane <marc@taler.net>
Date:   Sat,  4 Nov 2023 20:04:49 +0100

ManualDetailsV, minimal

Diffstat:
MTalerWallet.xcodeproj/project.pbxproj | 12++++++------
DTalerWallet1/Views/Transactions/ManualDetails.swift | 85-------------------------------------------------------------------------------
ATalerWallet1/Views/Transactions/ManualDetailsV.swift | 99+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MTalerWallet1/Views/Transactions/TransactionDetailView.swift | 2+-
4 files changed, 106 insertions(+), 92 deletions(-)

diff --git a/TalerWallet.xcodeproj/project.pbxproj b/TalerWallet.xcodeproj/project.pbxproj @@ -55,7 +55,7 @@ 4E3EAE3B2A990778009F1BE8 /* TalerWallet1App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB094EC298979620043A8A1 /* TalerWallet1App.swift */; }; 4E3EAE3C2A990778009F1BE8 /* WithdrawTOSView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095402989CBFE0043A8A1 /* WithdrawTOSView.swift */; }; 4E3EAE3D2A990778009F1BE8 /* Sheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EEC157729F9032900D46A03 /* Sheet.swift */; }; - 4E3EAE3E2A990778009F1BE8 /* ManualDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6EDD842A3615BE0031D520 /* ManualDetails.swift */; }; + 4E3EAE3E2A990778009F1BE8 /* ManualDetailsV.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6EDD842A3615BE0031D520 /* ManualDetailsV.swift */; }; 4E3EAE3F2A990778009F1BE8 /* View+dismissTop.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB095082989CB7C0043A8A1 /* View+dismissTop.swift */; }; 4E3EAE402A990778009F1BE8 /* TransactionsListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB0952F2989CBFE0043A8A1 /* TransactionsListView.swift */; }; 4E3EAE412A990778009F1BE8 /* WalletBackendRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB0951B2989CBCB0043A8A1 /* WalletBackendRequest.swift */; }; @@ -153,7 +153,7 @@ 4E605DB82AB05E48002FB9A7 /* View+flippedDirection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E605DB62AB05E48002FB9A7 /* View+flippedDirection.swift */; }; 4E605DBA2AB05FB6002FB9A7 /* BarGraph.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E605DB92AB05FB6002FB9A7 /* BarGraph.swift */; }; 4E605DBB2AB05FB6002FB9A7 /* BarGraph.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E605DB92AB05FB6002FB9A7 /* BarGraph.swift */; }; - 4E6EDD852A3615BE0031D520 /* ManualDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6EDD842A3615BE0031D520 /* ManualDetails.swift */; }; + 4E6EDD852A3615BE0031D520 /* ManualDetailsV.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6EDD842A3615BE0031D520 /* ManualDetailsV.swift */; }; 4E6EDD872A363D8D0031D520 /* ListStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E6EDD862A363D8D0031D520 /* ListStyle.swift */; }; 4E753A062A0952F8002D9328 /* DebugViewC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E753A052A0952F7002D9328 /* DebugViewC.swift */; }; 4E753A082A0B6A5F002D9328 /* ShareSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E753A072A0B6A5F002D9328 /* ShareSheet.swift */; }; @@ -328,7 +328,7 @@ 4E605DAE2AADDD13002FB9A7 /* UIScreen+screenSize.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIScreen+screenSize.swift"; sourceTree = "<group>"; }; 4E605DB62AB05E48002FB9A7 /* View+flippedDirection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "View+flippedDirection.swift"; sourceTree = "<group>"; }; 4E605DB92AB05FB6002FB9A7 /* BarGraph.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarGraph.swift; sourceTree = "<group>"; }; - 4E6EDD842A3615BE0031D520 /* ManualDetails.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ManualDetails.swift; sourceTree = "<group>"; }; + 4E6EDD842A3615BE0031D520 /* ManualDetailsV.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ManualDetailsV.swift; sourceTree = "<group>"; }; 4E6EDD862A363D8D0031D520 /* ListStyle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListStyle.swift; sourceTree = "<group>"; }; 4E753A042A08E720002D9328 /* transactions.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = transactions.json; sourceTree = "<group>"; }; 4E753A052A0952F7002D9328 /* DebugViewC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DebugViewC.swift; sourceTree = "<group>"; }; @@ -692,7 +692,7 @@ 4EB095302989CBFE0043A8A1 /* TransactionRowView.swift */, 4EB095312989CBFE0043A8A1 /* TransactionDetailView.swift */, 4E87C8722A31CB7F001C6406 /* TransactionsEmptyView.swift */, - 4E6EDD842A3615BE0031D520 /* ManualDetails.swift */, + 4E6EDD842A3615BE0031D520 /* ManualDetailsV.swift */, 4ED2F94A2A278F5100453B40 /* ThreeAmounts.swift */, ); path = Transactions; @@ -1078,7 +1078,7 @@ 4E3EAE3B2A990778009F1BE8 /* TalerWallet1App.swift in Sources */, 4E3EAE3C2A990778009F1BE8 /* WithdrawTOSView.swift in Sources */, 4E3EAE3D2A990778009F1BE8 /* Sheet.swift in Sources */, - 4E3EAE3E2A990778009F1BE8 /* ManualDetails.swift in Sources */, + 4E3EAE3E2A990778009F1BE8 /* ManualDetailsV.swift in Sources */, 4E3EAE3F2A990778009F1BE8 /* View+dismissTop.swift in Sources */, 4E3EAE402A990778009F1BE8 /* TransactionsListView.swift in Sources */, 4E3EAE412A990778009F1BE8 /* WalletBackendRequest.swift in Sources */, @@ -1187,7 +1187,7 @@ 4EB094ED298979620043A8A1 /* TalerWallet1App.swift in Sources */, 4EB095652989CBFE0043A8A1 /* WithdrawTOSView.swift in Sources */, 4EEC157829F9032900D46A03 /* Sheet.swift in Sources */, - 4E6EDD852A3615BE0031D520 /* ManualDetails.swift in Sources */, + 4E6EDD852A3615BE0031D520 /* ManualDetailsV.swift in Sources */, 4EB0950B2989CB7C0043A8A1 /* View+dismissTop.swift in Sources */, 4EB095562989CBFE0043A8A1 /* TransactionsListView.swift in Sources */, 4EB0951F2989CBCB0043A8A1 /* WalletBackendRequest.swift in Sources */, diff --git a/TalerWallet1/Views/Transactions/ManualDetails.swift b/TalerWallet1/Views/Transactions/ManualDetails.swift @@ -1,85 +0,0 @@ -/* - * This file is part of GNU Taler, ©2022-23 Taler Systems S.A. - * See LICENSE.md - */ -import SwiftUI -import taler_swift - -struct ManualDetails: View { - var common : TransactionCommon - var details : WithdrawalDetails - var body: some View { - if let paytoUris = details.exchangePaytoUris { - let payto = paytoUris[0] - let payURL = URL(string: payto) - let iban = payURL?.iban ?? "unknown IBAN" - let amount = common.amountRaw.readableDescription - Group { - Text("You need to transfer \(amount) from your regular bank account to the Exchange.") - Text("Step 1: Copy this code and paste it into the subject/purpose field in your banking app or bank website.\nThis is mandatory, otherwise your money will not arrive in this wallet.") - .multilineTextAlignment(.leading) - .listRowSeparator(.hidden) - HStack { - Text(details.reservePub) - .monospacedDigit() - .accessibilityLabel("Cryptocode") - Spacer() - CopyButton(textToCopy: details.reservePub, vertical: true) - .accessibilityLabel("Copy the cryptocode") - .disabled(false) - } .padding(.leading) - .listRowSeparator(.hidden) - Text("Step 2: If you don't already have it in your banking favourites list, then copy and paste this IBAN into the receiver IBAN field in your banking app or website:") - .multilineTextAlignment(.leading) - .listRowSeparator(.hidden) - HStack { - Text(iban) - .monospacedDigit() - Spacer() - CopyButton(textToCopy: iban, vertical: true) - .accessibilityLabel("Copy the IBAN") - .disabled(false) - } .padding(.leading) - .padding(.top, -8) - .listRowSeparator(.hidden) - Text("Step 3: Finish the wire transfer of \(amount) in your banking app or website, then this withdrawal will proceed automatically.") - .multilineTextAlignment(.leading) - .listRowSeparator(.visible) - Text("Alternative: If your bank already supports PayTo, you can use this PayTo-Link instead:") - .multilineTextAlignment(.leading) - .padding(.top, 2) - .listRowSeparator(.hidden) - HStack { - Text(verbatim: "|") // only reason for this leading-aligned text is to get a nice full length listRowSeparator - .accessibilityHidden(true) - .foregroundColor(Color.clear) - Spacer() - ShareButton(textToShare: payto) - .accessibilityLabel("Share the PayTo URL") - .disabled(false) - Spacer() - } .listRowSeparator(.automatic) - } - .accessibilityFont(.body) - } - } -} -// MARK: - -#if DEBUG -struct ManualDetails_Previews: PreviewProvider { - static var previews: some View { - let common = TransactionCommon(type: .withdrawal, - txState: TransactionState(major: .done), - amountEffective: try! Amount(fromString: LONGCURRENCY + ":1.1"), - amountRaw: try! Amount(fromString: LONGCURRENCY + ":2.2"), - transactionId: "someTxID", - timestamp: Timestamp(from: 1_666_666_000_000), - txActions: []) - let details = WithdrawalDetails(type: .manual, reservePub: "ReSeRvEpUbLiC_KeY_FoR_WiThDrAwAl", reserveIsReady: false, - exchangePaytoUris:["payto://iban/SANDBOXX/DE159593?receiver-name=Exchange+Company"]) - List { - ManualDetails(common: common, details: details) - } - } -} -#endif diff --git a/TalerWallet1/Views/Transactions/ManualDetailsV.swift b/TalerWallet1/Views/Transactions/ManualDetailsV.swift @@ -0,0 +1,99 @@ +/* + * This file is part of GNU Taler, ©2022-23 Taler Systems S.A. + * See LICENSE.md + */ +import SwiftUI +import taler_swift + +struct ManualDetailsV: View { + var common : TransactionCommon + var details : WithdrawalDetails + + @AppStorage("iconOnly") var iconOnly: Bool = false + + var body: some View { + if let paytoUris = details.exchangePaytoUris { + let payto = paytoUris[0] + let payURL = URL(string: payto) + let iban = payURL?.iban ?? "unknown IBAN" + let amount = common.amountRaw.readableDescription + Group { + Text(iconOnly ? "Transfer \(amount) to the Exchange." + : "You need to transfer \(amount) from your regular bank account to the Exchange.") + Text(iconOnly ? "Step 1: Copy+Paste this subject:" + : "Step 1: Copy this code and paste it into the subject/purpose field in your banking app or bank website:") + .multilineTextAlignment(.leading) + .listRowSeparator(.hidden) + if !iconOnly { + Text("This is mandatory, otherwise your money will not arrive in this wallet.") + .bold() + .multilineTextAlignment(.leading) + .listRowSeparator(.hidden) + } + HStack { + Text(details.reservePub) + .monospacedDigit() + .accessibilityLabel("Cryptocode") + Spacer() + CopyButton(textToCopy: details.reservePub, vertical: true) + .accessibilityLabel("Copy the cryptocode") + .disabled(false) + } .padding(.leading) + .listRowSeparator(.hidden) + Text(iconOnly ? "Step 2: Copy+Paste this IBAN:" + : "Step 2: If you don't already have it in your banking favourites list, then copy and paste this IBAN into the receiver IBAN field in your banking app or website:") + .multilineTextAlignment(.leading) + .listRowSeparator(.hidden) + HStack { + Text(iban) + .monospacedDigit() + Spacer() + CopyButton(textToCopy: iban, vertical: true) + .accessibilityLabel("Copy the IBAN") + .disabled(false) + } .padding(.leading) + .padding(.top, -8) + .listRowSeparator(.hidden) + Text(iconOnly ? "Step 3: Transfer \(amount)." + : "Step 3: Finish the wire transfer of \(amount) in your banking app or website, then this withdrawal will proceed automatically.") + .multilineTextAlignment(.leading) + .listRowSeparator(.visible) + Text(iconOnly ? "Or use this PayTo-Link:" + : "Alternative: If your bank already supports PayTo, you can use this PayTo-Link instead:") + .multilineTextAlignment(.leading) + .padding(.top, 2) + .listRowSeparator(.hidden) + HStack { + Text(verbatim: "|") // only reason for this leading-aligned text is to get a nice full length listRowSeparator + .accessibilityHidden(true) + .foregroundColor(Color.clear) + Spacer() + ShareButton(textToShare: payto) + .accessibilityLabel("Share the PayTo URL") + .disabled(false) + Spacer() + } .listRowSeparator(.automatic) + } + .accessibilityFont(.body) + } + } +} +// MARK: - +#if DEBUG +struct ManualDetails_Previews: PreviewProvider { + static var previews: some View { + let common = TransactionCommon(type: .withdrawal, + txState: TransactionState(major: .done), + amountEffective: try! Amount(fromString: LONGCURRENCY + ":1.1"), + amountRaw: try! Amount(fromString: LONGCURRENCY + ":2.2"), + transactionId: "someTxID", + timestamp: Timestamp(from: 1_666_666_000_000), + txActions: []) + let details = WithdrawalDetails(type: .manual, reservePub: "ReSeRvEpUbLiC_KeY_FoR_WiThDrAwAl", reserveIsReady: false, + exchangePaytoUris:["payto://iban/SANDBOXX/DE159593?receiver-name=Exchange+Company"]) + List { + ManualDetailsV(common: common, details: details) + } + } +} +#endif diff --git a/TalerWallet1/Views/Transactions/TransactionDetailView.swift b/TalerWallet1/Views/Transactions/TransactionDetailView.swift @@ -206,7 +206,7 @@ struct TransactionDetailView: View { let withdrawalDetails = details.withdrawalDetails switch withdrawalDetails.type { case .manual: // "Make a wire transfer of \(amount) to" - ManualDetails(common: common, details: withdrawalDetails) + ManualDetailsV(common: common, details: withdrawalDetails) case .bankIntegrated: // "Confirm with bank" let confirmed = withdrawalDetails.confirmed ?? false