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 {
|
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.")) {
|
||||||
|
|||||||
@@ -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
|
||||||
|
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.")) {
|
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 {
|
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 {
|
||||||
@@ -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)
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user