-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
79 lines (69 loc) · 1.78 KB
/
main.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
import Exponent from "exponent";
import React from "react";
import {
AppRegistry,
Platform,
StatusBar,
StyleSheet,
Text,
View
} from "react-native";
import {
NavigationProvider,
StackNavigation,
} from "@exponent/ex-navigation";
import {Provider} from "react-redux";
import {
Components,
Font,
} from 'exponent';
import {MenuContext} from "react-native-popup-menu";
import Router from "./navigation/Router";
import store from "./store";
function cacheFonts(fonts) {
return fonts.map(font => Exponent.Font.loadAsync(font));
}
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
appIsReady: false
};
}
componentWillMount() {
this._loadAssetsAsync();
}
render() {
if (!this.state.appIsReady) {
return <Components.AppLoading />;
}
return (
<Provider store={store}>
<MenuContext style={{flex: 1}}>
<View style={styles.container}>
<NavigationProvider router={Router}>
<StackNavigation id="root" initialRoute={Router.getRoute("rootNavigation")} />
</NavigationProvider>
{Platform.OS === "ios" && <StatusBar barStyle="default" />}
{Platform.OS === "android" && <View style={styles.statusBarUnderlay} />}
</View>
</MenuContext>
</Provider>
);
}
async _loadAssetsAsync() {
const fontAssets = cacheFonts([
{OxygenRegular: require('./assets/fonts/Oxygen-Regular.ttf')},
{OxygenBold: require('./assets/fonts/Oxygen-Bold.ttf')},
{OxygenLight: require('./assets/fonts/Oxygen-Light.ttf')},
]);
this.setState({appIsReady: true});
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "white"
}
});
Exponent.registerRootComponent(App);