-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
74 lines (58 loc) · 1.87 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
70
71
72
73
74
import { StatusBar } from 'expo-status-bar';
import React, {useState, useEffect} from 'react';
import { Platform, StyleSheet, Text, View } from 'react-native';
import { MainTabBottomNavigator } from './navigation/MainTabBottomNavigator';
import { enableScreens } from 'react-native-screens';
import Layout from './constants/Layout';
import * as SplashScreen from 'expo-splash-screen';
import * as Font from 'expo-font';
const BOTTOM_BAR_HEIGHT = !Platform.isPad ? 29 : 49
//to improve performance
enableScreens();
// to prevent the splash-screen from auto-hiding
SplashScreen. preventAutoHideAsync();
//google-fonts
const getFonts=()=> Font.loadAsync({
'libre-baskerville-bold': require('./assets/fonts/LibreBaskerville-Bold.ttf'),
'libre-baskerville-regular-italic': require('./assets/fonts/LibreBaskerville-Italic.ttf'),
'libre-baskerville-regular': require('./assets/fonts/LibreBaskerville-Regular.ttf')
});
export default function App() {
const[fontsLoaded, setFontsLoaded] = useState(false);
useEffect(()=>{
const loadResourcesAndDataAsync = async()=>{
try{
//to loading fonts
await getFonts();
}catch(error){
console.warn(error);
}finally{
setFontsLoaded(true);
//to hide splashScreen
SplashScreen.hideAsync();
};
};
loadResourcesAndDataAsync();
},[]);
if(!fontsLoaded){
return null;
}else{
return (
<MainTabBottomNavigator style={styles.container}/>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection:'column',
justifyContent:'center',
alignContent:'center',
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
fontFamily: 'libre-baskerville-bold',
width: Layout.window.width - 30,
height: Layout.window.height - BOTTOM_BAR_HEIGHT*6,
},
});