|
1 | 1 | import * as Font from "expo-font";
|
| 2 | +import * as SplashScreen from "expo-splash-screen"; |
2 | 3 | import { StatusBar } from "expo-status-bar";
|
3 | 4 | import type { FC } from "react";
|
4 | 5 | import * as React from "react";
|
@@ -30,6 +31,9 @@ import {
|
30 | 31 | TrackerUtils,
|
31 | 32 | } from "./src/utils";
|
32 | 33 |
|
| 34 | +// Keep the splash screen visible while we fetch resources |
| 35 | +void SplashScreen.preventAutoHideAsync(); |
| 36 | + |
33 | 37 | setNotificationHandler();
|
34 | 38 | initLocales();
|
35 | 39 | initMonitoring();
|
@@ -138,17 +142,24 @@ const MainAppContainer: FC = () => {
|
138 | 142 |
|
139 | 143 | void init();
|
140 | 144 | // Permet de détecter lorsque l'app change d'état ('active' | 'background' | 'inactive' | 'unknown' | 'extension')
|
141 |
| - AppState.addEventListener("change", handleAppStateChange); |
| 145 | + const subscription = AppState.addEventListener( |
| 146 | + "change", |
| 147 | + handleAppStateChange |
| 148 | + ); |
142 | 149 |
|
143 | 150 | return () => {
|
144 |
| - AppState.removeEventListener("change", handleAppStateChange); |
| 151 | + subscription.remove(); |
145 | 152 | };
|
146 | 153 | // eslint-disable-next-line react-hooks/exhaustive-deps
|
147 | 154 | }, []);
|
148 | 155 |
|
149 | 156 | useEffect(() => {
|
150 | 157 | if (isLoadingComplete && fontsLoaded && appCounterIsLoaded) {
|
151 |
| - setScreenCanBeDisplayed(true); |
| 158 | + const hideSplashScreen = async () => { |
| 159 | + await SplashScreen.hideAsync(); |
| 160 | + setScreenCanBeDisplayed(true); |
| 161 | + }; |
| 162 | + void hideSplashScreen(); |
152 | 163 | }
|
153 | 164 | }, [isLoadingComplete, fontsLoaded, appCounterIsLoaded]);
|
154 | 165 |
|
|
0 commit comments