Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion app/dime/Views/TransactionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this commented-out code if it is not required in the future

Expand Down Expand Up @@ -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 {
Expand Down