Implemented showing 'Discard' instead of 'OK' to discard changes

This commit is contained in:
dankito 2020-08-24 17:53:37 +02:00
parent aaa22bc2c1
commit 974d427e1a
5 changed files with 13 additions and 3 deletions

View File

@ -2,6 +2,7 @@
"OK" = "OK";
"Cancel" = "Cancel";
"Done" = "Done";
"Discard" = "Discard";
"Add" = "Add";
"New" = "New";

View File

@ -2,6 +2,7 @@
"OK" = "OK";
"Cancel" = "Abbrechen";
"Done" = "Fertig";
"Discard" = "Verwerfen";
"Add" = "Hinzufügen";
"New" = "Neu";

View File

@ -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)
}
}

View File

@ -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()

View File

@ -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()