From 31c6408d6250223181c829390161d5a08813bca8 Mon Sep 17 00:00:00 2001 From: MAcosta7 Date: Sat, 30 Aug 2025 20:05:23 -0400 Subject: [PATCH] Added confirmation dialog to discard changes when price or note is changed by the user. --- app/dime/Views/TransactionView.swift | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/dime/Views/TransactionView.swift b/app/dime/Views/TransactionView.swift index 5945aaf..a3f14ca 100644 --- a/app/dime/Views/TransactionView.swift +++ b/app/dime/Views/TransactionView.swift @@ -223,6 +223,9 @@ struct TransactionView: View { @State var isEditingDecimal = false @State var decimalValuesAssigned: AssignedDecimal = .none @State private var priceString: String = "0" + + // Discard Changes Confirmation Dialog + @State private var showDiscardChangesDialog: Bool = false var body: some View { GeometryReader { proxy in @@ -301,7 +304,11 @@ struct TransactionView: View { .overlay { HStack { Button { - dismiss() + if price != 0 || note.isEmpty == false { + showDiscardChangesDialog = true + } else { + dismiss() + } } label: { Image(systemName: "xmark") // .font(.system(size: 16, weight: .semibold)) @@ -925,6 +932,15 @@ struct TransactionView: View { swipingOffset = capsuleWidth } } + .confirmationDialog("Are you sure you want to discard your changes?", isPresented: $showDiscardChangesDialog) { + Button(role: .destructive) { + dismiss() + } label: { + Text("Discard Changes") + } + } message: { + Text("This action will discard any unsaved changes.") + } } func isDateToday(date: Date) -> Bool {