-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
69 lines (61 loc) · 2.04 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
68
69
import React, {useEffect} from 'react';
import {StyleSheet, View, StatusBar} from 'react-native';
import {Provider} from 'react-redux';
import {default as AsyncStorage2} from '@react-native-async-storage/async-storage';
import getStoredStateMigrateV4 from 'redux-persist/lib/integration/getStoredStateMigrateV4';
import SafeArea from 'react-native-safe-area';
import {persistReducer, persistStore} from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import {applyMiddleware, createStore} from 'redux';
import thunk from 'redux-thunk';
import {PersistGate} from 'redux-persist/integration/react';
import {NavigationContainer} from '@react-navigation/native';
import InitialSplashView from './src/component/Splash';
import AppReducer from './src/reducer';
import {Screen} from './src/navigation/screens';
// setup navigation
const persistConfig = {
key: 'root',
storage,
getStoredState: getStoredStateMigrateV4({
blacklist: ['navigation'],
storage: AsyncStorage2,
}),
timeout: 0,
};
const persistedReducer = persistReducer(persistConfig, AppReducer);
const store = createStore(persistedReducer, applyMiddleware(thunk));
const persistor = persistStore(store);
export default function App() {
const {container} = styles;
useEffect(() => {
setSafeArea();
}, []);
const setSafeArea = () => {
SafeArea.getSafeAreaInsetsForRootView().then(result => {
const temp = {
top: result.safeAreaInsets.top,
bottom: result.safeAreaInsets.bottom,
left: result.safeAreaInsets.left,
right: result.safeAreaInsets.right,
};
global.SafeArea = temp;
});
};
return (
<Provider store={store}>
<PersistGate loading={<InitialSplashView />} persistor={persistor}>
<View style={container}>
<StatusBar hidden={false} barStyle="light-content" />
<NavigationContainer>
<Screen />
</NavigationContainer>
</View>
</PersistGate>
</Provider>
);
}
// 9714714057
const styles = StyleSheet.create({
container: {flex: 1},
});