-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
96 lines (82 loc) · 2.59 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/** In order for logging to stream to XDE or the exp CLI you must import the
* exponent module at some point in your app */
import Exponent from 'exponent';
import React from 'react';
import {
AppRegistry,
Platform,
StatusBar,
StyleSheet,
View,
} from 'react-native';
import {
FontAwesome,
} from '@exponent/vector-icons';
import { Provider } from 'react-redux'
import cacheAssetsAsync from './utilities/cacheAssetsAsync';
import ActionTypes from './state/ActionTypes';
import * as ActionCreators from './state/ActionCreators';
import * as Game from './Game';
import HomeScreen from './screens/HomeScreen';
import Store from './state/Store';
let store = Store;
class AppContainer extends React.Component {
state = {
appIsReady: false,
}
componentWillMount() {
this._loadAssetsAsync();
Game.createNewGameAsync(Store.dispatch); // TODO: Handle errors
}
async _loadAssetsAsync() {
await cacheAssetsAsync({
images: [
require('./assets/images/exponent-wordmark.png'),
],
fonts: [
FontAwesome.font,
{
'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'),
// 'VT323': require('./assets/fonts/VT323.ttf'),
// 'NovaMono': require('./assets/fonts/NovaMono.ttf'),
// 'DontMixYerDrinks': require('./assets/fonts/dontmix.ttf'),
// 'Targa': require('./assets/fonts/TargaMSHand.ttf'),
// 'CafeFrancoise': require('./assets/fonts/cafe-francoise.ttf'),
// 'Appleberry': require('./assets/fonts/appleberry.ttf'),
// 'Puddleduck': require('./assets/fonts/Puddleduck.ttf'),
// 'SkinnyJeansSolid': require('./assets/fonts/SkinnyJeansSolid.ttf'),
// 'ItsaSketch': require('./assets/fonts/ItsaSketch.ttf'),
'TopSecret': require('./assets/fonts/Top_Secret.ttf'),
},
],
});
this.setState({appIsReady: true});
}
render() {
if (this.state.appIsReady) {
let { notification } = this.props.exp;
return (
<View style={styles.container}>
<Provider store={Store}>
<HomeScreen />
</Provider>
{Platform.OS === 'ios' && <StatusBar barStyle="default" />}
{Platform.OS === 'android' && <View style={styles.statusBarUnderlay} />}
</View>
);
} else {
return <Exponent.Components.AppLoading />;
}
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
statusBarUnderlay: {
height: 24,
backgroundColor: 'rgba(0,0,0,0.2)',
},
});
AppRegistry.registerComponent('main', () => AppContainer);