Add logout button, and show account keys
Changelog-Added: Show logout button and account keys in config Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -127,6 +127,12 @@ extension Notification.Name {
|
||||
}
|
||||
}
|
||||
|
||||
extension Notification.Name {
|
||||
static var logout: Notification.Name {
|
||||
return Notification.Name("logout")
|
||||
}
|
||||
}
|
||||
|
||||
extension Notification.Name {
|
||||
static var followed: Notification.Name {
|
||||
return Notification.Name("followed")
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import AVFoundation
|
||||
|
||||
struct ConfigView: View {
|
||||
let state: DamusState
|
||||
@Environment(\.dismiss) var dismiss
|
||||
@State var show_add_relay: Bool = false
|
||||
@State var confirm_logout: Bool = false
|
||||
@State var new_relay: String = ""
|
||||
|
||||
func Relay(_ ev: NostrEvent, relay: String) -> some View {
|
||||
@@ -45,6 +47,32 @@ struct ConfigView: View {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Section("Public Account ID") {
|
||||
Text(state.keypair.pubkey_bech32)
|
||||
.textSelection(.enabled)
|
||||
.onTapGesture {
|
||||
UIPasteboard.general.string = state.keypair.pubkey_bech32
|
||||
AudioServicesPlaySystemSound(SystemSoundID(kSystemSoundID_Vibrate))
|
||||
}
|
||||
}
|
||||
|
||||
if let sec = state.keypair.privkey_bech32 {
|
||||
Section("Secret Account Login Key") {
|
||||
Text(sec)
|
||||
.textSelection(.enabled)
|
||||
.onTapGesture {
|
||||
UIPasteboard.general.string = sec
|
||||
AudioServicesPlaySystemSound(SystemSoundID(kSystemSoundID_Vibrate))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Section("Reset") {
|
||||
Button("Logout") {
|
||||
confirm_logout = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VStack {
|
||||
@@ -63,6 +91,16 @@ struct ConfigView: View {
|
||||
}
|
||||
.navigationTitle("Settings")
|
||||
.navigationBarTitleDisplayMode(.large)
|
||||
.alert("Logout", isPresented: $confirm_logout) {
|
||||
Button("Logout") {
|
||||
notify(.logout, ())
|
||||
}
|
||||
Button("Cancel") {
|
||||
confirm_logout = false
|
||||
}
|
||||
} message: {
|
||||
Text("Make sure your nsec account key is saved before you logout or you will lose access to this account")
|
||||
}
|
||||
.sheet(isPresented: $show_add_relay) {
|
||||
AddRelayView(show_add_relay: $show_add_relay, relay: $new_relay) { _ in
|
||||
guard let url = URL(string: new_relay) else {
|
||||
|
||||
@@ -35,6 +35,9 @@ struct MainView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.onReceive(handle_notify(.logout)) { _ in
|
||||
keypair = nil
|
||||
}
|
||||
.onAppear {
|
||||
keypair = get_saved_keypair()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user