2019-08-19 06:47:46 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { Platform, StatusBar, StyleSheet, View } from 'react-native';
|
2019-08-25 03:26:31 +00:00
|
|
|
import { ThemeProvider } from 'react-native-elements';
|
2019-08-20 16:23:43 +00:00
|
|
|
import { AppLoading, ScreenOrientation } from 'expo';
|
2019-08-19 06:47:46 +00:00
|
|
|
import { Asset } from 'expo-asset';
|
|
|
|
import * as Font from 'expo-font';
|
|
|
|
import { Ionicons } from '@expo/vector-icons';
|
2019-08-29 04:38:29 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2019-08-19 06:47:46 +00:00
|
|
|
|
|
|
|
import AppNavigator from './navigation/AppNavigator';
|
2019-08-22 14:23:02 +00:00
|
|
|
import Colors from './constants/Colors';
|
2019-08-25 03:26:31 +00:00
|
|
|
import Theme from './utils/Theme';
|
2019-08-19 06:47:46 +00:00
|
|
|
|
|
|
|
export default class App extends React.Component {
|
2019-08-29 04:38:29 +00:00
|
|
|
static propTypes = {
|
|
|
|
skipLoadingScreen: PropTypes.bool
|
|
|
|
};
|
|
|
|
|
2019-08-19 06:47:46 +00:00
|
|
|
state = {
|
2019-08-22 14:23:02 +00:00
|
|
|
isLoadingComplete: false
|
2019-08-19 06:47:46 +00:00
|
|
|
};
|
|
|
|
|
2019-08-20 16:23:43 +00:00
|
|
|
componentDidMount() {
|
|
|
|
// Allow screen rotation on iPad
|
|
|
|
if (Platform.OS === 'ios' && Platform.isPad) {
|
|
|
|
ScreenOrientation.lockAsync(
|
|
|
|
ScreenOrientation.OrientationLock.ALL
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-19 06:47:46 +00:00
|
|
|
render() {
|
|
|
|
if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
|
|
|
|
return (
|
|
|
|
<AppLoading
|
|
|
|
startAsync={this._loadResourcesAsync}
|
|
|
|
onError={this._handleLoadingError}
|
|
|
|
onFinish={this._handleFinishLoading}
|
|
|
|
autoHideSplash={false}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return (
|
2019-08-25 03:26:31 +00:00
|
|
|
<ThemeProvider theme={Theme}>
|
2019-08-19 06:47:46 +00:00
|
|
|
<View style={styles.container}>
|
|
|
|
{Platform.OS === 'ios' && <StatusBar barStyle="light-content" />}
|
|
|
|
<AppNavigator />
|
|
|
|
</View>
|
2019-08-25 03:26:31 +00:00
|
|
|
</ThemeProvider>
|
2019-08-19 06:47:46 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_loadImagesAsync = () => {
|
|
|
|
const images = [
|
|
|
|
require('./assets/images/splash.png'),
|
|
|
|
require('./assets/images/logowhite.png')
|
|
|
|
];
|
|
|
|
return images.map(image => Asset.fromModule(image).downloadAsync());
|
|
|
|
}
|
|
|
|
|
|
|
|
_loadResourcesAsync = async () => {
|
|
|
|
return Promise.all([
|
|
|
|
Font.loadAsync({
|
|
|
|
// This is the font that we are using for our tab bar
|
|
|
|
...Ionicons.font
|
|
|
|
}),
|
|
|
|
...this._loadImagesAsync()
|
|
|
|
]);
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleLoadingError = error => {
|
|
|
|
// In this case, you might want to report the error to your error
|
|
|
|
// reporting service, for example Sentry
|
|
|
|
console.warn(error);
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleFinishLoading = () => {
|
|
|
|
this.setState({ isLoadingComplete: true });
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
flex: 1,
|
2019-08-24 18:44:39 +00:00
|
|
|
backgroundColor: Colors.backgroundColor
|
2019-08-19 06:47:46 +00:00
|
|
|
}
|
|
|
|
});
|