-
Notifications
You must be signed in to change notification settings - Fork 26
/
App.js
62 lines (53 loc) · 1.51 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
import 'react-native-gesture-handler';
import React, { useState, useEffect, useCallback } from 'react';
import { Provider } from 'react-redux';
import {
ActionSheetProvider,
connectActionSheet,
} from '@expo/react-native-action-sheet';
import AppLoading from 'expo-app-loading';
import * as Font from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import AppNavigator from './navigation/AppNavigator';
import { ContextProvider } from './context/ContextProvider';
import store from './store/store';
SplashScreen.preventAutoHideAsync();
const fetchFonts = async () => {
const loadedFonts = await Font.loadAsync({
'poppins-regular': require('./assets/fonts/Poppins-Regular.ttf'),
'poppins-bold': require('./assets/fonts/Poppins-Bold.ttf'),
});
return loadedFonts;
};
const App = () => {
const [fontLoaded, setFontLoaded] = useState(false);
const stopSplash = async () => {
try {
await SplashScreen.hideAsync();
setFontLoaded(true);
} catch (error) {
console.log(error);
}
};
if (!fontLoaded) {
return (
<AppLoading
startAsync={fetchFonts}
onError={(err) => console.warn(err)}
onFinish={stopSplash}
autoHideSplash
/>
);
}
return (
<Provider store={store}>
<ActionSheetProvider>
<ContextProvider>
<AppNavigator theme="dark" />
</ContextProvider>
</ActionSheetProvider>
</Provider>
);
};
const ConnectedApp = connectActionSheet(App);
export default ConnectedApp;