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) .frame(width: 100, height: 100, alignment: .center)
.blur(radius: self.selectedAvatarIndex == index ? 0 : 1) .blur(radius: self.selectedAvatarIndex == index ? 0 : 1)
.scaleEffect(self.selectedAvatarIndex == index ? 1.3 : 1) .scaleEffect(self.selectedAvatarIndex == index ? 1.3 : 1)
.background(self.selectedAvatarIndex == index ? Color.white.opacity(0.3) : Color.clear)
.onTapGesture { .onTapGesture {
print("selected another avatar: \(index)") print("selected another avatar: \(index)")
@@ -107,8 +108,6 @@ struct AddBasicInfoView: View {
updatedUser?.avatar = Avatars.avatarSystemNames[self.selectedAvatarIndex] updatedUser?.avatar = Avatars.avatarSystemNames[self.selectedAvatarIndex]
updatedUser?.nickname = self.nickname updatedUser?.nickname = self.nickname
// TODO: I need these updated attributes to be listened to when loading the circle hub next
if updatedUser != nil { if updatedUser != nil {
self.addInfoViewModel.updateUser(currUser: updatedUser!) self.addInfoViewModel.updateUser(currUser: updatedUser!)
} }
@@ -12,7 +12,6 @@ struct InnerCircleView: View {
@EnvironmentObject var authSessionStore: AuthSessionStore @EnvironmentObject var authSessionStore: AuthSessionStore
@EnvironmentObject var navigationStack: NavigationStack @EnvironmentObject var navigationStack: NavigationStack
let universalSize = UIScreen.main.bounds let universalSize = UIScreen.main.bounds
// TESTING // TESTING
@@ -355,7 +354,6 @@ struct InnerCircleView: View {
Button("Log out") { Button("Log out") {
print("log out button clicked") print("log out button clicked")
// have this send it
self.authSessionStore.logOut() self.authSessionStore.logOut()
// once logged out, then the listener will listen and router view will take care of us thereafter // 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() Spacer()
Button { Button {
self.navigationStack.push(AddBasicInfoView())
} label: { } label: {
Text("Skip") Text("Skip")
.foregroundColor(NirvanaColor.dimTeal) .foregroundColor(NirvanaColor.dimTeal)
+4 -31
View File
@@ -16,43 +16,16 @@ enum NavigationPages {
case circle 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 {
@EnvironmentObject var authSessionStore: AuthSessionStore @EnvironmentObject var authSessionStore: AuthSessionStore
@EnvironmentObject var navigationStack: NavigationStack @EnvironmentObject var navigationStack: NavigationStack
var body: some View { var body: some View {
// authenticated and have user's data switch self.authSessionStore.sessionState {
if self.authSessionStore.sessionState == SessionState.isAuthenticated { case SessionState.isAuthenticated:
if self.authSessionStore.user != nil { InnerCircleView()
if self.authSessionStore.user?.nickname == nil && self.authSessionStore.user?.avatar == nil { case SessionState.isLoggedOut:
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
WelcomeView() WelcomeView()
.transition(.slide)
} else {
SplashView()
.transition(.slide)
} }
} }
} }