import { ScrollView, View, Animated, Platform } from "react-native"; import React, { useRef } from "react"; export const DynamicHeaderScrollView = (props) => { const { Max_Header_Height = 200, Min_Header_Height = 80, children, scrollViewProps = {}, containerProps = {}, shortHeader = <>, longHeader = <>, topStickyContent, styles, } = props; const scrollOffsetY = useRef(new Animated.Value(0)).current; const Scroll_Distance = Max_Header_Height - Min_Header_Height; const animatedHeaderHeight = scrollOffsetY.interpolate({ inputRange: [Scroll_Distance, Scroll_Distance + 30], outputRange: [Max_Header_Height, 0], extrapolate: "clamp", }); const animatedHeaderHeight2 = scrollOffsetY.interpolate({ inputRange: [Scroll_Distance, Scroll_Distance + 30], outputRange: [Max_Header_Height, Min_Header_Height], extrapolate: "clamp", }); const animatedHeaderVisible = scrollOffsetY.interpolate({ inputRange: [Scroll_Distance - 30, Scroll_Distance], outputRange: [1, 0], extrapolate: "clamp", }); const animatedHeaderVisible2 = scrollOffsetY.interpolate({ inputRange: [Scroll_Distance - 30, Scroll_Distance + 30], outputRange: [0, 1], extrapolate: "clamp", }); return ( {shortHeader} {longHeader} {topStickyContent && ( {topStickyContent} )} {children} ); };