ENEI2019-Public/App/app/screens/AuthLoading.js

39 lines
997 B
JavaScript
Executable File

import React, {Component} from 'react';
import {
ActivityIndicator,
AsyncStorage,
Button,
StatusBar,
StyleSheet,
View,
} from 'react-native';
import {UtilStyles} from '../assets/styles'
export default class AuthLoadingScreen extends Component {
constructor() {
super();
this._bootstrapAsync();
}
// Fetch the token from storage then navigate to our appropriate place
_bootstrapAsync = async () => {
const token = await AsyncStorage.getItem('token');
// This will switch to the App screen or Auth screen and this loading
// screen will be unmounted and thrown away.
this.props.navigation.navigate(token ? 'App' : 'Auth');
};
// Render Loading
render() {
return (
<View style={UtilStyles.containerLoading}>
<ActivityIndicator size='large' color="rgba(000,000,000,1)"/>
<StatusBar barStyle="default" />
</View>
);
}
}