[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 32/35: TransactionDetailView
From: |
gnunet |
Subject: |
[taler-taler-ios] 32/35: TransactionDetailView |
Date: |
Thu, 27 Jul 2023 09:10:05 +0200 |
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 9ff0fd3aa5cb7dedb3c421688555d2b16c615fea
Author: Marc Stibane <marc@taler.net>
AuthorDate: Wed Jul 26 11:08:03 2023 +0200
TransactionDetailView
---
.../Views/Exchange/ManualWithdrawDone.swift | 16 +++--
TalerWallet1/Views/Peer2peer/SendDone.swift | 65 ++++++++++---------
.../Views/Sheets/P2P_Sheets/P2pAcceptDone.swift | 8 ++-
.../Views/Transactions/TransactionDetailView.swift | 33 ++++++----
.../Views/Transactions/TransactionsListView.swift | 72 ++++++++++------------
.../WithdrawAcceptDone.swift | 8 ++-
6 files changed, 109 insertions(+), 93 deletions(-)
diff --git a/TalerWallet1/Views/Exchange/ManualWithdrawDone.swift
b/TalerWallet1/Views/Exchange/ManualWithdrawDone.swift
index 5214057..e5d3b20 100644
--- a/TalerWallet1/Views/Exchange/ManualWithdrawDone.swift
+++ b/TalerWallet1/Views/Exchange/ManualWithdrawDone.swift
@@ -16,8 +16,8 @@ struct ManualWithdrawDone: View {
@EnvironmentObject private var model: WalletModel
- @State var acceptManualWithdrawalResult: AcceptManualWithdrawalResult?
- @State var transactionId: String?
+ @State private var acceptManualWithdrawalResult:
AcceptManualWithdrawalResult?
+ @State private var transactionId: String?
func reloadOneAction(_ transactionId: String) async throws -> Transaction {
return try await model.getTransactionByIdT(transactionId)
@@ -28,14 +28,20 @@ struct ManualWithdrawDone: View {
let _ = Self._printChanges()
let _ = symLog.vlog() // just to get the # to compare it with
.onAppear & onDisappear
#endif
- VStack {
+ Group {
if let transactionId {
TransactionDetailView(transactionId: transactionId,
reloadAction: reloadOneAction,
- doneAction:
ViewState.shared.popToRootView)
+ navTitle: navTitle,
+ doneAction:
ViewState.shared.popToRootView,
+ abortAction: nil,
+ deleteAction: nil,
+ failAction: nil,
+ suspendAction: nil,
+ resumeAction: nil)
.navigationBarBackButtonHidden(true)
.interactiveDismissDisabled() // can only use "Done"
button to dismiss
- .navigationTitle(navTitle)
+// .navigationTitle(navTitle)
} else {
WithdrawProgressView(message:
exchange.exchangeBaseUrl.trimURL())
.navigationTitle("Loading " + navTitle)
diff --git a/TalerWallet1/Views/Peer2peer/SendDone.swift
b/TalerWallet1/Views/Peer2peer/SendDone.swift
index 79b0918..88b9698 100644
--- a/TalerWallet1/Views/Peer2peer/SendDone.swift
+++ b/TalerWallet1/Views/Peer2peer/SendDone.swift
@@ -23,41 +23,40 @@ struct SendDone: View {
@EnvironmentObject private var model: WalletModel
- @State var talerURI: String = ""
+ @State private var transactionId: String?
+
+ func reloadOneAction(_ transactionId: String) async throws -> Transaction {
+ return try await model.getTransactionByIdT(transactionId)
+ }
var body: some View {
- List {
- let incoming = (amountToSend == nil)
- QRCodeDetailView(talerURI: talerURI,
- incoming: incoming,
- amount: incoming ? amountToReceive :
amountToSend)
- Text("QR code and link can also be scanned or copied / shared from
Transactions later.")
- .multilineTextAlignment(.leading)
- .font(.subheadline)
- .padding(.top)
- }
- .listStyle(myListStyle.style).anyView
- .safeAreaInset(edge: .bottom) {
- Button("Done") {
- withAnimation() { ViewState.shared.popToRootView() }
- }
- .buttonStyle(TalerButtonStyle(type: .prominent))
- .padding(.horizontal)
- }
- .overlay {
- if talerURI.isEmpty {
- LoadingView(backButtonHidden: true)
+#if DEBUG
+ let _ = Self._printChanges()
+ let _ = symLog.vlog() // just to get the # to compare it with
.onAppear & onDisappear
+#endif
+ VStack {
+ if let transactionId {
+ TransactionDetailView(transactionId: transactionId,
+ reloadAction: reloadOneAction,
+ navTitle: navTitle,
+ doneAction:
ViewState.shared.popToRootView,
+ abortAction: nil,
+ deleteAction: nil,
+ failAction: nil,
+ suspendAction: nil,
+ resumeAction: nil)
+ .navigationBarBackButtonHidden(true)
+ .interactiveDismissDisabled() // can only use "Done"
button to dismiss
+ .navigationTitle(navTitle)
+ } else {
+ WithdrawProgressView(message: "Loading...")
+ .navigationTitle(navTitle)
}
}
- .interactiveDismissDisabled() // can only use "Done" button to
dismiss
- .navigationBarBackButtonHidden(true)
- .navigationTitle(navTitle)
-// .navigationBarHidden(true) // no back button, no title
- .background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all))
+//
.background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all))
.task {
symLog.log(".task")
do {
- // generate talerURI
let timestamp = developerMode ?
Timestamp.inSomeMinutes(expireDays > 20 ? (24*60)
:
expireDays > 5 ? 60 : 3)
:
Timestamp.inSomeDays(expireDays)
@@ -67,18 +66,17 @@ struct SendDone: View {
purse_expiration: timestamp)
// TODO: user might choose baseURL
let response = try await model.initiatePeerPushDebitM(nil,
terms: terms)
- talerURI = response.talerUri
+ transactionId = response.transactionId
} else if let amountToReceive {
let terms = PeerContractTerms(amount: amountToReceive,
summary: summary,
purse_expiration: timestamp)
// TODO: user might choose baseURL
let response = try await
model.initiatePeerPullCreditM(nil, terms: terms)
- talerURI = response.talerUri
- } else { talerURI = "" }
+ transactionId = response.transactionId
+ } else { fatalError() }
} catch { // TODO: error
symLog.log(error.localizedDescription)
- talerURI = ""
}
} // task
}
@@ -90,8 +88,7 @@ struct SendNow_Previews: PreviewProvider {
SendDone(amountToSend: try! Amount(fromString: LONGCURRENCY +
":4.8"),
amountToReceive: nil,
summary: "some purpose",
- expireDays: 0,
- talerURI:
"taler://pay-push/exchange.demo.taler.net/95ZG4D1AGFGZQ7CNQ1V49D3FT18HXKA6HQT4X3XME9YSJQVFQ520")
+ expireDays: 0)
}
}
}
diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
index e54ce77..85530fc 100644
--- a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
+++ b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
@@ -30,7 +30,13 @@ struct P2pAcceptDone: View {
: String(localized: "Paid P2P", comment:
"Title, short")
TransactionDetailView(transactionId: transactionId,
reloadAction: reloadOneAction,
- doneAction: { dismissTop() })
+ navTitle: navTitle,
+ doneAction: { dismissTop() },
+ abortAction: nil,
+ deleteAction: nil,
+ failAction: nil,
+ suspendAction: nil,
+ resumeAction: nil)
.navigationBarBackButtonHidden(true)
.interactiveDismissDisabled() // can only use "Done"
button to dismiss
.navigationTitle(navTitle)
diff --git a/TalerWallet1/Views/Transactions/TransactionDetailView.swift
b/TalerWallet1/Views/Transactions/TransactionDetailView.swift
index b01cd4f..bb2f404 100644
--- a/TalerWallet1/Views/Transactions/TransactionDetailView.swift
+++ b/TalerWallet1/Views/Transactions/TransactionDetailView.swift
@@ -30,18 +30,20 @@ struct TransactionDetailView: View {
@AppStorage("developerMode") var developerMode: Bool = false
#endif
- var transactionId: String
+ let transactionId: String
+ let reloadAction: ((_ transactionId: String) async throws -> Transaction)
+
+ let navTitle: String?
+ let doneAction: (() -> Void)?
+ let abortAction: ((_ transactionId: String) async throws -> Void)?
+ let deleteAction: ((_ transactionId: String) async throws -> Void)?
+ let failAction: ((_ transactionId: String) async throws -> Void)?
+ let suspendAction: ((_ transactionId: String) async throws -> Void)?
+ let resumeAction: ((_ transactionId: String) async throws -> Void)?
+
@State var transaction: Transaction = Transaction(dummyCurrency:
DEMOCURRENCY)
@State var viewId = UUID()
- var reloadAction: ((_ transactionId: String) async throws -> Transaction)
- var abortAction: ((_ transactionId: String) async throws -> Void)?
- var deleteAction: ((_ transactionId: String) async throws -> Void)?
- var failAction: ((_ transactionId: String) async throws -> Void)?
- var doneAction: (() -> Void)?
- var suspendAction: ((_ transactionId: String) async throws -> Void)?
- var resumeAction: ((_ transactionId: String) async throws -> Void)?
-
var body: some View {
#if DEBUG
let _ = Self._printChanges()
@@ -51,7 +53,7 @@ struct TransactionDetailView: View {
let pending = transaction.isPending
let dateString = TalerDater.dateString(from: common.timestamp)
let localizedType = transaction.localizedType
- let navTitle = pending ? String(localized: "Pending")
+ let navTitle2 = pending ? String(localized: "Pending")
: localizedType
Group {
List {
@@ -77,7 +79,7 @@ struct TransactionDetailView: View {
Text("Status: \(common.txState.major.localizedState)")
.font(.title2)
} .listRowSeparator(.automatic)
- SwitchCase(transaction: $transaction)
+ SwitchCase(transaction: $transaction, hasDone: doneAction !=
nil)
if transaction.isAbortable { if let abortAction {
TransactionButton(transactionId: common.transactionId,
@@ -144,7 +146,7 @@ struct TransactionDetailView: View {
symLog.log(notification.userInfo as Any)
}
}
- .navigationTitle(navTitle)
+ .navigationTitle(navTitle ?? navTitle2)
.task {
do {
symLog.log("task - load transaction")
@@ -168,6 +170,7 @@ struct TransactionDetailView: View {
//extension TransactionDetail {
struct SwitchCase: View {
@Binding var transaction: Transaction
+ let hasDone: Bool
var body: some View {
let common = transaction.common
@@ -238,6 +241,12 @@ struct TransactionDetailView: View {
// TODO: isSendCoins should show QR only while not
expired
if pending {
QRCodeDetails(transaction: transaction)
+ if hasDone {
+ Text("QR code and link can also be scanned or
copied / shared from Transactions later.")
+ .multilineTextAlignment(.leading)
+ .font(.subheadline)
+ .padding(.top)
+ }
}
ThreeAmountsSheet(common: common, topTitle:
transaction.localizedType,
baseURL: details.exchangeBaseUrl,
large: false)
diff --git a/TalerWallet1/Views/Transactions/TransactionsListView.swift
b/TalerWallet1/Views/Transactions/TransactionsListView.swift
index 67e1cd1..8057a0e 100644
--- a/TalerWallet1/Views/Transactions/TransactionsListView.swift
+++ b/TalerWallet1/Views/Transactions/TransactionsListView.swift
@@ -75,49 +75,41 @@ struct TransactionsListView: View {
}
}
// MARK: -
-//extension TransactionsListView {
- struct TransactionsRowsView: View {
- let symLog: SymLogV?
- let currency: String
- let transactions: [Transaction]
-// let reloadAllAction: () async -> ()
- let reloadOneAction: ((_ transactionId: String) async throws ->
Transaction)
+struct TransactionsRowsView: View {
+ let symLog: SymLogV?
+ let currency: String
+ let transactions: [Transaction]
+// let reloadAllAction: () async -> ()
+ let reloadOneAction: ((_ transactionId: String) async throws ->
Transaction)
- @EnvironmentObject private var model: WalletModel
- var body: some View {
+ @EnvironmentObject private var model: WalletModel
+ var body: some View {
#if DEBUG
- let _ = Self._printChanges()
- let _ = symLog?.vlog() // just to get the # to compare it
with .onAppear & onDisappear
+ let _ = Self._printChanges()
+ let _ = symLog?.vlog() // just to get the # to compare it with
.onAppear & onDisappear
#endif
- let abortAction = model.abortTransaction
- let deleteAction = model.deleteTransaction
- let failAction = model.failTransaction
- let suspendAction = model.suspendTransaction
- let resumeAction = model.resumeTransaction
- ForEach(Array(zip(transactions.indices, transactions)), id:
\.1) { index, transaction in
- NavigationLink { LazyView { // whole row like in a
tableView
- TransactionDetailView(transactionId: transaction.id,
- reloadAction: reloadOneAction,
- abortAction: abortAction,
- deleteAction: deleteAction,
- failAction: failAction,
- suspendAction: suspendAction,
- resumeAction: resumeAction)
- }} label: {
- TransactionRowView(transaction: transaction)
- }
- .id(Int(index))
+ let abortAction = model.abortTransaction
+ let deleteAction = model.deleteTransaction
+ let failAction = model.failTransaction
+ let suspendAction = model.suspendTransaction
+ let resumeAction = model.resumeTransaction
+ ForEach(Array(zip(transactions.indices, transactions)), id: \.1) {
index, transaction in
+ NavigationLink {
+ LazyView {
+ TransactionDetailView(transactionId: transaction.id,
+ reloadAction: reloadOneAction,
+ navTitle: nil,
+ doneAction: nil,
+ abortAction: abortAction,
+ deleteAction: deleteAction,
+ failAction: failAction,
+ suspendAction: suspendAction,
+ resumeAction: resumeAction)
}
- // pending may not be deleted, but only aborted
-// .onDelete(perform: removeItems) // delete this row from
the list
+ } label: {
+ TransactionRowView(transaction: transaction)
+ }
+ .id(Int(index))
}
}
-//}
-// MARK: -
-#if DEBUG
-//struct TransactionsView_Previews: PreviewProvider {
-// static var previews: some View {
-// TransactionsView()
-// }
-//}
-#endif
+}
diff --git a/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawAcceptDone.swift
b/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawAcceptDone.swift
index 1a802f1..aa9ca99 100644
--- a/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawAcceptDone.swift
+++ b/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawAcceptDone.swift
@@ -32,7 +32,13 @@ struct WithdrawAcceptDone: View {
if let transactionId {
TransactionDetailView(transactionId: transactionId,
reloadAction: reloadOneAction,
- doneAction: { dismissTop() })
+ navTitle: navTitle,
+ doneAction: { dismissTop() },
+ abortAction: nil,
+ deleteAction: nil,
+ failAction: nil,
+ suspendAction: nil,
+ resumeAction: nil)
.navigationBarBackButtonHidden(true)
.interactiveDismissDisabled() // can only use "Done"
button to dismiss
.navigationTitle(navTitle)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] 14/35: Sound for Expired, (continued)
- [taler-taler-ios] 14/35: Sound for Expired, gnunet, 2023/07/27
- [taler-taler-ios] 27/35: Postpone update until onAppear, gnunet, 2023/07/27
- [taler-taler-ios] 31/35: Expired, pending, gnunet, 2023/07/27
- [taler-taler-ios] 35/35: iOS: bump version to 0.9.3 (16), gnunet, 2023/07/27
- [taler-taler-ios] 22/35: extension TransactionsListView.Content => TransactionsRowsView, gnunet, 2023/07/27
- [taler-taler-ios] 21/35: fanblades.slash and clock.badge.xmark not in iOS 15, gnunet, 2023/07/27
- [taler-taler-ios] 13/35: SendDone, gnunet, 2023/07/27
- [taler-taler-ios] 17/35: Warnings and hints no longer use "coins", gnunet, 2023/07/27
- [taler-taler-ios] 26/35: debug, cleanup, gnunet, 2023/07/27
- [taler-taler-ios] 30/35: small fixes, gnunet, 2023/07/27
- [taler-taler-ios] 32/35: TransactionDetailView,
gnunet <=
- [taler-taler-ios] 16/35: rendering on small screens, gnunet, 2023/07/27
- [taler-taler-ios] 34/35: ScrollViewReader, gnunet, 2023/07/27
- [taler-taler-ios] 20/35: ToS, move Exchange down, gnunet, 2023/07/27
- [taler-taler-ios] 29/35: show up to 3 transactions in Balances, gnunet, 2023/07/27
- [taler-taler-ios] 33/35: Comments, gnunet, 2023/07/27
- [taler-taler-ios] 15/35: ToS, gnunet, 2023/07/27
- [taler-taler-ios] 24/35: ToS, gnunet, 2023/07/27
- [taler-taler-ios] 23/35: Hints for manual withdrawal, Accessibility, gnunet, 2023/07/27
- [taler-taler-ios] 28/35: QRcode rendering and hint, gnunet, 2023/07/27