damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 3fec9dd20943a3682c43283de5b0a094ac31c209
parent a560d50366e61fe084482b02de807df429804eb3
Author: ericholguin <eric.holguinsanchez@gmail.com>
Date:   Thu,  2 Mar 2023 16:16:42 -0700

Additional delete confirmation and sign out on config view

Changelog-Added: Add additional warning when deleting account
Closes: #729

Diffstat:
Mdamus/Views/ConfigView.swift | 33+++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/damus/Views/ConfigView.swift b/damus/Views/ConfigView.swift @@ -12,8 +12,10 @@ import Combine struct ConfigView: View { let state: DamusState + @Environment(\.colorScheme) var colorScheme @Environment(\.dismiss) var dismiss @State var confirm_logout: Bool = false + @State var delete_account_warning: Bool = false @State var confirm_delete_account: Bool = false @State var show_privkey: Bool = false @State var has_authenticated_locally: Bool = false @@ -35,6 +37,10 @@ struct ConfigView: View { _privkey = State(initialValue: self.state.keypair.privkey_bech32 ?? "") _settings = ObservedObject(initialValue: state.settings) } + + func textColor() -> Color { + colorScheme == .light ? Color("DamusBlack") : Color("DamusWhite") + } func authenticateLocally(completion: @escaping (Bool) -> Void) { // Need to authenticate only once while ConfigView is presented @@ -200,11 +206,25 @@ struct ConfigView: View { KingfisherManager.shared.cache.cleanExpiredDiskCache() } } + + Section(NSLocalizedString("Sign Out", comment: "Section title for signing out")) { + Button(action: { + if state.keypair.privkey == nil { + notify(.logout, ()) + } else { + confirm_logout = true + } + }, label: { + Label(NSLocalizedString("Sign out", comment: "Sidebar menu label to sign out of the account."), systemImage: "pip.exit") + .foregroundColor(textColor()) + .frame(maxWidth: .infinity, alignment: .leading) + }) + } if state.is_privkey_user { - Section(NSLocalizedString("Delete", comment: "Section title for deleting the user")) { + Section(NSLocalizedString("Permanently Delete Account", comment: "Section title for deleting the user")) { Button(NSLocalizedString("Delete Account", comment: "Button to delete the user's account."), role: .destructive) { - confirm_delete_account = true + delete_account_warning = true } } } @@ -218,6 +238,15 @@ struct ConfigView: View { } .navigationTitle(NSLocalizedString("Settings", comment: "Navigation title for Settings view.")) .navigationBarTitleDisplayMode(.large) + .alert(NSLocalizedString("WARNING:\n\nTHIS WILL SIGN AN EVENT THAT DELETES THIS ACCOUNT.\n\nYOU WILL NO LONGER BE ABLE TO LOG INTO DAMUS USING THIS ACCOUNT KEY.\n\n ARE YOU SURE YOU WANT TO CONTINUE?", comment: "Alert for deleting the users account."), isPresented: $delete_account_warning) { + + Button(NSLocalizedString("Cancel", comment: "Cancel deleting the user."), role: .cancel) { + delete_account_warning = false + } + Button(NSLocalizedString("Continue", comment: "Continue with deleting the user.")) { + confirm_delete_account = true + } + } .alert(NSLocalizedString("Permanently Delete Account", comment: "Alert for deleting the users account."), isPresented: $confirm_delete_account) { TextField(NSLocalizedString("Type DELETE to delete", comment: "Text field prompt asking user to type the word DELETE to confirm that they want to proceed with deleting their account. The all caps lock DELETE word should not be translated. Everything else should."), text: $delete_text) Button(NSLocalizedString("Cancel", comment: "Cancel deleting the user."), role: .cancel) {