App1.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import React from 'react';
  2. import { Platform, StatusBar, StyleSheet, View } from 'react-native';
  3. import { AppLoading, Asset, Font, Icon } from 'expo';
  4. import AppNavigator from './navigation/AppNavigator';
  5. export default class App extends React.Component {
  6. state = {
  7. isLoadingComplete: false,
  8. };
  9. render() {
  10. if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
  11. return (
  12. <AppLoading
  13. startAsync={this._loadResourcesAsync}
  14. onError={this._handleLoadingError}
  15. onFinish={this._handleFinishLoading}
  16. />
  17. );
  18. } else {
  19. return (
  20. <View style={styles.container}>
  21. {Platform.OS === 'ios' && <StatusBar barStyle="light-content" />}
  22. <AppNavigator />
  23. </View>
  24. );
  25. }
  26. }
  27. _loadResourcesAsync = async () => {
  28. return Promise.all([
  29. Asset.loadAsync([
  30. require('./assets/images/robot-dev.png'),
  31. require('./assets/images/robot-prod.png'),
  32. ]),
  33. Font.loadAsync({
  34. // This is the font that we are using for our tab bar
  35. ...Icon.Ionicons.font,
  36. // We include SpaceMono because we use it in HomeScreen.js. Feel free
  37. // to remove this if you are not using it in your app
  38. 'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'),
  39. }),
  40. ]);
  41. };
  42. _handleLoadingError = error => {
  43. // In this case, you might want to report the error to your error
  44. // reporting service, for example Sentry
  45. console.warn(error);
  46. };
  47. _handleFinishLoading = () => {
  48. this.setState({ isLoadingComplete: true });
  49. };
  50. }
  51. const styles = StyleSheet.create({
  52. container: {
  53. flex: 1,
  54. backgroundColor: '#fff',
  55. },
  56. });