import { View } from '@/components/ui/view'; import { useBottomTabOverflow } from '@/hooks/useBottomTabOverflow'; import { useColor } from '@/hooks/useColor'; import type { PropsWithChildren, ReactElement } from 'react'; import Animated, { interpolate, useAnimatedRef, useAnimatedStyle, useScrollViewOffset, } from 'react-native-reanimated'; type Props = PropsWithChildren<{ headerHeight?: number; headerImage: ReactElement; }>; export function ParallaxScrollView({ children, headerHeight = 250, headerImage, }: Props) { const backgroundColor = useColor('background'); const scrollRef = useAnimatedRef(); const scrollOffset = useScrollViewOffset(scrollRef); const bottom = useBottomTabOverflow(); const headerAnimatedStyle = useAnimatedStyle(() => { return { transform: [ { translateY: interpolate( scrollOffset.value, [-headerHeight, 0, headerHeight], [-headerHeight / 2, 0, headerHeight * 0.75] ), }, { scale: interpolate( scrollOffset.value, [-headerHeight, 0, headerHeight], [2, 1, 1] ), }, ], }; }); return ( {headerImage} {children} ); }