forked from Path-Check/gaen-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
63 lines (56 loc) · 1.9 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import React, { FunctionComponent, useState, useEffect } from "react"
import SplashScreen from "react-native-splash-screen"
import "array-flat-polyfill"
import env from "react-native-config"
import MainNavigator from "./src/navigation/MainNavigator"
import { ErrorBoundary } from "./src/ErrorBoundaries"
import { ExposureProvider } from "./src/ExposureContext"
import {
OnboardingProvider,
onboardingHasBeenCompleted,
} from "./src/OnboardingContext"
import { ConfigurationProvider } from "./src/ConfigurationContext"
import { PermissionsProvider } from "./src/PermissionsContext"
import { SystemServicesProvider } from "./src/SystemServicesContext"
import { initializei18next, loadUserLocale } from "./src/locales/languages"
import Logger from "./src/logger"
Logger.start()
const App: FunctionComponent = () => {
const [isLoading, setIsLoading] = useState(true)
const [onboardingIsComplete, setOnboardingIsComplete] = useState(false)
useEffect(() => {
const locales = env.SUPPORTED_LOCALES?.split(",") || []
initializei18next(locales)
loadUserLocale()
onboardingHasBeenCompleted()
.then((onboardingHasBeenCompleted) => {
setOnboardingIsComplete(onboardingHasBeenCompleted)
})
.finally(() => {
setIsLoading(false)
SplashScreen.hide()
})
}, [])
return (
<>
{!isLoading ? (
<ErrorBoundary>
<ConfigurationProvider>
<OnboardingProvider
userHasCompletedOnboarding={onboardingIsComplete}
>
<PermissionsProvider>
<SystemServicesProvider>
<ExposureProvider>
<MainNavigator />
</ExposureProvider>
</SystemServicesProvider>
</PermissionsProvider>
</OnboardingProvider>
</ConfigurationProvider>
</ErrorBoundary>
) : null}
</>
)
}
export default App