Convert onboarding flow navigation links
This commit is contained in:
committed by
William Casarin
parent
242455410e
commit
c50ccef56d
@@ -10,8 +10,7 @@ import SwiftUI
|
||||
struct CreateAccountView: View {
|
||||
@StateObject var account: CreateAccountModel = CreateAccountModel()
|
||||
@StateObject var profileUploadViewModel = ProfileUploadingViewModel()
|
||||
|
||||
@State var is_done: Bool = false
|
||||
@EnvironmentObject var navigationCoordinator: NavigationCoordinator
|
||||
|
||||
func SignupForm<FormContent: View>(@ViewBuilder content: () -> FormContent) -> some View {
|
||||
return VStack(alignment: .leading, spacing: 10.0, content: content)
|
||||
@@ -25,10 +24,6 @@ struct CreateAccountView: View {
|
||||
|
||||
var body: some View {
|
||||
ZStack(alignment: .top) {
|
||||
NavigationLink(destination: SaveKeysView(account: account), isActive: $is_done) {
|
||||
EmptyView()
|
||||
}
|
||||
|
||||
VStack {
|
||||
VStack(alignment: .center) {
|
||||
ProfilePictureSelector(pubkey: account.pubkey, viewModel: profileUploadViewModel, callback: uploadedProfilePicture(image_url:))
|
||||
@@ -63,7 +58,7 @@ struct CreateAccountView: View {
|
||||
.padding(.top, 10)
|
||||
|
||||
Button(action: {
|
||||
self.is_done = true
|
||||
navigationCoordinator.push(route: Route.SaveKeys(account: account))
|
||||
}) {
|
||||
HStack {
|
||||
Text("Create account now", comment: "Button to create account.")
|
||||
|
||||
@@ -56,18 +56,13 @@ By using our Application, you signify your acceptance of this EULA. If you do no
|
||||
"""
|
||||
|
||||
struct EULAView: View {
|
||||
@State private var login = false
|
||||
@State var accepted = false
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
@Environment(\.dismiss) var dismiss
|
||||
@EnvironmentObject var navigationCoordinator: NavigationCoordinator
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
ScrollView {
|
||||
NavigationLink(destination: LoginView(accepted: $accepted), isActive: $login) {
|
||||
EmptyView()
|
||||
}
|
||||
|
||||
Text(Markdown.parse(content: eula))
|
||||
.padding()
|
||||
}
|
||||
@@ -96,8 +91,7 @@ struct EULAView: View {
|
||||
}
|
||||
|
||||
Button(action: {
|
||||
accepted = true
|
||||
login.toggle()
|
||||
navigationCoordinator.push(route: Route.Login)
|
||||
}) {
|
||||
HStack {
|
||||
Text("Accept", comment: "Button to accept the end user license agreement before being allowed into the app.")
|
||||
|
||||
@@ -33,13 +33,11 @@ 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
|
||||
@EnvironmentObject var navigationCoordinator: NavigationCoordinator
|
||||
|
||||
func get_error(parsed_key: ParsedKey?) -> String? {
|
||||
if self.error != nil {
|
||||
@@ -55,12 +53,6 @@ struct LoginView: View {
|
||||
|
||||
var body: some View {
|
||||
ZStack(alignment: .top) {
|
||||
if accepted {
|
||||
NavigationLink(destination: CreateAccountView(), isActive: $create_account) {
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
|
||||
VStack {
|
||||
SignInHeader()
|
||||
.padding(.top, 100)
|
||||
@@ -107,7 +99,8 @@ struct LoginView: View {
|
||||
.padding(.top, 10)
|
||||
}
|
||||
|
||||
CreateAccountPrompt(create_account: $create_account)
|
||||
CreateAccountPrompt()
|
||||
.environmentObject(navigationCoordinator)
|
||||
.padding(.top, 10)
|
||||
|
||||
Spacer()
|
||||
@@ -337,14 +330,14 @@ struct SignInEntry: View {
|
||||
}
|
||||
|
||||
struct CreateAccountPrompt: View {
|
||||
@Binding var create_account: Bool
|
||||
@EnvironmentObject var navigationCoordinator: NavigationCoordinator
|
||||
var body: some View {
|
||||
HStack {
|
||||
Text("New to Nostr?", comment: "Ask the user if they are new to Nostr")
|
||||
.foregroundColor(Color("DamusMediumGrey"))
|
||||
|
||||
Button(NSLocalizedString("Create account", comment: "Button to navigate to create account view.")) {
|
||||
create_account.toggle()
|
||||
navigationCoordinator.push(route: Route.CreateAccount)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
@@ -358,8 +351,8 @@ struct LoginView_Previews: PreviewProvider {
|
||||
let pubkey = "npub18m76awca3y37hkvuneavuw6pjj4525fw90necxmadrvjg0sdy6qsngq955"
|
||||
let bech32_pubkey = "KeyInput"
|
||||
Group {
|
||||
LoginView(key: pubkey, accepted: .constant(true))
|
||||
LoginView(key: bech32_pubkey, accepted: .constant(true))
|
||||
LoginView(key: pubkey)
|
||||
LoginView(key: bech32_pubkey)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,16 +17,12 @@ func hex_col(r: UInt8, g: UInt8, b: UInt8) -> Color {
|
||||
|
||||
|
||||
struct SetupView: View {
|
||||
@State private var eula = false
|
||||
@StateObject var navigationCoordinator: NavigationCoordinator = NavigationCoordinator()
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
NavigationStack(path: $navigationCoordinator.path) {
|
||||
ZStack {
|
||||
VStack(alignment: .center) {
|
||||
NavigationLink(destination: EULAView(), isActive: $eula) {
|
||||
EmptyView()
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
Image("logo-nobg")
|
||||
@@ -53,7 +49,7 @@ struct SetupView: View {
|
||||
Spacer()
|
||||
|
||||
Button(action: {
|
||||
eula.toggle()
|
||||
navigationCoordinator.push(route: Route.EULA)
|
||||
}) {
|
||||
HStack {
|
||||
Text("Let's get started!", comment: "Button to continue to login page.")
|
||||
@@ -72,6 +68,9 @@ struct SetupView: View {
|
||||
.ignoresSafeArea(),
|
||||
alignment: .top
|
||||
)
|
||||
.navigationDestination(for: Route.self) { route in
|
||||
route.view(navigationCordinator: navigationCoordinator, damusState: DamusState.empty)
|
||||
}
|
||||
}
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.navigationViewStyle(StackNavigationViewStyle())
|
||||
|
||||
Reference in New Issue
Block a user