cleaning up routing

This commit is contained in:
talksik
2021-12-19 05:14:27 -08:00
parent 501a495863
commit 909232b7a8
3 changed files with 44 additions and 22 deletions
+41 -7
View File
@@ -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())
}
}