import React,{ useEffect } from 'react';
import { Image, ImageBackground, TouchableOpacity, View,Text, Dimensions } from 'react-native';
import Icon from 'react-native-vector-icons/dist/Entypo';
import { useSelector } from 'react-redux';
import { COLORS } from '../../utils/colors';
import images from '../../utils/images';
import styles from './styles';

const {height,width} = Dimensions.get('window')
const Splash = ({onSplashEnd, lang, onClose}) => {
  useEffect(() => {
  let time= setTimeout(() => {
      onSplashEnd()
    }, 3000);
    return () => {
      clearTimeout(time);
    };
  }, []);
  const languageResource = useSelector((state) => state.resourcesReducer.resource);
  const settingsData = useSelector((state) => state.resourcesReducer.settingsData); 
  return (
    <ImageBackground
      style={[styles.imageBackground]}
      resizeMode={'cover'}
      source={settingsData  ? (lang !== 1 ? images.drawerBgReverse : images.drawerBg ): {uri : lang !== 1 ? settingsData.bgImageReverse : settingsData.bgImage}}
      // source={{uri : lang !== 1 ? settingsData.bgImageReverse : settingsData.bgImage}}
      // source={lang !== 1 ? images.drawerBgReverse : images.drawerBg}
      >
      <TouchableOpacity style={[styles.backButton]} onPress={() => onClose()}>
      
        <Image
          source={images.cross}
          resizeMode="contain"
          style={[styles.image]}
        />
      </TouchableOpacity>

      <View style={[styles.feedbackView]}>
      <Text allowFontScaling={false} style={styles.feedbackText}>
          {' '}
          {languageResource.Hello_I_am_Ajbot}
        </Text>
        <Image
          source={images.bot_img}
          resizeMode="contain"
          style={styles.imageGif}
        />
        <Text allowFontScaling={false} style={styles.feedbackTextNormal}>
          {' '}
          {languageResource.Hello_I_am_Ajbot2}
        </Text>
        <Text allowFontScaling={false} style={styles.feedbackTextNormal}>
          {'\n '}
          {languageResource.Hello_I_am_Ajbot3}
        </Text>
      </View>
    </ImageBackground>
  );
};

export default Splash;
