cleaning up routing
This commit is contained in:
@@ -9,19 +9,9 @@ import SwiftUI
|
|||||||
import NavigationStack
|
import NavigationStack
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
@EnvironmentObject var authSessionStore: AuthSessionStore
|
|
||||||
|
|
||||||
// welcome -> phone verification -> phone code verification -> onboarding trio -> first, last, avatar picker -> add contacts -> hub
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStackView {
|
NavigationStackView {
|
||||||
AddBasicInfoView()
|
RouterView()
|
||||||
// TODO: remove this commenting to enable natural user flow
|
|
||||||
// switch self.authSessionStore.sessionState {
|
|
||||||
// case SessionState.isAuthenticated:
|
|
||||||
// InnerCircleView()
|
|
||||||
// case SessionState.isLoggedOut:
|
|
||||||
// WelcomeView()
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ import FirebaseFirestoreSwift
|
|||||||
|
|
||||||
struct User: Identifiable, Codable {
|
struct User: Identifiable, Codable {
|
||||||
@DocumentID var id: String? = UUID().uuidString
|
@DocumentID var id: String? = UUID().uuidString
|
||||||
var firstName: String?
|
var nickname: String?
|
||||||
var lastName: String?
|
|
||||||
var phoneNumber: String?
|
var phoneNumber: String?
|
||||||
var emailAddress:String?
|
var emailAddress:String?
|
||||||
var avatar:String?
|
var avatar:String?
|
||||||
@@ -20,8 +19,7 @@ struct User: Identifiable, Codable {
|
|||||||
@ServerTimestamp var createdTimestamp: Date?
|
@ServerTimestamp var createdTimestamp: Date?
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case firstName
|
case nickname
|
||||||
case lastName
|
|
||||||
case phoneNumber
|
case phoneNumber
|
||||||
case emailAddress
|
case emailAddress
|
||||||
case avatar
|
case avatar
|
||||||
|
|||||||
@@ -6,21 +6,55 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import NavigationStack
|
||||||
|
|
||||||
// show the loading screen while we figure out where to send the user through the nav stack
|
enum NavigationPages {
|
||||||
|
case welcome
|
||||||
|
case auth
|
||||||
|
case intro
|
||||||
|
case createProfile
|
||||||
|
case circle
|
||||||
|
}
|
||||||
|
|
||||||
|
// show the loading/splash screen while we figure out where to send the user through the nav stack
|
||||||
|
|
||||||
|
// if not authenticated -> push to welcome
|
||||||
|
// if authenticated
|
||||||
|
// if no profile pic and name and all -> go through onboarding again
|
||||||
|
// if has everythign in place -> homeview and get talking/chatting
|
||||||
|
|
||||||
|
|
||||||
|
// Purpose: want to use programmatic and maintain the same nav stack but take the user to the right place
|
||||||
struct RouterView: View {
|
struct RouterView: View {
|
||||||
// if not authenticated -> push to welcome
|
@EnvironmentObject var authSessionStore: AuthSessionStore
|
||||||
// if authenticated
|
@EnvironmentObject var navigationStack: NavigationStack
|
||||||
// if no profile pic and name and all -> go through onboarding again
|
|
||||||
// if has everythign in place -> homeview and get talking/chatting
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
SplashView()
|
||||||
|
.onAppear() {
|
||||||
|
print(authSessionStore)
|
||||||
|
print("figuring out where to send the user based on \(self.authSessionStore)")
|
||||||
|
if authSessionStore.sessionState == SessionState.isAuthenticated {
|
||||||
|
if let user = authSessionStore.user {
|
||||||
|
// evaluate where the user should go based on how much data he has
|
||||||
|
|
||||||
|
// user is authenticated but has never picked a username or avatar
|
||||||
|
if user.nickname != nil && user.avatar != nil {
|
||||||
|
self.navigationStack.push(OnboardingTrioView())
|
||||||
|
} else {// user is existing user for a year -> signs in is pushed nicely right to hub
|
||||||
|
self.navigationStack.push(InnerCircleView())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// go to welcome page at which point they can go and follow the programmatic
|
||||||
|
// line to the sigin and so on and so forth
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RouterView_Previews: PreviewProvider {
|
struct RouterView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
RouterView()
|
RouterView().environmentObject(AuthSessionStore())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user