import React, { useState, useEffect } from 'react';
import { StatusBar } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { GetPageTheme } from "../../styles/Global";
import { AuthStack } from './Routes';
import { connect } from 'react-redux';
import { mapStateToProps, mapDispatchToProps } from '../../reducers/contextProvider';
import { LogBox } from 'react-native';
import NetInfo from "@react-native-community/netinfo";

LogBox.ignoreLogs(['new NativeEventEmitter']); // Ignore log notification by message
LogBox.ignoreAllLogs(); //Ignore all log notifications
LogBox.ignoreLogs([
    "[react-native-gesture-handler] Seems like you\'re using an old API with gesture components, check out new Gestures system!",
]);
const Navigator = (props) => {
    const PageTheme = GetPageTheme(false, '');
    const { DarkMode } = props;
    const [state, setState] = useState({});

    useEffect(() => {
        const unsubscribe = NetInfo.addEventListener(state => {
            var isAlreadyConnected = props.isInternetAvailable == true
            if (isAlreadyConnected == false || (isAlreadyConnected != state.isConnected)) {
                props.show_ConnChange({ showConnChange: true })
            }
            props.set_networkStatus({ isInternetAvailable: state.isConnected });

        });

        return () => {
            unsubscribe();
        }
    }, []);



    return (
        <NavigationContainer>
            <StatusBar barStyle={"dark-content"} backgroundColor={PageTheme.$status_bar_color} />
            <AuthStack {...props} />
        </NavigationContainer>
    )


};



export default connect(mapStateToProps, mapDispatchToProps)(Navigator)