You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

51 lines
1001 B

//
// damusApp.swift
// damus
//
// Created by William Casarin on 2022-04-01.
//
import SwiftUI
@main
struct damusApp: App {
var body: some Scene {
WindowGroup {
MainView()
}
}
}
struct MainView: View {
@State var needs_setup = false;
@State var keypair: Keypair? = nil;
var body: some View {
Group {
if let kp = keypair, !needs_setup {
ContentView(keypair: kp)
} else {
SetupView()
.onReceive(handle_notify(.login)) { notif in
needs_setup = false
keypair = get_saved_keypair()
}
}
}
.onReceive(handle_notify(.logout)) { _ in
try? clear_keypair()
keypair = nil
}
.onAppear {
keypair = get_saved_keypair()
}
}
}
func needs_setup() -> Keypair? {
return get_saved_keypair()
}