[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 20/54: viewID + comments
From: |
gnunet |
Subject: |
[taler-taler-ios] 20/54: viewID + comments |
Date: |
Fri, 30 Jun 2023 22:33:52 +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 cf4e4fc16e614126c1a77ce2ffd9f8200dbcd485
Author: Marc Stibane <marc@taler.net>
AuthorDate: Sun Jun 25 09:56:23 2023 +0200
viewID + comments
---
.../Views/Balances/BalancesSectionView.swift | 20 ++++++--
TalerWallet1/Views/Peer2peer/PaymentPurpose.swift | 4 +-
.../Sheets/P2P_Sheets/P2pReceiveURIView.swift | 4 +-
.../Views/Transactions/TransactionDetailView.swift | 59 ++++++++++++----------
.../Views/Transactions/TransactionsListView.swift | 4 +-
.../WithdrawBankIntegrated/WithdrawTOSView.swift | 2 +-
6 files changed, 54 insertions(+), 39 deletions(-)
diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift
b/TalerWallet1/Views/Balances/BalancesSectionView.swift
index f46735e..188be25 100644
--- a/TalerWallet1/Views/Balances/BalancesSectionView.swift
+++ b/TalerWallet1/Views/Balances/BalancesSectionView.swift
@@ -56,6 +56,8 @@ struct BalancesSectionView: View {
return (incoming, outgoing)
}
+ @State private var sectionID = UUID()
+ @State private var shownSectionID = UUID() // guaranteed to be different
the first time
var body: some View {
#if DEBUG
@@ -66,14 +68,17 @@ struct BalancesSectionView: View {
let reloadCompleted = {
transactions = await model.fetchTransactionsT(currency: currency)
completedTransactions =
WalletModel.completedTransactions(transactions)
+// sectionID = UUID()
}
let reloadPending = {
transactions = await model.fetchTransactionsT(currency: currency)
pendingTransactions = WalletModel.pendingTransactions(transactions)
+// sectionID = UUID()
}
let reloadUncompleted = {
transactions = await model.fetchTransactionsT(currency: currency)
uncompletedTransactions =
WalletModel.uncompletedTransactions(transactions)
+// sectionID = UUID()
}
let deleteAction = model.deleteTransactionT // dummyTransaction
let abortAction = model.abortTransactionT
@@ -178,11 +183,16 @@ struct BalancesSectionView: View {
} header: {
Text(currency)
.font(.title)
- } .task {
- let response = await model.fetchTransactionsT(currency: currency)
- transactions = response
- pendingTransactions = WalletModel.pendingTransactions(response)
- uncompletedTransactions =
WalletModel.uncompletedTransactions(response)
+ }.id(sectionID)
+ .task {
+ if shownSectionID != sectionID {
+ symLog.log("task for BalancesSectionView \(sectionID)")
+ let response = await model.fetchTransactionsT(currency:
currency)
+ transactions = response
+ pendingTransactions = WalletModel.pendingTransactions(response)
+ uncompletedTransactions =
WalletModel.uncompletedTransactions(response)
+ shownSectionID = sectionID
+ }
}
} // body
}
diff --git a/TalerWallet1/Views/Peer2peer/PaymentPurpose.swift
b/TalerWallet1/Views/Peer2peer/PaymentPurpose.swift
index e7230ea..0a69e48 100644
--- a/TalerWallet1/Views/Peer2peer/PaymentPurpose.swift
+++ b/TalerWallet1/Views/Peer2peer/PaymentPurpose.swift
@@ -80,10 +80,10 @@ struct PaymentPurpose: View {
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.horizontal)
}
- .navigationTitle("Invoice another Wallet")
+ .navigationTitle("Invoice")
.background(WalletColors().backgroundColor.edgesIgnoringSafeArea(.all))
.onAppear {
- DebugViewC.shared.setSheetID(VIEW_INVOICE_PURPOSE)
+ DebugViewC.shared.setViewID(VIEW_INVOICE_PURPOSE)
print("❗️ PaymentPurpose onAppear")
}
.onDisappear {
diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift
b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift
index 1b0478a..e7e4050 100644
--- a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift
+++ b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pReceiveURIView.swift
@@ -6,8 +6,8 @@ import SwiftUI
import taler_swift
import SymLog
-// Will be called either by the user scanning a QR code or tapping the
provided link, from another user's SendCoins
-// we show the user the P2P details - but first the ToS must be accepted
+// Will be called either by the user scanning a QR code or tapping the
provided link,
+// from another user's SendCoins. We show the P2P details - but first the ToS
must be accepted.
struct P2pReceiveURIView: View {
private let symLog = SymLogV()
let navTitle = String(localized: "Accept P2P Receive")
diff --git a/TalerWallet1/Views/Transactions/TransactionDetailView.swift
b/TalerWallet1/Views/Transactions/TransactionDetailView.swift
index 9627ef5..0165764 100644
--- a/TalerWallet1/Views/Transactions/TransactionDetailView.swift
+++ b/TalerWallet1/Views/Transactions/TransactionDetailView.swift
@@ -7,8 +7,8 @@ import taler_swift
import SymLog
extension Transaction { // for Dummys
- init(dummy: Bool) {
- let amount = try! Amount(fromString: "KUDOS:0")
+ init(dummyCurrency: String) {
+ let amount = try! Amount(fromString: "\(dummyCurrency):0")
let now = Timestamp.now()
let common = TransactionCommon(type: .dummy,
txState: TransactionState(major:
.pending),
@@ -27,8 +27,8 @@ struct TransactionDetailView: View {
@AppStorage("developerMode") var developerMode: Bool = false
var transactionId: String
- @State var transaction: Transaction = Transaction(dummy: true)
- @State var viewId: Int = 0
+ @State var transaction: Transaction = Transaction(dummyCurrency:
DEMOCURRENCY)
+ @State var viewId = UUID()
var reloadAction: ((_ transactionId: String) async throws -> Transaction)
var deleteAction: ((_ transactionId: String) async throws -> Void)?
@@ -59,7 +59,7 @@ struct TransactionDetailView: View {
TransactionButton(transactionId: common.transactionId,
command: .resume, action:
resumeAction)
} }
- }
+ } // Suspend + Resume buttons
Text("\(dateString)")
.font(.title2)
// .listRowSeparator(.hidden)
@@ -68,46 +68,52 @@ struct TransactionDetailView: View {
if transaction.isAbortable { if let abortAction {
TransactionButton(transactionId: common.transactionId,
command: .abort, action: abortAction)
- } }
+ } } // Abort button
if transaction.isDeleteable { if let deleteAction {
TransactionButton(transactionId: common.transactionId,
command: .delete, action: deleteAction)
- } }
+ } } // Delete button
if let doneAction {
DoneButton(doneAction: doneAction)
- }
- }.id(viewId)
+ } // Done button
+ }.id(viewId) // change viewId to enforce a draw update
.listStyle(myListStyle.style).anyView
}.onNotification(.TransactionStateTransition) { notification in
if let transition = notification.userInfo?[TRANSACTIONTRANSITION]
as? TransactionTransition {
if transition.transactionId == common.transactionId {
let newState = transition.newTxState.major
if newState == .done { if let doneAction {
- symLog.log("newTxState.major == done")
- doneAction()
+ symLog.log("newTxState.major == done => dismiss
sheet")
+ doneAction() // if this view is in a sheet this
action will dissmiss it
}} else { Task { do {
- symLog.log("newState: \(newState), reloading
transaction")
- withAnimation() { transaction = Transaction(dummy:
true); viewId += 1 }
- let reloadedTransaction = try await
reloadAction(common.transactionId)
- symLog.log("reloaded transaction:
\(reloadedTransaction.common.txState.major)")
- withAnimation() { transaction = reloadedTransaction;
viewId += 1 } // redraw
+ if doneAction != nil { // don't update while we are in
a sheet - except done
+ symLog.log("ignoring newState: \(newState)")
+ } else {
+ symLog.log("newState: \(newState), reloading
transaction")
+ withAnimation() { transaction =
Transaction(dummyCurrency: DEMOCURRENCY); viewId = UUID() }
+ let reloadedTransaction = try await
reloadAction(common.transactionId)
+ symLog.log("reloaded transaction:
\(reloadedTransaction.common.txState.major)")
+ withAnimation() { transaction =
reloadedTransaction; viewId = UUID() } // redraw
+ }
} catch {
symLog.log(error.localizedDescription)
}}}
}
} else {
+ // Yikes - should never happen
symLog.log(notification.userInfo as Any)
}
}
.navigationTitle(navTitle)
.task {
do {
- symLog.log("task")
+ symLog.log("task - load transaction")
let reloadedTransaction = try await reloadAction(transactionId)
- withAnimation() { transaction = reloadedTransaction } //
redraw
+ withAnimation() { transaction = reloadedTransaction; viewId =
UUID() } // redraw
} catch {
- withAnimation() { transaction = Transaction(dummy: true) }
+ symLog.log(error)
+ withAnimation() { transaction = Transaction(dummyCurrency:
DEMOCURRENCY); viewId = UUID() }
}
}
.onAppear {
@@ -129,7 +135,7 @@ struct TransactionDetailView: View {
let pending = transaction.isPending
switch transaction {
case .dummy(let dummyTransaction):
- Text("Dummy")
+ Text("")
case .withdrawal(let withdrawalTransaction):
let details = withdrawalTransaction.details
if pending {
@@ -153,7 +159,7 @@ struct TransactionDetailView: View {
}
}
}
- }
+ } // ManualDetails or Confirm with bank
ThreeAmounts(common: common, topTitle: String(localized:
"Chosen amount to withdraw:"),
baseURL:
withdrawalTransaction.details.exchangeBaseUrl, large: true)
case .payment(let paymentTransaction):
@@ -182,7 +188,8 @@ struct TransactionDetailView: View {
baseURL: nil, large: true) // TODO:
baseURL
case .peer2peer(let p2pTransaction):
let details = p2pTransaction.details //
TODO: details
- if pending {
+ // TODO: isSendCoins should show QR only while not expired
+ if pending || transaction.isSendCoins {
QRCodeDetails(transaction: transaction)
}
ThreeAmounts(common: common, topTitle: String(localized:
"Peer to Peer:"),
@@ -199,15 +206,13 @@ struct TransactionDetailView: View {
if keys.contains(TALERURI) {
if let talerURI = details[TALERURI] {
if talerURI.count > 10 {
- VStack {
- QRGeneratorView(text: talerURI)
- Text(talerURI)
- }
+ QRCodeDetailView(talerURI: talerURI,
+ incoming: transaction.isP2pIncoming)
}
}
} else if keys.contains(EXCHANGEBASEURL) {
if let baseURL = details[EXCHANGEBASEURL] {
- Text("from \(baseURL.trimURL())")
+ Text("from \(baseURL.trimURL())")
.font(.title2)
.padding(.bottom)
}
diff --git a/TalerWallet1/Views/Transactions/TransactionsListView.swift
b/TalerWallet1/Views/Transactions/TransactionsListView.swift
index eae9b75..77563e4 100644
--- a/TalerWallet1/Views/Transactions/TransactionsListView.swift
+++ b/TalerWallet1/Views/Transactions/TransactionsListView.swift
@@ -88,6 +88,7 @@ extension TransactionsListView {
// }
// }
+ @State var viewId = UUID()
var body: some View {
#if DEBUG
let _ = Self._printChanges()
@@ -97,7 +98,6 @@ extension TransactionsListView {
ScrollViewReader { scrollView in
List {
ForEach(Array(zip(transactions.indices, transactions)),
id: \.1) { index, transaction in
-// let common = transaction.common
NavigationLink { LazyView { // whole row like
in a tableView
// pending may not be deleted, but only aborted
TransactionDetailView(transactionId:
transaction.id,
@@ -115,7 +115,7 @@ extension TransactionsListView {
.refreshable {
symLog?.log("refreshing")
await reloadAllAction()
- }
+ }.id(viewId)
.listStyle(myListStyle.style).anyView
.onAppear {
upAction = { withAnimation { scrollView.scrollTo(0) }}
diff --git a/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawTOSView.swift
b/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawTOSView.swift
index f0efbd2..6197077 100644
--- a/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawTOSView.swift
+++ b/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawTOSView.swift
@@ -30,7 +30,7 @@ struct WithdrawTOSView: View {
_ = try await
model.setExchangeTOSAcceptedM(exchangeBaseUrl, etag: exchangeTOS!.currentEtag)
if acceptAction != nil {
acceptAction!()
- } else {
+ } else { // just go back - caller will reload
self.presentationMode.wrappedValue.dismiss()
}
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] 21/54: Sounds, P2P receive, (continued)
- [taler-taler-ios] 21/54: Sounds, P2P receive, gnunet, 2023/06/30
- [taler-taler-ios] 07/54: Big Model update, removed unneccessary thread-safety code, gnunet, 2023/06/30
- [taler-taler-ios] 41/54: playSound, gnunet, 2023/06/30
- [taler-taler-ios] 30/54: bugfix, gnunet, 2023/06/30
- [taler-taler-ios] 43/54: confirmTransferUrl, gnunet, 2023/06/30
- [taler-taler-ios] 33/54: log only release builds, gnunet, 2023/06/30
- [taler-taler-ios] 27/54: Logging, gnunet, 2023/06/30
- [taler-taler-ios] 38/54: actions, gnunet, 2023/06/30
- [taler-taler-ios] 28/54: playSound, gnunet, 2023/06/30
- [taler-taler-ios] 32/54: Adjust DebugView for Notch, gnunet, 2023/06/30
- [taler-taler-ios] 20/54: viewID + comments,
gnunet <=
- [taler-taler-ios] 31/54: bump Testflight version, gnunet, 2023/06/30
- [taler-taler-ios] 37/54: Decodable, gnunet, 2023/06/30
- [taler-taler-ios] 29/54: Model cleanup, gnunet, 2023/06/30
- [taler-taler-ios] 36/54: playSound, gnunet, 2023/06/30
- [taler-taler-ios] 44/54: BalanceReloaded, gnunet, 2023/06/30
- [taler-taler-ios] 35/54: developerMode, gnunet, 2023/06/30
- [taler-taler-ios] 45/54: TransactionDetails, gnunet, 2023/06/30
- [taler-taler-ios] 39/54: Scrollview, gnunet, 2023/06/30
- [taler-taler-ios] 25/54: failTransaction, gnunet, 2023/06/30
- [taler-taler-ios] 23/54: Remove old view, gnunet, 2023/06/30