[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 05/12: dismiss after delete
From: |
gnunet |
Subject: |
[taler-taler-ios] 05/12: dismiss after delete |
Date: |
Sun, 29 Sep 2024 10:14:21 +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 e7dfcd59b5ad3453f0e5c772224f6eff1a91e899
Author: Marc Stibane <marc@taler.net>
AuthorDate: Wed Sep 25 08:58:44 2024 +0200
dismiss after delete
---
.../Views/HelperViews/TransactionButton.swift | 31 +++++++------
.../Views/Transactions/TransactionSummaryV.swift | 54 +++++++++++++++++-----
2 files changed, 59 insertions(+), 26 deletions(-)
diff --git a/TalerWallet1/Views/HelperViews/TransactionButton.swift
b/TalerWallet1/Views/HelperViews/TransactionButton.swift
index d270dc8..32a3560 100755
--- a/TalerWallet1/Views/HelperViews/TransactionButton.swift
+++ b/TalerWallet1/Views/HelperViews/TransactionButton.swift
@@ -57,6 +57,7 @@ struct TransactionButton: View {
let transactionId: String
let command: TxAction
let warning: String?
+ @Binding var didExecute: Bool
let action: (_ transactionId: String, _ viewHandles: Bool) async throws ->
Void
@State private var disabled: Bool = false
@@ -69,6 +70,7 @@ struct TransactionButton: View {
if let _ = try? await action(transactionId, false) {
// symLog.log("\(executed) \(transactionId)")
executed = true // change button text
+ didExecute = true
}
}
}
@@ -91,18 +93,19 @@ struct TransactionButton: View {
}
// MARK: -
#if DEBUG
-struct TransactionButton_Previews: PreviewProvider {
-
- static func action(_ transactionId: String, _ viewHandles: Bool) async
throws {
- print(transactionId)
- }
-
- static var previews: some View {
- List {
- TransactionButton(transactionId: "Button pressed", command: .abort,
- warning: "Are you sure you want to abort this
transaction?",
- action: action)
- }
- }
-}
+//struct TransactionButton_Previews: PreviewProvider {
+//
+// static func action(_ transactionId: String, _ viewHandles: Bool) async
throws {
+// print(transactionId)
+// }
+//
+// static var previews: some View {
+// List {
+// TransactionButton(transactionId: "Button pressed", command:
.abort,
+// warning: "Are you sure you want to abort this
transaction?",
+// didExecute: <#Binding<Bool>#>,
+// action: action)
+// }
+// }
+//}
#endif
diff --git a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
index 65ca027..12e56a2 100755
--- a/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
+++ b/TalerWallet1/Views/Transactions/TransactionSummaryV.swift
@@ -40,6 +40,7 @@ struct TransactionSummaryV: View {
@Environment(\.colorScheme) private var colorScheme
@Environment(\.colorSchemeContrast) private var colorSchemeContrast
+ @Environment(\.presentationMode) var presentationMode:
Binding<PresentationMode>
@AppStorage("myListStyle") var myListStyle: MyListStyle = .automatic
#if DEBUG
@AppStorage("developerMode") var developerMode: Bool = true
@@ -47,7 +48,9 @@ struct TransactionSummaryV: View {
@AppStorage("developerMode") var developerMode: Bool = false
#endif
- @State var transaction: Transaction = Transaction(dummyCurrency:
DEMOCURRENCY)
+ @State private var ignoreThis: Bool = false
+ @State private var didDelete: Bool = false
+ @State var transaction = Transaction(dummyCurrency: DEMOCURRENCY)
@State var viewId = UUID()
func loadTransaction() async {
@@ -76,6 +79,15 @@ struct TransactionSummaryV: View {
return false
}
+ @MainActor
+ private func dismiss(_ stack: CallStack) {
+ if hasDone { // if this view is in a sheet then dissmiss the
whole sheet
+ dismissTop(stack.push())
+ } else { // on a NavigationStack just pop
+ presentationMode.wrappedValue.dismiss()
+ }
+ }
+
func checkReload(_ notification: Notification, _ logStr: String = "") {
if let transition = notification.userInfo?[TRANSACTIONTRANSITION] as?
TransactionTransition {
if transition.transactionId == transactionId { // is the
transition for THIS transaction?
@@ -110,11 +122,17 @@ struct TransactionSummaryV: View {
if developerMode {
if transaction.isSuspendable { if let suspendAction {
TransactionButton(transactionId: common.transactionId,
- command: .suspend, warning: nil,
action: suspendAction)
+ command: .suspend,
+ warning: nil,
+ didExecute: $ignoreThis,
+ action: suspendAction)
} }
if transaction.isResumable { if let resumeAction {
TransactionButton(transactionId: common.transactionId,
- command: .resume, warning: nil,
action: resumeAction)
+ command: .resume,
+ warning: nil,
+ didExecute: $ignoreThis,
+ action: resumeAction)
} }
} // Suspend + Resume buttons
Group {
@@ -164,19 +182,31 @@ struct TransactionSummaryV: View {
// warning: nil, action: abortAction)
// } } // Retry button
if transaction.isAbortable { if let abortAction {
- TransactionButton(transactionId: common.transactionId,
command: .abort,
- warning: String(localized: "Are you sure
you want to abort this transaction?"),
- action: abortAction)
+ TransactionButton(transactionId: common.transactionId,
+ command: .abort,
+ warning: String(localized: "Are
you sure you want to abort this transaction?"),
+ didExecute: $ignoreThis,
+ action: abortAction)
} } // Abort button
if transaction.isFailable { if let failAction {
- TransactionButton(transactionId: common.transactionId,
command: .fail,
- warning: String(localized: "Are you sure
you want to abandon this transaction?"),
- action: failAction)
+ TransactionButton(transactionId: common.transactionId,
+ command: .fail,
+ warning: String(localized: "Are
you sure you want to abandon this transaction?"),
+ didExecute: $ignoreThis,
+ action: failAction)
} } // Fail button
if transaction.isDeleteable { if let deleteAction {
- TransactionButton(transactionId: common.transactionId,
command: .delete,
- warning: String(localized: "Are you sure
you want to delete this transaction?"),
- action: deleteAction)
+ TransactionButton(transactionId: common.transactionId,
+ command: .delete,
+ warning: String(localized: "Are
you sure you want to delete this transaction?"),
+ didExecute: $didDelete,
+ action: deleteAction)
+ .onChange(of: didDelete) { wasDeleted in
+ if wasDeleted {
+ symLog.log("wasDeleted -> dismiss view")
+ dismiss(stack)
+ }
+ }
} } // Delete button
}.id(viewId) // change viewId to enforce a draw update
.listStyle(myListStyle.style).anyView
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] branch master updated (e921612 -> 16eefa4), gnunet, 2024/09/29
- [taler-taler-ios] 03/12: fixedInnerHeight, gnunet, 2024/09/29
- [taler-taler-ios] 02/12: currencyInput, gnunet, 2024/09/29
- [taler-taler-ios] 09/12: filterByState, gnunet, 2024/09/29
- [taler-taler-ios] 01/12: getMaxDepositAmount, getMaxPeerPushDebitAmount, gnunet, 2024/09/29
- [taler-taler-ios] 04/12: cleanup, gnunet, 2024/09/29
- [taler-taler-ios] 06/12: GetMaxPeerPushAmount, gnunet, 2024/09/29
- [taler-taler-ios] 12/12: German localization, gnunet, 2024/09/29
- [taler-taler-ios] 11/12: delete rows (swipeActions), gnunet, 2024/09/29
- [taler-taler-ios] 05/12: dismiss after delete,
gnunet <=
- [taler-taler-ios] 07/12: don't beep twice for expirations, gnunet, 2024/09/29
- [taler-taler-ios] 08/12: strikethrough, gnunet, 2024/09/29
- [taler-taler-ios] 10/12: cleanup, gnunet, 2024/09/29