-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
67 lines (58 loc) · 1.82 KB
/
App.js
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
import {
DarkTheme,
DefaultTheme,
NavigationContainer
} from '@react-navigation/native'
import 'fast-text-encoding'
import React, { useEffect } from 'react'
import { StatusBar } from 'react-native'
import { ToastProvider } from 'react-native-toast-notifications'
import { Provider, useDispatch } from 'react-redux'
import Toast from './src/components/toast/Toast'
import ToastManager from './src/components/toast/ToastManager'
import LanguageProvider from './src/contexts/LanguageProvider'
import ThemeProvider, { useTheme } from './src/contexts/ThemeProvider'
import './src/i18n'
import AppNavigator from './src/navigation/AppNavigator'
import { checkAuthentication } from './src/store/slices/authSlice'
import { initializeLanguage } from './src/store/slices/languageSlice'
import { initializeTheme } from './src/store/slices/themeSlice'
import store from './src/store/store'
const App = () => {
const dispatch = useDispatch()
useEffect(() => {
dispatch(initializeTheme())
dispatch(initializeLanguage())
dispatch(checkAuthentication())
}, [dispatch])
return (
<ThemeProvider>
<LanguageProvider>
<AppContent />
</LanguageProvider>
</ThemeProvider>
)
}
const AppContent = () => {
const { isDarkMode } = useTheme()
const theme = isDarkMode ? DarkTheme : DefaultTheme
return (
<>
<StatusBar />
<NavigationContainer theme={theme}>
<AppNavigator />
</NavigationContainer>
</>
)
}
const RootApp = () => {
return (
<Provider store={store}>
<ToastProvider renderToast={toast => <Toast {...toast} />}>
<App />
<ToastManager />
</ToastProvider>
</Provider>
)
}
export default RootApp