[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 04/69: AccountPicker, remove exchangePaytoUris
From: |
gnunet |
Subject: |
[taler-taler-ios] 04/69: AccountPicker, remove exchangePaytoUris |
Date: |
Fri, 19 Jan 2024 09:01:37 +0100 |
This is an automated email from the git hooks/post-receive script.
marc-stibane pushed a commit to branch master
in repository taler-ios.
commit 6ae5e98eb50ffd6f8ffd26d7fb07d06c350bb058
Author: Marc Stibane <marc@taler.net>
AuthorDate: Wed Dec 13 22:40:02 2023 +0100
AccountPicker, remove exchangePaytoUris
---
TalerWallet1/Model/Transaction.swift | 3 +-
.../Views/Transactions/ManualDetailsV.swift | 60 +++++++++++++++++++---
.../Views/Transactions/TransactionRowView.swift | 2 +-
3 files changed, 55 insertions(+), 10 deletions(-)
diff --git a/TalerWallet1/Model/Transaction.swift
b/TalerWallet1/Model/Transaction.swift
index 75c88a3..6a6033f 100644
--- a/TalerWallet1/Model/Transaction.swift
+++ b/TalerWallet1/Model/Transaction.swift
@@ -245,8 +245,7 @@ struct WithdrawalDetails: Decodable {
var reserveIsReady: Bool
/// Details for manual withdrawals:
- /// The payto URIs that the exchange supports.
- var exchangePaytoUris: [String]?
+ var exchangeCreditAccountDetails: [WithdrawalExchangeAccountDetails]?
/// Details for bank-integrated withdrawals:
/// Whether the bank has confirmed the withdrawal.
diff --git a/TalerWallet1/Views/Transactions/ManualDetailsV.swift
b/TalerWallet1/Views/Transactions/ManualDetailsV.swift
index 42f827f..97c8575 100644
--- a/TalerWallet1/Views/Transactions/ManualDetailsV.swift
+++ b/TalerWallet1/Views/Transactions/ManualDetailsV.swift
@@ -5,21 +5,64 @@
import SwiftUI
import taler_swift
+struct AccountPicker: View {
+ let title: String
+ let value: Int
+ let accountDetails: [WithdrawalExchangeAccountDetails]
+ let action: (Int) -> Void
+
+ @State private var selectedAccount = 0
+
+ var body: some View {
+ Picker(title, selection: $selectedAccount, content: {
+ ForEach(0..<accountDetails.count, id: \.self, content: { index in
+ let detail = accountDetails[index]
+ let bankName = detail.bankName ?? "BankName " + String(index)
+ let amountStr = detail.transferAmount.readableDescription
+ Text(bankName + ": " + amountStr)
+ .tag(index)
+ })
+ })
+ .accessibilityFont(.title3)
+ .pickerStyle(.menu)
+ .onAppear() {
+ withAnimation { selectedAccount = value }
+ }
+ .onChange(of: selectedAccount) { selected in
+ action(selected)
+ }
+ }
+}
+
+
struct ManualDetailsV: View {
var common : TransactionCommon
var details : WithdrawalDetails
@AppStorage("iconOnly") var iconOnly: Bool = false
+ @State private var accountID = 0
+ @State private var listID = UUID()
+
+ func redraw(_ newAccount: Int) -> Void {
+ if newAccount != accountID {
+ accountID = newAccount
+ withAnimation { listID = UUID() }
+ }
+ }
var body: some View {
- if let paytoUris = details.exchangePaytoUris {
- let payto = paytoUris[0]
+ if let accountDetails = details.exchangeCreditAccountDetails {
+ AccountPicker(title: String(localized: "Bank"), value: accountID,
+ accountDetails: accountDetails, action: redraw)
+ let account = accountDetails[accountID]
+ let payto = account.paytoUri
let payURL = URL(string: payto)
let iban = payURL?.iban ?? "unknown IBAN"
- let amountStr = common.amountRaw.readableDescription //
TODO: formatter
+ let amountStr = account.transferAmount.readableDescription
// TODO: formatter
+ let obtainStr = common.amountRaw.readableDescription
Group {
Text(iconOnly ? "Transfer \(amountStr) to the Exchange."
- : "You need to transfer \(amountStr) from your
regular bank account to the Exchange.")
+ : "You need to transfer \(amountStr) from your
regular bank account to the Exchange to receive \(obtainStr) as electronic cash
in this wallet.")
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)
@@ -76,7 +119,7 @@ struct ManualDetailsV: View {
.disabled(false)
Spacer()
} .listRowSeparator(.automatic)
- }
+ }.id(listID)
.accessibilityFont(.body)
}
}
@@ -92,8 +135,11 @@ struct ManualDetails_Previews: PreviewProvider {
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"])
+ let payto =
"payto://iban/SANDBOXX/DE159593?receiver-name=Exchange+Company"
+ let details = WithdrawalDetails(type: .manual,
+ reservePub:
"ReSeRvEpUbLiC_KeY_FoR_WiThDrAwAl",
+ reserveIsReady: false,
+ confirmed: false)
List {
ManualDetailsV(common: common, details: details)
}
diff --git a/TalerWallet1/Views/Transactions/TransactionRowView.swift
b/TalerWallet1/Views/Transactions/TransactionRowView.swift
index aafc403..3a37822 100644
--- a/TalerWallet1/Views/Transactions/TransactionRowView.swift
+++ b/TalerWallet1/Views/Transactions/TransactionRowView.swift
@@ -187,7 +187,7 @@ extension Transaction { // for PreViews
:
WithdrawalDetails.WithdrawalType.bankIntegrated,
reservePub:
"PuBlIc_KeY_oF_tHe_ReSeRvE",
reserveIsReady: false,
- exchangePaytoUris: pending ? [payto]
: nil)
+ confirmed: false)
let wDetails = WithdrawalTransactionDetails(exchangeBaseUrl:
DEMOEXCHANGE,
withdrawalDetails:
withdrawalDetails)
self = .withdrawal(WithdrawalTransaction(common: common, details:
wDetails))
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] branch master updated (a123c3a -> 4167b6d), gnunet, 2024/01/19
- [taler-taler-ios] 06/69: withdraw-exchange, gnunet, 2024/01/19
- [taler-taler-ios] 01/69: WithdrawExchangeV, gnunet, 2024/01/19
- [taler-taler-ios] 04/69: AccountPicker, remove exchangePaytoUris,
gnunet <=
- [taler-taler-ios] 03/69: CurrencyInfo from Exchange, gnunet, 2024/01/19
- [taler-taler-ios] 25/69: colors adapted for WCAG AA, gnunet, 2024/01/19
- [taler-taler-ios] 05/69: ToS language, gnunet, 2024/01/19
- [taler-taler-ios] 19/69: cleanup, gnunet, 2024/01/19
- [taler-taler-ios] 02/69: LoadingView, gnunet, 2024/01/19
- [taler-taler-ios] 12/69: PRINT_CHANGES, gnunet, 2024/01/19
- [taler-taler-ios] 07/69: Haptics, gnunet, 2024/01/19
- [taler-taler-ios] 31/69: Withdraw only once, gnunet, 2024/01/19
- [taler-taler-ios] 22/69: Summary in ThreeAmountsV, gnunet, 2024/01/19
- [taler-taler-ios] 30/69: Layout Balances, gnunet, 2024/01/19