import * as React from "react"; import { useRef, useState, useEffect, memo } from "react"; import { View, Animated, Easing, Alert } from "react-native"; import { VideoPlayerModalContainer, VideoPlayerContainer } from "./styled"; import BottomOptions from "./bottom-options"; import { VideoPlayer } from "../video"; import { VideoItem } from "../video/video"; import ShareStackIcon from "../share-stack-icon"; import InfoPanel from "./info-panel"; import VideoPremiumBlocker from "../video-premium-blocker"; import { useVideoPlayerCollapse } from "./hooks/use-video-collapse"; export type VidepPlayerCollapsePropsBase = { show: boolean; data?: VideoItem | undefined; onShowBottomOptions: () => void; showBottomOptions: boolean; onHiddeBottomOptions: () => void; onCloseVideo: () => void; onMinimize: () => void; isMinimized: boolean; onOpenShareOptions: () => void; isShareOptionsOpened: boolean; onSwitchInfo: () => void; isOpenInfo: boolean; }; function VidepPlayerCollapse({ data, show, isMinimized, isOpenInfo, isShareOptionsOpened, onCloseVideo, onHiddeBottomOptions, onMinimize, onSwitchInfo, onOpenShareOptions, onShowBottomOptions, showBottomOptions, }: VidepPlayerCollapsePropsBase) { const timeout = useRef(); const bottomTimeout = useRef(); const heightAnimation = useRef(new Animated.Value(0)).current; const [activeAnimation, setActiveAnimation] = useState(false); useEffect(() => { setActiveAnimation(true); Animated.parallel([ Animated.timing(heightAnimation, { useNativeDriver: false, toValue: show && !isMinimized ? 220 : 0, duration: 300, easing: Easing.bezier(0.16, 1, 0.3, 1), }), ]).start(() => { if (!show) setActiveAnimation(false); }); }, [show, isMinimized]); useEffect(() => { if (showBottomOptions) bottomTimeout.current = setTimeout(onHiddeBottomOptions, 5000); }, [showBottomOptions]); if (!show && !activeAnimation) return null; return ( { clearTimeout(timeout.current); if (isShareOptionsOpened) timeout.current = setTimeout(onOpenShareOptions, 5000); onShowBottomOptions(); }} > {show && data && data.renderer?.subscriptions ? ( {}} /> ) : ( data && )} {isShareOptionsOpened && ( )} {data && ( )} ); } export type VideoPlayerCollapseProps = { video?: VideoItem; open: boolean; onClose: () => void; }; export default memo((props: VideoPlayerCollapseProps) => { const { videoPlayerModal } = useVideoPlayerCollapse(props); return ; }); //