having real time user listened to in authlistener

This commit is contained in:
talksik
2021-12-19 21:15:01 -08:00
parent eea799feec
commit 298f824330
6 changed files with 48 additions and 14 deletions
@@ -90,7 +90,7 @@ struct AddBasicInfoView: View {
.font(.subheadline)
.multilineTextAlignment(.center)
Text("What does your friends call you?")
Text("What do your friends call you?")
.font(.footnote)
.foregroundColor(Color.black.opacity(0.7))
@@ -129,6 +129,13 @@ struct AddBasicInfoView: View {
}
.frame(maxHeight: .infinity)
}
.onAppear {
// get current user nickname and avatar if they have one
self.nickname = self.authSessionStore.user?.nickname ?? ""
if self.authSessionStore.user?.avatar != nil { // if user has previously selected an avatar
self.selectedAvatarIndex = Avatars.avatarSystemNames.firstIndex(of: (self.authSessionStore.user?.avatar)!) ?? 0 // 0 in case the system names doesn't have it anymore
}
}
//TODO: hook up the alert with the view model
// .alert(isPresented: Binding<Bool>(
// get: { self.addInfoViewModel.state == ProfileRegistrationState.failed},
@@ -41,6 +41,8 @@ class AddBasicInfoViewModel : ObservableObject {
// save in firestore
self.firestoreService.updateUser(user: currUser) {res in
print(res)
switch res {
case .success:
self.state = .successful
@@ -344,17 +344,21 @@ struct InnerCircleView: View {
.font(.title2)
Menu {
Button("Edit Profile") {
self.navigationStack.push(AddBasicInfoView())
}
Button("Friends") {
print("manage friends page")
}
Button("Log out") {
print("log out button clicked")
// have this send it
self.authSessionStore.logOut()
// once logged out, then the listener will listen and change the page but we will go there first
self.navigationStack.push(ContentView())
}
Button("Friends") {
print("manage friends page")
// once logged out, then the listener will listen and router view will take care of us thereafter
}
} label: {
Image("Artboards_Diversity_Avatars_by_Netguru-51")
@@ -35,19 +35,24 @@ struct RouterView: View {
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
WelcomeView()
.transition(.slide)
} else {
SplashView()
.transition(.slide)
}
}
}