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 type { Edge } from 'react-native-safe-area-context'; import { SafeAreaView } from 'react-native-safe-area-context'; import { commonStyles } from '../../constants'; import type { StickyHeaderFlashListProps } from '../../primitiveComponents/StickyHeaderProps'; import { withStickyHeaderFlashList } from '../../primitiveComponents/withStickyHeaderFlashList'; import { parseAnimatedColorProp } from '../common/utils/parseAnimatedColorProp'; import type { TabbedHeaderFlashListProps } from './TabbedHeaderProps'; import { HeaderBar } from './components/HeaderBar'; import { useTabbedFlashListHeader } from './hooks/useTabbedFlashListHeader'; export function withTabbedHeaderFlashList( flashListComponent: React.ComponentClass> ) { const StickyHeaderFlashList = withStickyHeaderFlashList( flashListComponent as React.ComponentClass> ) as ( props: StickyHeaderFlashListProps & React.RefAttributes> ) => React.ReactElement; return React.forwardRef, TabbedHeaderFlashListProps>((props, ref) => { const { backgroundColor, decelerationRate = 'fast', enableSafeAreaTopInset = true, logo, logoContainerStyle, logoResizeMode, logoStyle, nestedScrollEnabled = true, overScrollMode = 'never', renderHeader, renderHeaderBar, scrollEventThrottle = 16, viewabilityConfig = { itemVisiblePercentThreshold: 50 }, ...rest } = props; const { onMomentumScrollEnd, onScroll, onScrollEndDrag, onViewableItemsChanged, renderHeader: defaultRenderHeader, renderTabs, scrollViewRef, } = useTabbedFlashListHeader(props); React.useImperativeHandle(ref, () => scrollViewRef.current as FlashList); const wrapperAnimatedStyle = useAnimatedStyle(() => { return { backgroundColor: parseAnimatedColorProp(backgroundColor), }; }, [backgroundColor]); return ( {renderHeaderBar ? ( renderHeaderBar() ) : logo ? ( ) : ( )} ); }); }