import React from 'react' import {StyleProp, View, ViewStyle} from 'react-native' import Animated, { Extrapolation, interpolate, SharedValue, useAnimatedStyle, } from 'react-native-reanimated' import {isIOS} from '#/platform/detection' import {usePagerHeaderContext} from '#/view/com/pager/PagerHeaderContext' export function GrowableAvatar({ children, style, }: { children: React.ReactNode style?: StyleProp }) { const pagerContext = usePagerHeaderContext() // pagerContext should only be present on iOS, but better safe than sorry if (!pagerContext || !isIOS) { return {children} } const {scrollY} = pagerContext return ( {children} ) } function GrowableAvatarInner({ scrollY, children, style, }: { scrollY: SharedValue children: React.ReactNode style?: StyleProp }) { const animatedStyle = useAnimatedStyle(() => ({ transform: [ { scale: interpolate(scrollY.get(), [-150, 0], [1.2, 1], { extrapolateRight: Extrapolation.CLAMP, }), }, ], })) return ( {children} ) }