import * as React from 'react'; import type { SectionList } from 'react-native'; import { View } from 'react-native'; import Animated, { useAnimatedStyle } from 'react-native-reanimated'; import { commonStyles } from '../../constants'; import { StickyHeaderSectionList } from '../../primitiveComponents/StickyHeaderSectionList'; import { parseAnimatedColorProp } from '../common/utils/parseAnimatedColorProp'; import type { AvatarHeaderSectionListProps } from './AvatarHeaderProps'; import { HeaderBar } from './components/HeaderBar'; import { useAvatarHeader } from './hooks/useAvatarHeader'; function AvatarHeaderSectionListInner( props: AvatarHeaderSectionListProps, ref: React.ForwardedRef> ) { const { backgroundColor, contentContainerStyle, decelerationRate = 'fast', enableSafeAreaTopInset = true, image, leftTopIcon, leftTopIconAccessibilityLabel, leftTopIconOnPress, leftTopIconTestID, nestedScrollEnabled = true, overScrollMode = 'never', renderHeader, renderHeaderBar, renderSectionFooter, renderSectionHeader, rightTopIcon, rightTopIconAccessibilityLabel, rightTopIconOnPress, rightTopIconTestID, scrollEventThrottle = 16, sections, stickySectionHeadersEnabled = true, title, titleStyle, ...rest } = props; const { onMomentumScrollEnd, onScroll, onScrollEndDrag, parallaxHeight, renderHeader: defaultRenderHeader, scrollValue, scrollViewRef, } = useAvatarHeader>(props); React.useImperativeHandle(ref, () => scrollViewRef.current as SectionList); const wrapperAnimatedStyle = useAnimatedStyle(() => { return { backgroundColor: parseAnimatedColorProp(backgroundColor), }; }, [backgroundColor]); return ( {renderHeaderBar ? ( renderHeaderBar() ) : ( )} ); } type AvatarHeaderSectionListType = ( props: AvatarHeaderSectionListProps & React.RefAttributes> ) => React.ReactElement; export const AvatarHeaderSectionList = React.forwardRef( AvatarHeaderSectionListInner ) as AvatarHeaderSectionListType;