navigation: remove SetupState and references and update navigation links for onboarding flow
This commit is contained in:
committed by
William Casarin
parent
72cc4c1fd7
commit
15acdef912
@@ -26,6 +26,9 @@ struct CreateAccountView: View {
|
||||
var body: some View {
|
||||
ZStack(alignment: .top) {
|
||||
DamusGradient()
|
||||
NavigationLink(destination: SaveKeysView(account: account), isActive: $is_done) {
|
||||
EmptyView()
|
||||
}
|
||||
|
||||
VStack {
|
||||
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.")) {
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
import SwiftUI
|
||||
|
||||
struct EULAView: View {
|
||||
var state: SetupState?
|
||||
@Environment(\.dismiss) var dismiss
|
||||
@State var accepted = false
|
||||
|
||||
@@ -69,14 +68,12 @@ By using our Application, you signify your acceptance of this EULA. If you do no
|
||||
|
||||
"""))
|
||||
.padding()
|
||||
@State private var login = false
|
||||
NavigationLink(destination: LoginView(accepted: $accepted), isActive: $login) {
|
||||
EmptyView()
|
||||
}
|
||||
|
||||
if state == .create_account {
|
||||
NavigationLink(destination: CreateAccountView(), isActive: $accepted) {
|
||||
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.")) {
|
||||
|
||||
@@ -33,10 +33,13 @@ enum ParsedKey {
|
||||
}
|
||||
|
||||
struct LoginView: View {
|
||||
@State private var create_account = false
|
||||
@State var key: String = ""
|
||||
@State var is_pubkey: Bool = false
|
||||
@State var error: String? = nil
|
||||
@State private var credential_handler = CredentialHandler()
|
||||
|
||||
@Binding var accepted: Bool
|
||||
|
||||
func get_error(parsed_key: ParsedKey?) -> String? {
|
||||
if self.error != nil {
|
||||
@@ -53,6 +56,12 @@ struct LoginView: View {
|
||||
var body: some View {
|
||||
ZStack(alignment: .top) {
|
||||
DamusGradient()
|
||||
if accepted {
|
||||
NavigationLink(destination: CreateAccountView(), isActive: $create_account) {
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
|
||||
VStack {
|
||||
Text("Login", comment: "Title of view to log into an account.")
|
||||
.foregroundColor(.white)
|
||||
|
||||
@@ -15,15 +15,9 @@ func hex_col(r: UInt8, g: UInt8, b: UInt8) -> Color {
|
||||
opacity: 1.0)
|
||||
}
|
||||
|
||||
enum SetupState {
|
||||
case home
|
||||
case create_account
|
||||
case login
|
||||
}
|
||||
|
||||
|
||||
struct SetupView: View {
|
||||
@State var state: SetupState? = .home
|
||||
@State private var eula = false
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
@@ -31,10 +25,7 @@ struct SetupView: View {
|
||||
DamusGradient()
|
||||
|
||||
VStack(alignment: .center) {
|
||||
NavigationLink(destination: EULAView(state: state), tag: .create_account, selection: $state ) {
|
||||
EmptyView()
|
||||
}
|
||||
NavigationLink(destination: EULAView(state: state), tag: .login, selection: $state ) {
|
||||
NavigationLink(destination: EULAView(), isActive: $eula) {
|
||||
EmptyView()
|
||||
}
|
||||
|
||||
@@ -79,7 +70,6 @@ func DamusWhiteButton(_ title: String, action: @escaping () -> ()) -> some View
|
||||
.background(Color.white.opacity(0.15))
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct SetupView_Previews: PreviewProvider {
|
||||
|
||||
Reference in New Issue
Block a user