From 5d6384918ecaaea1cfa19e2daf068257d3923d9d Mon Sep 17 00:00:00 2001 From: dankito Date: Sun, 9 Aug 2020 15:52:20 +0200 Subject: [PATCH] Implemented deleting account --- .../src/main/res/values-de/strings.xml | 2 +- .../Base.lproj/Localizable.strings | 6 +++++ .../de.lproj/Localizable.strings | 6 +++++ .../ui/views/BankSettingsDialog.swift | 25 +++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/ui/BankingAndroidApp/src/main/res/values-de/strings.xml b/ui/BankingAndroidApp/src/main/res/values-de/strings.xml index 8ac3ff5e..9d3a2b3a 100644 --- a/ui/BankingAndroidApp/src/main/res/values-de/strings.xml +++ b/ui/BankingAndroidApp/src/main/res/values-de/strings.xml @@ -94,7 +94,7 @@ ATC muss eine Zahl sein.\n\nDer eingebene ATC Wert \'%s\' kann jedoch nicht in eine Zahl konvertiert werden. Möchten Sie das Konto \'%s\' wirklich löschen? - \n\nDies kann nicht rückgängig gemacht werden und die hierzu gespeicherten Daten gehen unwiederbringlich verloren. + \n\nDies kann nicht rückgängig gemacht werden und alle zu diesem Konto gespeicherten Daten gehen unwiederbringlich verloren. Bitte geben Sie den Namen des Empfängers ein diff --git a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings index 5f6f7f94..070987b8 100644 --- a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings +++ b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings @@ -6,6 +6,7 @@ "Add" = "Add"; "New" = "New"; "New ..." = "New ..."; +"Delete" = "Delete"; "Show less ..." = "Show less ..."; "Show all ..." = "Show all ..."; @@ -96,9 +97,14 @@ "Customer name" = "Customer name"; "FinTS server address" = "FinTS server address"; +"Delete account" = "Delete account"; + "Unsaved changes" = "Unsaved changes"; "Changed data hasn't been saved. Are you sure you want to discard them?" = "Changed data hasn't been saved. Are you sure you want to discard them?"; +"Delete account?" = "Delete account?"; +"Really delete account '%@'? This cannot be undone and data will be lost." = "Really delete account '%@'?\n\nThis cannot be undone and data will be lost."; + /* BankAccountSettingsDialog */ diff --git a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings index 94a76dd4..522a4d1e 100644 --- a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings +++ b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings @@ -6,6 +6,7 @@ "Add" = "Hinzufügen"; "New" = "Neu"; "New ..." = "Neu ..."; +"Delete" = "Löschen"; "Show less ..." = "Weniger anzeigen ..."; "Show all ..." = "Alles anzeigen ..."; @@ -96,9 +97,14 @@ "Customer name" = "Kontoinhaber"; "FinTS server address" = "FinTS Server"; +"Delete account" = "Konto löschen"; + "Unsaved changes" = "Nicht gespeicherte Änderungen"; "Changed data hasn't been saved. Are you sure you want to discard them?" = "Es wurden nicht alle Änderungen gespeichert. Sind Sie sich sicher, dass Sie sie verwerfen möchten?"; +"Delete account?" = "Konto löschen?"; +"Really delete account '%@'? This cannot be undone and data will be lost." = "Möchten Sie das Konto '%@' wirklich löschen?\n\nDies kann nicht rückgängig gemacht werden und alle zu diesem Konto gespeicherten Daten gehen unwiederbringlich verloren."; + /* BankAccountSettingsDialog */ diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankSettingsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankSettingsDialog.swift index 998ba826..27b4519a 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankSettingsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankSettingsDialog.swift @@ -21,6 +21,8 @@ struct BankSettingsDialog: View { @State private var unsavedChangesMessage: Message? = nil + @State private var askToDeleteAccountMessage: Message? = nil + private var hasUnsavedData: Bool { return bank.displayName != displayName @@ -77,15 +79,38 @@ struct BankSettingsDialog: View { } } } + + HStack { + Spacer() + + Button("Delete account", action: askUserToDeleteAccount) + .foregroundColor(Color.red) + + Spacer() + } } .alert(item: $unsavedChangesMessage) { message in Alert(title: message.title, message: message.message, primaryButton: message.primaryButton, secondaryButton: message.secondaryButton!) } + .alert(item: $askToDeleteAccountMessage) { message in + Alert(title: message.title, message: message.message, primaryButton: message.primaryButton, secondaryButton: message.secondaryButton!) + } .showNavigationBarTitle(LocalizedStringKey(bank.displayName)) .setCancelAndDoneNavigationBarButtons(onCancelPressed: cancelPressed, onDonePressed: donePressed) } + func askUserToDeleteAccount() { + self.askToDeleteAccountMessage = Message(title: Text("Delete account?"), message: Text("Really delete account '\(bank.displayName)'? This cannot be undone and data will be lost."), primaryButton: .destructive(Text("Delete"), action: deleteAccount), secondaryButton: .cancel()) + } + + func deleteAccount() { + presenter.deleteAccount(customer: bank) + + closeDialog() + } + + 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())