import * as React from 'react'; import type { SectionList } from 'react-native'; 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 { StickyHeaderSectionList } from '../../primitiveComponents/StickyHeaderSectionList'; import { parseAnimatedColorProp } from '../common/utils/parseAnimatedColorProp'; import type { TabbedHeaderListProps } from './TabbedHeaderProps'; import { HeaderBar } from './components/HeaderBar'; import { useTabbedHeaderList } from './hooks/useTabbedHeader'; function TabbedHeaderListInner( props: TabbedHeaderListProps, ref: React.ForwardedRef> ) { const { backgroundColor, contentContainerStyle, decelerationRate = 'fast', enableSafeAreaTopInset = true, logo, logoContainerStyle, logoResizeMode, logoStyle, nestedScrollEnabled = true, overScrollMode = 'never', renderHeader, renderHeaderBar, renderSectionFooter, renderSectionHeader, scrollEventThrottle = 16, stickySectionHeadersEnabled = true, viewabilityConfig = { itemVisiblePercentThreshold: 50 }, ...rest } = props; const { onMomentumScrollEnd, onScroll, onScrollEndDrag, onViewableItemsChanged, renderHeader: defaultRenderHeader, renderTabs, scrollViewRef, } = useTabbedHeaderList(props); React.useImperativeHandle(ref, () => scrollViewRef.current as SectionList); const wrapperAnimatedStyle = useAnimatedStyle(() => { return { backgroundColor: parseAnimatedColorProp(backgroundColor), }; }, [backgroundColor]); return ( {renderHeaderBar ? ( renderHeaderBar() ) : logo ? ( ) : ( )} ); } type TabbedHeaderListType = ( props: TabbedHeaderListProps & React.RefAttributes> ) => React.ReactElement; export const TabbedHeaderList = React.forwardRef(TabbedHeaderListInner) as TabbedHeaderListType;