import type { FlashList } from '@shopify/flash-list'; import * as React from 'react'; import { Extrapolate, interpolate, useAnimatedStyle } from 'react-native-reanimated'; import { HeaderWrapper } from '../../common/components/HeaderWrapper'; import { usePredefinedFlashListHeader } from '../../common/hooks/usePredefinedFlashListHeader'; import { scrollPosition } from '../../common/utils/scrollPosition'; import type { DetailsHeaderFlashListProps } from '../DetailsHeaderProps'; import { Foreground } from '../components/HeaderForeground'; export function useDetailsFlashListHeader = FlashList>( props: DetailsHeaderFlashListProps ) { const { contentBackgroundColor, onMomentumScrollEnd, onScroll, onScrollEndDrag, parallaxHeight, scrollHeight, scrollValue, scrollViewRef, } = usePredefinedFlashListHeader(props); const { backgroundColor, backgroundImage, contentIcon, contentIconNumber, contentIconNumberStyle, contentIconNumberTestID, hasBorderRadius, image, subtitle, subtitleStyle, subtitleTestID, tabsContainerBackgroundColor, tag, tagStyle, tagTestID, title, titleStyle, titleTestID, } = props; const headerTitleInputRange = [ 0, scrollPosition(scrollHeight, 60), scrollPosition(scrollHeight, 90), ]; const headerTitleContainerAnimatedStyle = useAnimatedStyle(() => { return { opacity: interpolate(scrollValue.value, headerTitleInputRange, [0, 0, 1], Extrapolate.CLAMP), }; // eslint-disable-next-line react-hooks/exhaustive-deps }, [scrollValue, scrollHeight]); const renderHeader = React.useCallback(() => { return ( ); }, [ backgroundColor, backgroundImage, contentBackgroundColor, contentIcon, contentIconNumber, contentIconNumberStyle, contentIconNumberTestID, hasBorderRadius, image, parallaxHeight, scrollHeight, scrollValue, subtitle, subtitleStyle, subtitleTestID, tabsContainerBackgroundColor, tag, tagStyle, tagTestID, title, titleStyle, titleTestID, ]); return { headerTitleContainerAnimatedStyle, onMomentumScrollEnd, onScroll, onScrollEndDrag, renderHeader, scrollValue, scrollViewRef, }; }