import { createSwitchNavigator, createAppContainer } from 'react-navigation'
import AuthStack from './AuthStack'
import AppStack from './AppStack'
import React from 'react'
import AppLoading from '../screens/app/AppLoading'
import LanguageSelect from '../screens/app/LanguageSelect'
import { Platform, View } from 'react-native'
import NavigationService from '../utils/NavigationService'
import {SafeAreaProvider, SafeAreaView} from "react-native-safe-area-context";

const MainNav = createAppContainer(createSwitchNavigator({
  AppLoading,
  LanguageSelect,
  App: AppStack
}))

export class AppNavContainer extends React.Component {
  constructor (p) {
    super(p)
  }

  render () {
    if(Platform.OS === 'android') {
      return (
        <SafeAreaProvider>
          <SafeAreaView style={{flex: 1}} edges={['top', 'bottom']}>
            <MainNav ref={navigatorRef => {NavigationService.setTopLevelNavigator(navigatorRef)}}/>
          </SafeAreaView>
        </SafeAreaProvider>
      )
    }else {
      return (
         <View style={{flex: 1}}>
            <MainNav ref={navigatorRef => {NavigationService.setTopLevelNavigator(navigatorRef)}}/>
        </View>
      )
    }
  }
}

export default AppNavContainer
