commit 8d7ffb90963038fefb4cac3aabc1ac81beb1ae7c
parent 76ae4440248ba3c2e0a703c3bc14b75fa2134029
Author: Nitesh Balusu <niteshbalusu@icloud.com>
Date: Tue, 20 Dec 2022 10:49:35 -0500
switch to using securefield
Signed-off-by: Nitesh Balusu <niteshbalusu@icloud.com>
Diffstat:
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/damus/Views/ConfigView.swift b/damus/Views/ConfigView.swift
@@ -4,7 +4,6 @@
//
// Created by William Casarin on 2022-06-09.
//
-
import AVFoundation
import SwiftUI
@@ -14,7 +13,13 @@ struct ConfigView: View {
@State var show_add_relay: Bool = false
@State var confirm_logout: Bool = false
@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 {
ZStack(alignment: .leading) {
@@ -47,7 +52,10 @@ struct ConfigView: View {
if let sec = state.keypair.privkey_bech32 {
Section("Secret Account Login Key") {
- if isHidden == false {
+ if showPrivateKey == false {
+ SecureField("PrivateKey", text: $privateKey)
+ .disabled(true)
+ } else {
Text(sec)
.textSelection(.enabled)
.onTapGesture {
@@ -62,14 +70,8 @@ struct ConfigView: View {
}
)
}
-
- if isHidden == true {
- Text("*******")
- }
- Button("Show/Hide Key") {
- isHidden.toggle()
- }
+ Toggle("Show PrivateKey", isOn: $showPrivateKey)
}
}