navigation: remove SetupState and references and update navigation links for onboarding flow

This commit is contained in:
ericholguin
2023-05-26 14:09:03 -06:00
committed by William Casarin
parent 72cc4c1fd7
commit 15acdef912
4 changed files with 18 additions and 21 deletions

View File

@@ -26,6 +26,9 @@ struct CreateAccountView: View {
var body: some View { var body: some View {
ZStack(alignment: .top) { ZStack(alignment: .top) {
DamusGradient() DamusGradient()
NavigationLink(destination: SaveKeysView(account: account), isActive: $is_done) {
EmptyView()
}
VStack { VStack {
Text("Create Account") Text("Create Account")
@@ -73,8 +76,6 @@ struct CreateAccountView: View {
} }
} }
NavigationLink(destination: SaveKeysView(account: account), isActive: $is_done) {
EmptyView()
} }
DamusWhiteButton(NSLocalizedString("Create", comment: "Button to create account.")) { DamusWhiteButton(NSLocalizedString("Create", comment: "Button to create account.")) {

View File

@@ -8,7 +8,6 @@
import SwiftUI import SwiftUI
struct EULAView: View { struct EULAView: View {
var state: SetupState?
@Environment(\.dismiss) var dismiss @Environment(\.dismiss) var dismiss
@State var accepted = false @State var accepted = false
@@ -69,14 +68,12 @@ By using our Application, you signify your acceptance of this EULA. If you do no
""")) """))
.padding() .padding()
@State private var login = false
if state == .create_account { NavigationLink(destination: LoginView(accepted: $accepted), isActive: $login) {
NavigationLink(destination: CreateAccountView(), isActive: $accepted) {
EmptyView() EmptyView()
} }
} else {
NavigationLink(destination: LoginView(), isActive: $accepted) { }
EmptyView()
} }
} }
DamusWhiteButton(NSLocalizedString("Accept", comment: "Button to accept the end user license agreement before being allowed into the app.")) { DamusWhiteButton(NSLocalizedString("Accept", comment: "Button to accept the end user license agreement before being allowed into the app.")) {

View File

@@ -33,11 +33,14 @@ enum ParsedKey {
} }
struct LoginView: View { struct LoginView: View {
@State private var create_account = false
@State var key: String = "" @State var key: String = ""
@State var is_pubkey: Bool = false @State var is_pubkey: Bool = false
@State var error: String? = nil @State var error: String? = nil
@State private var credential_handler = CredentialHandler() @State private var credential_handler = CredentialHandler()
@Binding var accepted: Bool
func get_error(parsed_key: ParsedKey?) -> String? { func get_error(parsed_key: ParsedKey?) -> String? {
if self.error != nil { if self.error != nil {
return self.error return self.error
@@ -53,6 +56,12 @@ struct LoginView: View {
var body: some View { var body: some View {
ZStack(alignment: .top) { ZStack(alignment: .top) {
DamusGradient() DamusGradient()
if accepted {
NavigationLink(destination: CreateAccountView(), isActive: $create_account) {
EmptyView()
}
}
VStack { VStack {
Text("Login", comment: "Title of view to log into an account.") Text("Login", comment: "Title of view to log into an account.")
.foregroundColor(.white) .foregroundColor(.white)

View File

@@ -15,15 +15,9 @@ func hex_col(r: UInt8, g: UInt8, b: UInt8) -> Color {
opacity: 1.0) opacity: 1.0)
} }
enum SetupState {
case home
case create_account
case login
}
struct SetupView: View { struct SetupView: View {
@State var state: SetupState? = .home @State private var eula = false
var body: some View { var body: some View {
NavigationView { NavigationView {
@@ -31,10 +25,7 @@ struct SetupView: View {
DamusGradient() DamusGradient()
VStack(alignment: .center) { VStack(alignment: .center) {
NavigationLink(destination: EULAView(state: state), tag: .create_account, selection: $state ) { NavigationLink(destination: EULAView(), isActive: $eula) {
EmptyView()
}
NavigationLink(destination: EULAView(state: state), tag: .login, selection: $state ) {
EmptyView() EmptyView()
} }
@@ -79,7 +70,6 @@ func DamusWhiteButton(_ title: String, action: @escaping () -> ()) -> some View
.background(Color.white.opacity(0.15)) .background(Color.white.opacity(0.15))
) )
} }
} }
struct SetupView_Previews: PreviewProvider { struct SetupView_Previews: PreviewProvider {