import React from 'react';
import PropTypes from 'prop-types';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { connect } from 'react-redux';
import { SafeAreaProvider, initialWindowMetrics } from 'react-native-safe-area-context';
import Navigation from './lib/Navigation';
import { defaultHeader, onNavigationStateChange } from './utils/navigation';
import {
ROOT_LOADING, ROOT_OUTSIDE, ROOT_NEW_SERVER, ROOT_INSIDE, ROOT_SET_USERNAME, ROOT_BACKGROUND
} from './actions/app';
// Stacks
import AuthLoadingView from './views/AuthLoadingView';
// SetUsername Stack
import SetUsernameView from './views/SetUsernameView';
import OutsideStack from './stacks/OutsideStack';
import InsideStack from './stacks/InsideStack';
// SetUsernameStack
const SetUsername = createStackNavigator();
const SetUsernameStack = () => (
);
// App
const Stack = createStackNavigator();
const App = React.memo(({ root }) => {
if (!root || root === ROOT_BACKGROUND) {
return null;
}
return (
<>
{root === ROOT_LOADING ? (
) : null}
{root === ROOT_OUTSIDE || root === ROOT_NEW_SERVER ? (
) : null}
{root === ROOT_INSIDE ? (
) : null}
{root === ROOT_SET_USERNAME ? (
) : null}
>
);
});
const mapStateToProps = state => ({
root: state.app.root
});
App.propTypes = {
root: PropTypes.string
};
const AppContainer = connect(mapStateToProps)(App);
export default AppContainer;