From 974d427e1a4c2dc4b04caa8b85470a9d3e4dc98c Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 24 Aug 2020 17:53:37 +0200 Subject: [PATCH] Implemented showing 'Discard' instead of 'OK' to discard changes --- .../BankingiOSApp/Base.lproj/Localizable.strings | 1 + .../BankingiOSApp/de.lproj/Localizable.strings | 1 + ui/BankingiOSApp/BankingiOSApp/ui/ViewExtensions.swift | 10 +++++++++- .../ui/views/BankAccountSettingsDialog.swift | 2 +- .../BankingiOSApp/ui/views/BankSettingsDialog.swift | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings index 0b54fdee..fc8067cf 100644 --- a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings +++ b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings @@ -2,6 +2,7 @@ "OK" = "OK"; "Cancel" = "Cancel"; "Done" = "Done"; +"Discard" = "Discard"; "Add" = "Add"; "New" = "New"; diff --git a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings index 7e33f7b4..d12617d9 100644 --- a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings +++ b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings @@ -2,6 +2,7 @@ "OK" = "OK"; "Cancel" = "Abbrechen"; "Done" = "Fertig"; +"Discard" = "Verwerfen"; "Add" = "Hinzufügen"; "New" = "Neu"; diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/ViewExtensions.swift b/ui/BankingiOSApp/BankingiOSApp/ui/ViewExtensions.swift index 6637b293..47220321 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/ViewExtensions.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/ViewExtensions.swift @@ -107,8 +107,16 @@ extension Color { extension Alert.Button { + public static func `default`(_ label: String, _ action: (() -> Void)? = {}) -> Alert.Button { + return .default(Text(label), action: action) + } + public static func ok(_ action: (() -> Void)? = {}) -> Alert.Button { - return .default(Text("OK"), action: action) + return .default("OK", action) + } + + public static func discard(_ action: (() -> Void)? = {}) -> Alert.Button { + return .destructive(Text("Discard"), action: action) } } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountSettingsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountSettingsDialog.swift index d66d73e2..9befa7f5 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountSettingsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountSettingsDialog.swift @@ -71,7 +71,7 @@ struct BankAccountSettingsDialog: View { private func cancelPressed() { if hasUnsavedData { - self.unsavedChangesMessage = Message(title: Text("Unsaved changes"), message: Text("Changed data hasn't been saved. Are you sure you want to discard them?"), primaryButton: .ok(closeDialog), secondaryButton: .cancel()) + self.unsavedChangesMessage = Message(title: Text("Unsaved changes"), message: Text("Changed data hasn't been saved. Are you sure you want to discard them?"), primaryButton: .discard(closeDialog), secondaryButton: .cancel()) } else { closeDialog() diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankSettingsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankSettingsDialog.swift index 006fd678..78fc3955 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankSettingsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankSettingsDialog.swift @@ -109,7 +109,7 @@ struct BankSettingsDialog: View { private func cancelPressed() { if hasUnsavedData { - self.askUserToDeleteAccountOrSaveChangesMessage = Message(title: Text("Unsaved changes"), message: Text("Changed data hasn't been saved. Are you sure you want to discard them?"), primaryButton: .ok(closeDialog), secondaryButton: .cancel()) + self.askUserToDeleteAccountOrSaveChangesMessage = Message(title: Text("Unsaved changes"), message: Text("Changed data hasn't been saved. Are you sure you want to discard them?"), primaryButton: .discard(closeDialog), secondaryButton: .cancel()) } else { closeDialog()