import React, { useRef } from 'react'; import { Animated, View, TouchableWithoutFeedback } from 'react-native'; import LinearGradient from 'react-native-linear-gradient'; import { fadeIn, fadeOut } from '../../../animations/fade'; import type { StoryDetailItemLayoutProps } from '../../../types'; import { styles } from './styles'; const AnimatedLinearGradient = Animated.createAnimatedComponent(LinearGradient); const defaultGradient = { locations: [0, 0.5, 0.8, 0.9], colors: ['rgba(0,0,0,0.3)', 'rgba(0,0,0,0.1)', '#FFFFFF00'], }; export const StoryDetailItemLayout: React.FC = ({ header, content, footer, onTapLeft, onTapRight, }) => { const fadeLeftAnim = useRef(new Animated.Value(0)).current; const fadeRightAnim = useRef(new Animated.Value(0)).current; return ( fadeIn(fadeLeftAnim)} onPressOut={() => { fadeOut(fadeLeftAnim, ({ finished }) => { if (finished) { onTapLeft && onTapLeft(); } }); }} > {content} fadeIn(fadeRightAnim)} onPressOut={() => { fadeOut(fadeRightAnim, ({ finished }) => { if (finished) { onTapRight && onTapRight(); } }); }} > {header} {footer} ); }; StoryDetailItemLayout.displayName = 'StoryDetailItemLayout';