-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
70 lines (59 loc) · 2.54 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
import React, { useState } from 'react';
import { StyleSheet, View, Text } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createDrawerNavigator } from '@react-navigation/drawer';
import Colors from './constants/Colors';
import { AppLoading } from 'expo';
import FontLoader from './functions/fonts/FontLoader';
import MainDrawer from './components/drawerMenus/MainDrawer';
import HomeScreen from './screens/HomeScreen';
import RPGSelectScreen from './screens/RPGSelectScreen';
import DieRollerScreen from './screens/DieRollerScreen';
import ErrorScreen from './screens/ErrorScreen';
import ICRPGSheetScreen from './screens/charSheets/ICRPGSheetScreen';
//Setting up the drawer menu that swipes out from the right
const Drawer = createDrawerNavigator();
export default function App() {
const [stateVars, setStateVars] = useState({
fontsLoaded: false,
});
//Using the FontLoader function to make sure all of the custom fonts are loaded before displaying the app
if (!stateVars.fontsLoaded) {
FontLoader.loadAllFonts()
.then(() => {
setStateVars((prevState) => {
return ({
...prevState,
fontsLoaded: true
});
});
})
.catch((error) => {
console.log("Fonts weren't loaded in App.js");
})
}
return (
<View style={styles.container}>
{stateVars.fontsLoaded && <NavigationContainer>
<Drawer.Navigator
drawerPosition={'right'}
drawerContent={props => <MainDrawer {...props} />}
>
<Drawer.Screen name="Home" component={HomeScreen} options={{ headerShown: false }}/>
<Drawer.Screen name="RPG Select" component={RPGSelectScreen} options={{headerShown: false}}/>
<Drawer.Screen name="Die Roller" component={DieRollerScreen} options={{ headerShown: false }}/>
<Drawer.Screen name="ICRPG Sheet" component={ICRPGSheetScreen} options={{ headerShown: false }}/>
<Drawer.Screen name="Error" component={ErrorScreen} options={{ headerShown: false }}/>
</Drawer.Navigator>
</NavigationContainer>}
{!stateVars.fontsLoaded && <AppLoading />}
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: Colors.shelf,
paddingTop: 30,
},
});