import { Ionicons } from "@expo/vector-icons"; import { Video } from "expo-av"; import React, { useState } from "react"; import { Dimensions, Modal, SafeAreaView, TouchableOpacity, } from "react-native"; import Gallery from "react-native-image-gallery"; export default function MediaCacheOverlay({ photos, previewVisible, setPreviewVisible, imgIndex, setImgIndex, }) { const [currentIndex, setcurrentIndex] = useState(0); const [dragging, setDragging] = useState(false); const videoRef = React.useRef(null); return ( setPreviewVisible(false)} onRequestClose={() => setPreviewVisible(false)} visible={previewVisible} transparent={false} > setcurrentIndex(position)} onPageScrollStateChanged={(state) => state === "idle" ? setDragging(false) : setDragging(true) } /> setPreviewVisible(false)} > {!dragging && photos[currentIndex] && photos[currentIndex].videoUrl && ( { await videoRef.current.loadAsync( { uri: photos[currentIndex].videoUrl }, {}, false ); videoRef.current.presentFullscreenPlayer(); }} > )} ); }