damus

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

commit 16d81ed40fc03145b7dd91838b98134d6ecd1ead
parent 1135c19fea83d089da1e14781cf158b2797bac1e
Author: cr0bar <cr0bar@users.noreply.github.com>
Date:   Sat, 15 Jul 2023 20:07:39 +0100

Hide nsec when logging in

Fix for Hide nsec when logging in & add hide/show toggle

Closes: https://github.com/damus-io/damus/issues/1206
Changelog-Changed: Hide nsec when logging in

Diffstat:
Mdamus/Views/LoginView.swift | 36+++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)

diff --git a/damus/Views/LoginView.swift b/damus/Views/LoginView.swift @@ -115,6 +115,21 @@ struct LoginView: View { } } +extension View { + func nsecLoginStyle(key: String, title: String) -> some View { + self + .placeholder(when: key.isEmpty) { + Text(title).foregroundColor(.white.opacity(0.6)) + } + .padding(10) + .autocapitalization(.none) + .autocorrectionDisabled(true) + .textInputAutocapitalization(.never) + .font(.body.monospaced()) + .textContentType(.password) + } +} + func parse_key(_ thekey: String) -> ParsedKey? { var key = thekey if key.count > 0 && key.first! == "@" { @@ -255,6 +270,7 @@ func get_nip05_pubkey(id: String) async -> NIP05User? { struct KeyInput: View { let title: String let key: Binding<String> + @State private var is_secured: Bool = true init(_ title: String, key: Binding<String>) { self.title = title @@ -270,16 +286,18 @@ struct KeyInput: View { self.key.wrappedValue = pastedkey } } - TextField("", text: key) - .placeholder(when: key.wrappedValue.isEmpty) { - Text(title).foregroundColor(.white.opacity(0.6)) + if is_secured { + SecureField("", text: key) + .nsecLoginStyle(key: key.wrappedValue, title: title) + } else { + TextField("", text: key) + .nsecLoginStyle(key: key.wrappedValue, title: title) + } + Image(systemName: "eye.slash") + .foregroundColor(.gray) + .onTapGesture { + is_secured.toggle() } - .padding(10) - .autocapitalization(.none) - .autocorrectionDisabled(true) - .textInputAutocapitalization(.never) - .font(.body.monospaced()) - .textContentType(.password) } .padding(.horizontal, 10) .overlay {