Browse Source

switch to using securefield

Signed-off-by: Nitesh Balusu <niteshbalusu@icloud.com>
post-button-style
Nitesh Balusu 2 years ago
committed by William Casarin
parent
commit
8d7ffb9096
  1. 22
      damus/Views/ConfigView.swift

22
damus/Views/ConfigView.swift

@ -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 {
@ -63,13 +71,7 @@ struct ConfigView: View {
) )
} }
if isHidden == true { Toggle("Show PrivateKey", isOn: $showPrivateKey)
Text("*******")
}
Button("Show/Hide Key") {
isHidden.toggle()
}
} }
} }

Loading…
Cancel
Save