-
Notifications
You must be signed in to change notification settings - Fork 6
/
App.tsx
77 lines (66 loc) · 2.08 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import React from 'react'
import { LogBox } from 'react-native'
import { NavigationContainer } from '@react-navigation/native'
import { IntlProvider } from 'react-intl'
import { PersistGate } from 'redux-persist/es/integration/react'
import { Provider } from 'react-redux'
import { store, persistor } from './redux/store'
import useCachedResources from './hooks/useCachedResources'
import Navigation from './navigation/Navigation'
import { LocaleSelector } from './redux/patient/patient.selectors'
import {
DEFAULT_LANGUAGE_CODE,
translationsForCode,
} from './constants/languages'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import useBestAvailableLanguage from './hooks/useBestAvailableLanguage'
import * as Notifications from 'expo-notifications'
LogBox.ignoreLogs([
"[react-native-gesture-handler] Seems like you're using an old API with gesture components, check out new Gestures system!",
])
const App = () => {
const isLoadingComplete = useCachedResources()
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: true,
shouldSetBadge: false,
}),
})
if (!isLoadingComplete) {
return null
} else {
return (
<SafeAreaProvider>
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<PersistGateConsumer />
</PersistGate>
</Provider>
</SafeAreaProvider>
)
}
}
const PersistGateConsumer = () => {
const localeStored = LocaleSelector()
const bestAvailableLanguage = useBestAvailableLanguage()
const locale = localeStored ? localeStored : bestAvailableLanguage
return (
<IntlProvider
locale={locale}
messages={translationsForCode(locale)}
defaultLocale={DEFAULT_LANGUAGE_CODE}
onError={(err) => {
if (err.code === 'MISSING_TRANSLATION') {
throw err
}
console.log('IntlProvider Err', err)
}}
>
<NavigationContainer>
<Navigation />
</NavigationContainer>
</IntlProvider>
)
}
export default App