cleaning up routing
This commit is contained in:
@@ -9,19 +9,9 @@ import SwiftUI
|
||||
import NavigationStack
|
||||
|
||||
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 {
|
||||
NavigationStackView {
|
||||
AddBasicInfoView()
|
||||
// TODO: remove this commenting to enable natural user flow
|
||||
// switch self.authSessionStore.sessionState {
|
||||
// case SessionState.isAuthenticated:
|
||||
// InnerCircleView()
|
||||
// case SessionState.isLoggedOut:
|
||||
// WelcomeView()
|
||||
// }
|
||||
RouterView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,7 @@ import FirebaseFirestoreSwift
|
||||
|
||||
struct User: Identifiable, Codable {
|
||||
@DocumentID var id: String? = UUID().uuidString
|
||||
var firstName: String?
|
||||
var lastName: String?
|
||||
var nickname: String?
|
||||
var phoneNumber: String?
|
||||
var emailAddress:String?
|
||||
var avatar:String?
|
||||
@@ -20,8 +19,7 @@ struct User: Identifiable, Codable {
|
||||
@ServerTimestamp var createdTimestamp: Date?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case firstName
|
||||
case lastName
|
||||
case nickname
|
||||
case phoneNumber
|
||||
case emailAddress
|
||||
case avatar
|
||||
|
||||
@@ -6,21 +6,55 @@
|
||||
//
|
||||
|
||||
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 {
|
||||
// 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
|
||||
@EnvironmentObject var authSessionStore: AuthSessionStore
|
||||
@EnvironmentObject var navigationStack: NavigationStack
|
||||
|
||||
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 {
|
||||
static var previews: some View {
|
||||
RouterView()
|
||||
RouterView().environmentObject(AuthSessionStore())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user