import React, {useState, useEffect} from 'react';
import Container from '../components/container';
import {useNavigation, useRoute} from '@react-navigation/native';
import {globalStyles, customStyles, GetPageTheme} from '../styles/Global';
import { StatusBar,Image,TextInput,View,Text,ScrollView,TouchableOpacity,Platform,PermissionsAndroid,FlatList,} from 'react-native';
import {ReactReduxContext,connect,useSelector,useDispatch,} from 'react-redux';
import {mapStateToProps, mapDispatchToProps} from '../reducers/contextProvider';
import SQLite from 'react-native-sqlite-2';
import {notify} from '../components/notify';
import moment from 'moment';
import {getDownloadJson,DownloadData} from '../controller/functions';
import {get_item, set_item, clear_item} from '../components/localStorage';
import {version,sloganline,appname,testurl,db,} from '../constants/constants';
import CustomHeader from '../components/customHeader';
import CustomLoader from '../components/CustomLoader';
import LinearGradient from 'react-native-linear-gradient';
import { FontAwesome, Fontisto, Ionicons, MaterialCommunityIcons } from '../components/icons';
import NoDataComponent from '../components/NoDataComponent';
import WebView from 'react-native-webview';
import { AntDesign, Entypo } from "../components/icons";
import * as RNFS from "react-native-fs";
import FileViewer from "react-native-file-viewer";
import VideoPlayer from 'react-native-video-controls';


function VideoScreen(props) {
  const route = useRoute();
  const ST=props.StaticText || {};
  const navigation = props.navigation
//   const navigation = useNavigation()
  const filePath = props.route.params.filePath;
  // get all theme styles acc to current theme set
  const PageTheme = GetPageTheme(props.DarkMode, route.name);
  const customStyle = customStyles(props.DarkMode, route.name);
  const globalStyle = globalStyles(props.DarkMode, route.name);
  
  
  const [processing, setProcessing] = useState(false);
 
  const [webviewurlT, setWebviewurlT] = useState('');
  
useEffect(()=>{
    setWebviewurlT(filePath)
},[filePath])

  return (
    <Container {...props} pt={0} avoidSafeArea={(Platform.OS=='ios'?true:false)}>
      {processing && <CustomLoader title={ST.Loading+".."}/>}
            <VideoPlayer
                source={{uri: webviewurlT}}
                navigator={props.navigation}
            />
    </Container>
  );
}

export default VideoScreen;
