switch to using securefield

Signed-off-by: Nitesh Balusu <niteshbalusu@icloud.com>
This commit is contained in:
Nitesh Balusu
2022-12-20 10:49:35 -05:00
committed by William Casarin
parent 76ae444024
commit 8d7ffb9096

View File

@@ -4,7 +4,6 @@
// //
// Created by William Casarin on 2022-06-09. // Created by William Casarin on 2022-06-09.
// //
import AVFoundation import AVFoundation
import SwiftUI import SwiftUI
@@ -14,7 +13,13 @@ struct ConfigView: View {
@State var show_add_relay: Bool = false @State var show_add_relay: Bool = false
@State var confirm_logout: Bool = false @State var confirm_logout: Bool = false
@State var new_relay: String = "" @State var new_relay: String = ""
@State var isHidden: Bool = true @State var showPrivateKey: Bool = false
@State var privateKey: String
init(state: DamusState) {
self.state = state
_privateKey = State(initialValue: self.state.keypair.privkey_bech32 ?? "")
}
var body: some View { var body: some View {
ZStack(alignment: .leading) { ZStack(alignment: .leading) {
@@ -47,7 +52,10 @@ struct ConfigView: View {
if let sec = state.keypair.privkey_bech32 { if let sec = state.keypair.privkey_bech32 {
Section("Secret Account Login Key") { Section("Secret Account Login Key") {
if isHidden == false { if showPrivateKey == false {
SecureField("PrivateKey", text: $privateKey)
.disabled(true)
} else {
Text(sec) Text(sec)
.textSelection(.enabled) .textSelection(.enabled)
.onTapGesture { .onTapGesture {
@@ -62,14 +70,8 @@ struct ConfigView: View {
} }
) )
} }
if isHidden == true {
Text("*******")
}
Button("Show/Hide Key") { Toggle("Show PrivateKey", isOn: $showPrivateKey)
isHidden.toggle()
}
} }
} }