import * as React from 'react'; import type { FlatList } from 'react-native'; import { View } from 'react-native'; import Animated, { useAnimatedStyle } from 'react-native-reanimated'; import { commonStyles } from '../../constants'; import { StickyHeaderFlatList } from '../../primitiveComponents/StickyHeaderFlatList'; import { parseAnimatedColorProp } from '../common/utils/parseAnimatedColorProp'; import type { DetailsHeaderFlatListProps } from './DetailsHeaderProps'; import { HeaderBar } from './components/HeaderBar'; import { useDetailsHeader } from './hooks/useDetailsHeader'; function DetailsHeaderFlatListInner( props: DetailsHeaderFlatListProps, ref: React.ForwardedRef> ) { const { backgroundColor, contentContainerStyle, data, decelerationRate = 'fast', enableSafeAreaTopInset = true, keyExtractor, leftTopIcon, leftTopIconAccessibilityLabel, leftTopIconOnPress, leftTopIconTestID, nestedScrollEnabled = true, overScrollMode = 'never', renderHeader, renderHeaderBar, renderItem, rightTopIcon, rightTopIconAccessibilityLabel, rightTopIconOnPress, rightTopIconTestID, scrollEventThrottle = 16, title, titleStyle, ...rest } = props; const { headerTitleContainerAnimatedStyle, renderHeader: defaultRenderHeader, scrollViewRef, onScroll, onScrollEndDrag, onMomentumScrollEnd, } = useDetailsHeader>(props); React.useImperativeHandle(ref, () => scrollViewRef.current as FlatList); const wrapperAnimatedStyle = useAnimatedStyle(() => { return { backgroundColor: parseAnimatedColorProp(backgroundColor), }; }, [backgroundColor]); return ( {renderHeaderBar ? ( renderHeaderBar() ) : ( )} ); } type DetailsHeaderFlatListType = ( props: DetailsHeaderFlatListProps & React.RefAttributes> ) => React.ReactElement; export const DetailsHeaderFlatList = React.forwardRef( DetailsHeaderFlatListInner ) as DetailsHeaderFlatListType;