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 authSessionStore: AuthSessionStore
@EnvironmentObject var navigationStack: NavigationStack @EnvironmentObject var navigationStack: NavigationStack
@State var selectedFriendIndex: String? = nil @State var selectedFriendIndex: String? = nil
let universalSize = UIScreen.main.bounds let universalSize = UIScreen.main.bounds
+15
View File
@@ -19,8 +19,10 @@ enum NavigationPages {
struct RouterView: View { struct RouterView: View {
@EnvironmentObject var authSessionStore: AuthSessionStore @EnvironmentObject var authSessionStore: AuthSessionStore
@EnvironmentObject var navigationStack: NavigationStack @EnvironmentObject var navigationStack: NavigationStack
@Environment(\.scenePhase) var scenePhase
var body: some View { var body: some View {
ZStack {
switch self.authSessionStore.sessionState { switch self.authSessionStore.sessionState {
case SessionState.notCheckedYet: case SessionState.notCheckedYet:
SplashView() SplashView()
@@ -30,6 +32,19 @@ struct RouterView: View {
WelcomeView() 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")
}
}
}
} }
struct RouterView_Previews: PreviewProvider { struct RouterView_Previews: PreviewProvider {