import * as React from "react"; import { useRef, useState, useEffect } from "react"; import { VideoItem } from "../video/video"; import { InfoPannelContainer, ClosePanelContainer } from "./styled"; import { SiteImage } from "../site-image"; import Typography from "../ui/typography"; import { useThemeProvider } from "../../providers/theme-provider"; import { Animated, Easing } from "react-native"; export type InfoPanelProps = { videoData: VideoItem; show: boolean; onClose: () => void; }; function InfoPanel({ videoData, show, onClose }: InfoPanelProps) { const { theme: { color: { primary }, }, } = useThemeProvider(); const opacityAnimation = useRef(new Animated.Value(0)).current; const scaleAnimation = useRef(new Animated.Value(1.1)).current; const [activeAnimation, setActiveAnimation] = useState(false); useEffect(() => { setActiveAnimation(true); Animated.parallel([ Animated.timing(opacityAnimation, { useNativeDriver: true, toValue: show ? 1 : 0, duration: 200, easing: Easing.bezier(0.16, 1, 0.3, 1), }), Animated.timing(scaleAnimation, { useNativeDriver: true, toValue: show ? 1 : 1.1, duration: 200, easing: Easing.bezier(0.16, 1, 0.3, 1), }), ]).start(() => { if (!show) setActiveAnimation(false); }); }, [show]); if (!show && !activeAnimation) return null; return ( Close panel {videoData.renderer.name} ); } export default InfoPanel;