import { createStackNavigator } from '@react-navigation/stack';
import { createDrawerNavigator } from '@react-navigation/drawer';
import { useRoute } from '@react-navigation/native';
import Project from '../../screens/Project';
import Login from '../../screens/Login';
import Mpin from '../../screens/Mpin';
import MpinLogin from '../../screens/MpinLogin';
import NoticeBoard from '../../screens/NoticeBoard';
import One_QAD from '../../screens/One_QAD';
import { PrimaryTheme } from '../../styles/Themes';
// import Icon from 'react-native-vector-icons/Ionicons';
import DownloadDataScreen from '../../screens/DownloadDataScreen';
import ReportsMenu from '../../screens/ReportsMenu';
// import VideoPlayerScreen from '../../screens/VideoPlayer';
import UploadDataScreen from '../../screens/UploadData';
import Splash from '../../screens/SplashScreen';
import VisitorLogin from '../../screens/VisitorLogin';
import PersonalDocument from '../../screens/PersonalDocument';
import Training from '../../screens/Training';
import StoreList from '../../screens/StoreList';
import StoreDailyMenu from '../../screens/StoreDailyMenu';
import StoreCheckin from '../../screens/CheckInStore';
import GeoTag from '../../screens/GeoTag';
import ShowMap from '../../screens/ShowMap';
import StoreNonWorkingReasons from '../../screens/StoreNonWorkingReasons';
import Settings from '../../screens/Settings';

import OpeningStock from '../../screens/OpeningStock'; 
import BackroomStock from '../../screens/BackroomStock'; 
import MiddayStock from '../../screens/MiddayStock'; 
import ClosingStock from '../../screens/ClosingStock'; 
import ShareOfShelf from '../../screens/ShareOfShelf';
import PaidVisibility from '../../screens/PaidVisibility';
import AdditionalVisibility from '../../screens/AdditionalVisibility';
import CompetitionVisibility from '../../screens/CompetitionVisibility';
import Promotion from '../../screens/Promotion';
import CompetitionPromotion from '../../screens/CompetitionPromotion';
import ContactConversion from '../../screens/ContactConversion';
import Sale from '../../screens/Sale';
import SurveyList from '../../screens/SurveyList';

import { DrawerContent } from './drawerContent';
import { globalStyles,customStyles,GetPageTheme } from "../../styles/Global";
import {Text,ImageBackground} from 'react-native';
import LinearGradient from 'react-native-linear-gradient';

import * as React from 'react';
import { FontAwesome } from '../../components/icons';
import { TouchableOpacity } from 'react-native';
// import { globalStyle } from '../../styles/Global';

import DynamicStoreList from '../../screens/DynamicStoreList'; 
import DynamicSurveys from '../../screens/DynamicSurveys';
import DynamicSurveyCat from '../../screens/DynamicSurveyCat';
import SurveyView from '../../screens/SurveyView';
import SurveyCat from '../../screens/SurveyCat';
import SurveyNew from '../../screens/SurveyNew';
import QuestionsScreen from '../../screens/QuestionsScreen';
import Window from '../../screens/Window';
import Stock from '../../screens/Stock';
import ContactUs from '../../screens/ContactUs';
import POSM from '../../screens/POSM';
import Feedback from '../../screens/Feedback';
import SimplePromotion from '../../screens/SimplePromotion';
import StoreImages from '../../screens/StoreImages';
import StoreImagesCap from '../../screens/StoreImagesCap';
import CameraScreen from '../../screens/CameraScreen';
import ShelfTalker from '../../screens/ShelfTalker';
import StockCat from '../../screens/StockCat';
import StockWithCat from '../../screens/StockWithCat';
import StoreDailyMenuCat from '../../screens/StoreDailyMenuCat';
import PromotionOneApp from '../../screens/PromotionOneApp';
import PaidVisibilityOneApp from '../../screens/PaidVisibilityOneApp';
import ShareOfShelfOneApp from '../../screens/ShareOfShelfOneApp';

const Stack = createStackNavigator();
const Drawer = createDrawerNavigator();


function DrawerRoutes(props) { 
    const route = useRoute();
    const PageTheme=GetPageTheme(props.DarkMode,route.name);
    const customStyle=customStyles(props.DarkMode,route.name);
    const globalStyle=globalStyles(props.DarkMode,route.name);

    let params=props.route.params? props.route.params:{};
    let UserData=params.UserData || {};
    let username=UserData.UserId || '';
    let set_startDownload=params.set_startDownload || function (){};
    let useremail='';
    let pageprops=props.pageprops;
  
    return (
        <Drawer.Navigator initialRouteName="NoticeBoard" drawerContent={props => <DrawerContent {...props} UserName={username} UserEmail={useremail} pageprops={pageprops}/>}
        screenOptions={{
            headerTintColor:PrimaryTheme.$primary_color,
            drawerType:'front',
        }}>
            <Drawer.Screen name="Notice Board" component={NoticeBoard}  options={{
                // headerStyle: { backgroundColor: PrimaryTheme.$bg_color,borderBottomWidth:1,borderBottomColor:PrimaryTheme.$secondary_color_light },
                // headerTitleStyle: { color: PrimaryTheme.$primary_color,fontSize:16},
                // headerTitleAlign: 'center',
                headerShown:false,
                // headerBackground:()=>{<LinearGradient colors={[PageTheme.$gradient2,PageTheme.$primary_color]} start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }} style={globalStyle.drawerScreenbg}></LinearGradient>}
                
            }} />            
        </Drawer.Navigator>
    )
}


export const AuthStack = (props) => { 
   let props1=props;
    return(
        <Stack.Navigator initialRouteName={'initialScreen'}>
            <Stack.Screen name={'initialScreen'} component={Splash} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen  name={'Project'} component={Project} options={{ headerShown: false }}></Stack.Screen>
            
            <Stack.Screen {...props} name={'NoticeBoard'}  options={{ headerShown: false }}>
                {props =><DrawerRoutes {...props} pageprops={props1}  />}
            </Stack.Screen>
            <Stack.Screen {...props} name={'One_QAD'} component={One_QAD}  options={{ headerShown: false }}></Stack.Screen>
            
            
            <Stack.Screen name={'DownloadDataScreen'} component={DownloadDataScreen} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'UploadData'} component={UploadDataScreen} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'StoreList'} component={StoreList} options={{ headerShown: false }}></Stack.Screen>
            
            <Stack.Screen name={'StoreCheckin'} component={StoreCheckin} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'StoreDailyMenu'} component={StoreDailyMenu} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'StoreDailyMenuCat'} component={StoreDailyMenuCat} options={{ headerShown: false }}></Stack.Screen>
            
            <Stack.Screen name={'OpeningStock'} component={OpeningStock} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'BackroomStock'} component={BackroomStock} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'MiddayStock'} component={MiddayStock} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'ClosingStock'} component={ClosingStock} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'ShareOfShelf'} component={ShareOfShelf} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'PaidVisibility'} component={PaidVisibility} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'AdditionalVisibility'} component={AdditionalVisibility} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'CompetitionVisibility'} component={CompetitionVisibility} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'Promotion'} component={Promotion} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'CompetitionPromotion'} component={CompetitionPromotion} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'ContactConversion'} component={ContactConversion} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'Sale'} component={Sale} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'SurveyList'} component={SurveyList} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'SurveyCat'} component={SurveyCat} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'SurveyView'} component={SurveyView} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'Window'} component={Window} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'Stock'} component={Stock} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'POSM'} component={POSM} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'Feedback'} component={Feedback} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'SimplePromotion'} component={SimplePromotion} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'StoreImages'} component={StoreImages} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'ShelfTalker'} component={ShelfTalker} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'PromotionOneApp'} component={PromotionOneApp} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'StockCat'} component={StockCat} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'StockWithCat'} component={StockWithCat} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'PaidVisibilityOneApp'} component={PaidVisibilityOneApp} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'ShareOfShelfOneApp'} component={ShareOfShelfOneApp} options={{ headerShown: false }}></Stack.Screen>
            

            <Stack.Screen name={'ReportsMenu'} component={ReportsMenu} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'Settings'} component={Settings} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'VisitorLogin'} component={VisitorLogin} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'PersonalDocument'} component={PersonalDocument} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'Training'} component={Training} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'StoreImagesCap'} component={StoreImagesCap} options={{ headerShown: false }}></Stack.Screen>
            
            <Stack.Screen name={'CameraScreen'} component={CameraScreen} options={{ headerShown: false }}></Stack.Screen>
            

            <Stack.Screen name={'GeoTag'} component={GeoTag} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'StoreNonWorkingReasons'} component={StoreNonWorkingReasons} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'ShowMap'} component={ShowMap} options={{ headerShown: false }}></Stack.Screen>
            
            <Stack.Screen name={'Login'} component={Login} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'Mpin'} component={Mpin} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'MpinLogin'} component={MpinLogin} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'ContactUs'} component={ContactUs} options={{ headerShown: false }}></Stack.Screen>
            
            
            <Stack.Screen name={'DynamicStoreList'} component={DynamicStoreList} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'DynamicSurveys'} component={DynamicSurveys} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'DynamicSurveyCat'} component={DynamicSurveyCat} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'SurveyNew'} component={SurveyNew} options={{ headerShown: false }}></Stack.Screen>
            <Stack.Screen name={'QuestionsScreen'} component={QuestionsScreen} options={{ headerShown: false }}></Stack.Screen>
            
            
        </Stack.Navigator>
    );
};

