import * as React from 'react';
import {View, Text, Linking} from 'react-native';
import {NavigationContainer} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import LoginScreen from '../screens/authentication/login/LoginContainer';
import SignUpScreen from '../screens/authentication/signup/SignUpContainer';
import SplashContainer from '../screens/authentication/splash/SlashContainer';
import ProfileContainer from '../screens/profile/ProfileContainer';
import ConfirmedShiftDetail from '../screens/shift/shift-tabs/ConfirmedShiftScreen/ConfirmedShiftDetail/ConfirmedShiftDetailContainer';
import ForgotPassword from '../screens/authentication/forgot_password/ForgotPasswordContainer';
import SalaryScreen from '../screens/salary/SalaryContainer';
import IntroScreen from '../screens/authentication/introduction/IntroductionContainer';
import ServerScreen from '../screens/authentication/server/ServerContainer';

import {APP_NAVIGATE_SCREEN} from '../utils/constant';
import Tabs from './DrawerNavigation';
import BottomTabs from './BottomTabNavigation';
import RootNavigation from './RootNavigation';
import HeaderComponent from '../components/header/HeaderComponent';

const {
  INTRO,
  SERVER,
  LOGIN,
  MAIN,
  SIGN_UP,
  SPLASH,
  PROFILE,
  FORGOT_PASS,
  CONFIRM_SHIFT_DETAIL,
  SALARY,
} = APP_NAVIGATE_SCREEN;
const AppScreen = {
  [SERVER]: ServerScreen,
  [SPLASH]: SplashContainer,
  [LOGIN]: LoginScreen,
  [SIGN_UP]: SignUpScreen,
  [PROFILE]: ProfileContainer,
  [FORGOT_PASS]: ForgotPassword,
  // [MAIN]: Tabs,
  [MAIN]: BottomTabs,
  [CONFIRM_SHIFT_DETAIL]: ConfirmedShiftDetail,
  [SALARY]: SalaryScreen,
  [INTRO]: IntroScreen,
};
const Stack = createNativeStackNavigator();

function AppNavigation() {
  return (
    <NavigationContainer
      linking={{
        prefixes: 'anawork://app',
      }}
      ref={navigatorRef => {
        RootNavigation.setTopLevelNavigator(navigatorRef);
      }}>
      <Stack.Navigator
        initialRouteName={SPLASH}
        screenOptions={{headerShown: false}}>
        {Object.keys(AppScreen).map((item, index) => (
          <Stack.Screen key={index} name={item} component={AppScreen[item]} />
        ))}
      </Stack.Navigator>
    </NavigationContainer>
  );
}

export default AppNavigation;
