import React from 'react';
import { ActivityIndicator, View } from 'react-native';

import { getAuthState } from '../../realm/actions/AuthActions';

export default class TransitionScreen extends React.Component {
  constructor(props) {
    super(props);
    this.bootstrapAsync();
  }

  // Fetch the token from storage then navigate to our appropriate stack
  async bootstrapAsync() {
    const userToken = await getAuthState();
    this.props.navigation.navigate(userToken ? 'App' : 'Auth');
  }

  render() {
    return (
      <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
        <ActivityIndicator size='large' />
      </View>
    );
  }
}
