Created
November 12, 2016 06:27
-
-
Save joevo2/42fd96fa11e75818bb1ad4c856bc3446 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Exponent from 'exponent'; | |
import React from 'react'; | |
import { | |
AppRegistry, | |
Platform, | |
StatusBar, | |
StyleSheet, | |
View, | |
} from 'react-native'; | |
import { | |
NavigationProvider, | |
StackNavigation, | |
} from '@exponent/ex-navigation'; | |
import { | |
FontAwesome, | |
} from '@exponent/vector-icons'; | |
import Router from './navigation/Router'; | |
import cacheAssetsAsync from './utilities/cacheAssetsAsync'; | |
class AppContainer extends React.Component { | |
state = { | |
appIsReady: false, | |
} | |
componentWillMount() { | |
this._loadAssetsAsync(); | |
} | |
async _loadAssetsAsync() { | |
try { | |
await cacheAssetsAsync({ | |
images: [ | |
require('./assets/images/exponent-wordmark.png'), | |
], | |
fonts: [ | |
{'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf')}, | |
{'pacifico': require('./assets/fonts/Pacifico.ttf')}, | |
], | |
}); | |
} catch(e) { | |
console.warn(`There was an error caching assets (see: main.js), perhaps due to a network timeout, so we skipped caching. Reload the app to try again.`); | |
} finally { | |
this.setState({appIsReady: true}); | |
} | |
} | |
render() { | |
if (this.state.appIsReady) { | |
let initialRoute = Router.getRoute('rootNavigation'); | |
return ( | |
<View style={styles.container}> | |
<NavigationProvider router={Router}> | |
<StackNavigation | |
id="root" | |
initialRoute={initialRoute} | |
/> | |
</NavigationProvider> | |
{Platform.OS === 'ios' && <StatusBar barStyle="light-content"/>} | |
{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)', | |
}, | |
}); | |
Exponent.registerRootComponent(AppContainer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment