import type { FlashList, FlashListProps } from '@shopify/flash-list'; import * as React from 'react'; import { View } from 'react-native'; import Animated, { useAnimatedStyle } from 'react-native-reanimated'; import { commonStyles } from '../../constants'; import type { StickyHeaderFlashListProps } from '../../primitiveComponents/StickyHeaderProps'; import { withStickyHeaderFlashList } from '../../primitiveComponents/withStickyHeaderFlashList'; import { parseAnimatedColorProp } from '../common/utils/parseAnimatedColorProp'; import type { DetailsHeaderFlashListProps } from './DetailsHeaderProps'; import { HeaderBar } from './components/HeaderBar'; import { useDetailsFlashListHeader } from './hooks/useDetailsFlashListHeader'; export function withDetailsHeaderFlashList( flashListComponent: React.ComponentClass> ) { const StickyHeaderFlashList = withStickyHeaderFlashList( flashListComponent as React.ComponentClass> ) as ( props: StickyHeaderFlashListProps & React.RefAttributes> ) => React.ReactElement; return React.forwardRef, DetailsHeaderFlashListProps>((props, ref) => { const { backgroundColor, decelerationRate = 'fast', enableSafeAreaTopInset = true, leftTopIcon, leftTopIconAccessibilityLabel, leftTopIconOnPress, leftTopIconTestID, nestedScrollEnabled = true, overScrollMode = 'never', renderHeader, renderHeaderBar, rightTopIcon, rightTopIconAccessibilityLabel, rightTopIconOnPress, rightTopIconTestID, scrollEventThrottle = 16, title, titleStyle, ...rest } = props; const { headerTitleContainerAnimatedStyle, renderHeader: defaultRenderHeader, scrollViewRef, onScroll, onScrollEndDrag, onMomentumScrollEnd, } = useDetailsFlashListHeader(props); React.useImperativeHandle(ref, () => scrollViewRef.current as FlashList); const wrapperAnimatedStyle = useAnimatedStyle(() => { return { backgroundColor: parseAnimatedColorProp(backgroundColor), }; }, [backgroundColor]); return ( {renderHeaderBar ? ( renderHeaderBar() ) : ( )} ); }); }