import { FlashList, FlashListProps } from "@shopify/flash-list"; import React, { useEffect } from "react"; import { View, ViewStyle } from "react-native"; import Animated, { useAnimatedStyle, useSharedValue, withTiming, } from "react-native-reanimated"; import { Loader } from "../Loader"; import { Text } from "./Text"; type PartialExcept = Partial & Pick; interface HorizontalScrollProps extends PartialExcept< Omit, "renderItem">, "estimatedItemSize" > { data?: T[] | null; renderItem: (item: T, index: number) => React.ReactNode; containerStyle?: ViewStyle; contentContainerStyle?: ViewStyle; loadingContainerStyle?: ViewStyle; height?: number; loading?: boolean; } export function HorizontalScroll({ data = [], renderItem, containerStyle, contentContainerStyle, loadingContainerStyle, loading = false, height = 164, ...props }: HorizontalScrollProps): React.ReactElement { const animatedOpacity = useSharedValue(0); const animatedStyle1 = useAnimatedStyle(() => { return { opacity: withTiming(animatedOpacity.value, { duration: 250 }), }; }); useEffect(() => { if (data) { animatedOpacity.value = 1; } }, [data]); if (data === undefined || data === null || loading) { return ( ); } const renderFlashListItem = ({ item, index }: { item: T; index: number }) => ( {renderItem(item, index)} ); return ( ( No data available )} {...props} /> ); }