-
Notifications
You must be signed in to change notification settings - Fork 4
/
App.js
141 lines (127 loc) · 3.59 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import React, {useEffect, Fragment} from 'react';
import { createAppContainer, withNavigation } from 'react-navigation';
import { StyleSheet, Text, View, Image, Button, StatusBar, Platform } from 'react-native';
//added bottom tab navigator
import { createBottomTabNavigator } from 'react-navigation-tabs';
import * as Font from 'expo-font';
import { LIGHT_ORANGE, BLUE, LIGHT_GREEN } from './COLORS.js'
import * as SplashScreen from 'expo-splash-screen';
import {Asset} from 'expo-asset';
//Screens
import EventsNavigator from './screens/Events'
import MapNavigator from './screens/Map'
import ArtNavigator from './screens/Art'
import Icon from 'react-native-vector-icons/FontAwesome5';
const TabNavigator = createBottomTabNavigator({
Art: {
screen: ArtNavigator,
navigationOptions: {
tabBarIcon: ({focused, tintColor}) => {
return (
<Image
style={{ width: 35, height: 35, tintColor: focused ? LIGHT_ORANGE: 'grey'}}
source={require('./images/moodyOutlineLogo.png')}
color = {tintColor}
/>
)
}
}
},
Map: {
screen: MapNavigator,
navigationOptions: {
tabBarIcon: ({focused, tintColor}) => {
return (
<Image
style={{ width: 35, height: 35, tintColor: focused ? BLUE : 'grey'}}
source={require('./images/mapIconOutline.png')}
color = {tintColor}
/>
)
}
}
},
Events: {
screen: EventsNavigator,
navigationOptions: {
tabBarIcon: ({ focused, tintColor }) => (
<Icon
name="calendar-check"
color={focused ? LIGHT_GREEN : 'grey'}
size={35}
/>
)
}
},
},
{tabBarOptions: {
showLabel: true,
activeTintColor: 'grey',
inactiveTintColor: 'grey',
style: {
backgroundColor: 'white',
height: 70,
},
}
});
const AppContainer = createAppContainer(TabNavigator);
const delay = ms => new Promise(res => setTimeout(res, ms));
export default class App extends React.Component {
state = {
assetsLoaded: false,
// when isReady is set to True, the app is shown
isReady: false,
};
componentDidMount(){
// Shows the splash screen image (logo)
SplashScreen.preventAutoHide();
}
render() {
// Shows gif if ready is false
if (!this.state.isReady) {
return (
<View style={{ flex: 1 }}>
<Image
source={require('./assets/splash.gif')}
onLoad={this._cacheResourcesAsync}
/>
</View>
);
}
StatusBar.setBarStyle('light-content', true);
//const {assetsLoaded} = this.state;
console.log(this.state)
// Rest of app is shown when everything is loaded
if( this.state.assetsLoaded ) {
return (
<AppContainer
ref={nav => {
this.navigator = nav;
}}
/>
);
}
if( !this.state.assetsLoaded ) {
return (
<View>
</View>
);
}
}
_cacheSplashResourcesAsync = async () => {
const gif = require('./assets/splash.gif');
return Asset.fromModule(gif).downloadAsync();
};
_cacheResourcesAsync = async () => {
SplashScreen.hide();
await Font.loadAsync({
'aktiv-grotesk-regular': require('./assets/fonts/AktivGrotesk-Regular.ttf'),
'aktiv-grotesk-bold': require('./assets/fonts/AktivGrotesk-Bold.ttf'),
});
// This delay specifies the length of time the gif is on screen
await delay(1500);
this.setState({ isReady: true });
this.setState({ assetsLoaded: true });
};
}
//export default createAppContainer(App);