getting states read

This commit is contained in:
talksik
2021-12-28 14:47:51 -08:00
parent b1a22b715b
commit 6a0622f47a
2 changed files with 23 additions and 7 deletions
@@ -13,6 +13,7 @@ struct InnerCircleView: View {
@EnvironmentObject var authSessionStore: AuthSessionStore
@EnvironmentObject var navigationStack: NavigationStack
@State var selectedFriendIndex: String? = nil
let universalSize = UIScreen.main.bounds
+22 -7
View File
@@ -19,16 +19,31 @@ enum NavigationPages {
struct RouterView: View {
@EnvironmentObject var authSessionStore: AuthSessionStore
@EnvironmentObject var navigationStack: NavigationStack
@Environment(\.scenePhase) var scenePhase
var body: some View {
switch self.authSessionStore.sessionState {
case SessionState.notCheckedYet:
SplashView()
case SessionState.isAuthenticated:
InnerCircleView()
case SessionState.isLoggedOut:
WelcomeView()
ZStack {
switch self.authSessionStore.sessionState {
case SessionState.notCheckedYet:
SplashView()
case SessionState.isAuthenticated:
InnerCircleView()
case SessionState.isLoggedOut:
WelcomeView()
}
}
.onChange(of: scenePhase) { newPhase in
if newPhase == .inactive {
print("user is offline")
// set firestore user document isOnline to false
} else if newPhase == .active {
print("user is online again")
// set firestore user document isOnline to true
} else if newPhase == .background {
print("app is in backgroun")
}
}
}
}