fixing routing and flow and keeping it simple for now to move on and make it robust without errors

This commit is contained in:
talksik
2021-12-20 00:27:22 -08:00
parent 1a7995f360
commit 7452c54b25
4 changed files with 7 additions and 37 deletions
@@ -69,6 +69,7 @@ struct AddBasicInfoView: View {
.frame(width: 100, height: 100, alignment: .center)
.blur(radius: self.selectedAvatarIndex == index ? 0 : 1)
.scaleEffect(self.selectedAvatarIndex == index ? 1.3 : 1)
.background(self.selectedAvatarIndex == index ? Color.white.opacity(0.3) : Color.clear)
.onTapGesture {
print("selected another avatar: \(index)")
@@ -105,9 +106,7 @@ struct AddBasicInfoView: View {
print("attempting to save information")
var updatedUser = self.authSessionStore.user
updatedUser?.avatar = Avatars.avatarSystemNames[self.selectedAvatarIndex]
updatedUser?.nickname = self.nickname
// TODO: I need these updated attributes to be listened to when loading the circle hub next
updatedUser?.nickname = self.nickname
if updatedUser != nil {
self.addInfoViewModel.updateUser(currUser: updatedUser!)
@@ -12,7 +12,6 @@ struct InnerCircleView: View {
@EnvironmentObject var authSessionStore: AuthSessionStore
@EnvironmentObject var navigationStack: NavigationStack
let universalSize = UIScreen.main.bounds
// TESTING
@@ -355,7 +354,6 @@ struct InnerCircleView: View {
Button("Log out") {
print("log out button clicked")
// have this send it
self.authSessionStore.logOut()
// once logged out, then the listener will listen and router view will take care of us thereafter
@@ -53,7 +53,7 @@ struct OnboardingTrioView: View {
Spacer()
Button {
self.navigationStack.push(AddBasicInfoView())
} label: {
Text("Skip")
.foregroundColor(NirvanaColor.dimTeal)
+4 -31
View File
@@ -16,43 +16,16 @@ enum NavigationPages {
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 {
@EnvironmentObject var authSessionStore: AuthSessionStore
@EnvironmentObject var navigationStack: NavigationStack
var body: some View {
// authenticated and have user's data
if self.authSessionStore.sessionState == SessionState.isAuthenticated {
if self.authSessionStore.user != nil {
if self.authSessionStore.user?.nickname == nil && self.authSessionStore.user?.avatar == nil {
OnboardingTrioView()
.transition(.slide)
} else {// user is existing user/up and running user -> signs in is pushed nicely right to hub
InnerCircleView()
.transition(.slide)
}
} else {
OnboardingTrioView()
.transition(.slide)
}
} else if self.authSessionStore.sessionState == SessionState.isLoggedOut {
// go to welcome page at which point they can go and follow the programmatic
// line to the sigin and so on and so forth
switch self.authSessionStore.sessionState {
case SessionState.isAuthenticated:
InnerCircleView()
case SessionState.isLoggedOut:
WelcomeView()
.transition(.slide)
} else {
SplashView()
.transition(.slide)
}
}
}