@@ -35,6 +35,10 @@ const FlashListWithHeadersInputComp = <ItemT extends any = any>(
3535 disableAutoFixScroll = false ,
3636 /** At the moment, we will not allow overriding of this since the scrollHandler needs it. */
3737 onScroll : _unusedOnScroll ,
38+ absoluteHeader = false ,
39+ initialAbsoluteHeaderHeight = 0 ,
40+ contentContainerStyle = { } ,
41+ automaticallyAdjustsScrollIndicatorInsets,
3842 ...rest
3943 } : AnimatedFlashListType < ItemT > ,
4044 ref : React . Ref < FlashList < ItemT > >
@@ -50,11 +54,15 @@ const FlashListWithHeadersInputComp = <ItemT extends any = any>(
5054 largeHeaderOpacity,
5155 scrollHandler,
5256 debouncedFixScroll,
57+ absoluteHeaderHeight,
58+ onAbsoluteHeaderLayout,
5359 } = useScrollContainerLogic ( {
5460 scrollRef,
5561 largeHeaderShown,
5662 disableAutoFixScroll,
5763 largeHeaderExists : ! ! LargeHeaderComponent ,
64+ absoluteHeader,
65+ initialAbsoluteHeaderHeight,
5866 } ) ;
5967
6068 return (
@@ -66,7 +74,7 @@ const FlashListWithHeadersInputComp = <ItemT extends any = any>(
6674 ! ignoreRightSafeArea && { paddingRight : insets . right } ,
6775 ] }
6876 >
69- { HeaderComponent ( { showNavBar, scrollY } ) }
77+ { ! absoluteHeader && HeaderComponent ( { showNavBar, scrollY } ) }
7078 < AnimatedFlashList
7179 ref = { scrollRef }
7280 scrollEventThrottle = { 16 }
@@ -89,6 +97,19 @@ const FlashListWithHeadersInputComp = <ItemT extends any = any>(
8997 debouncedFixScroll ( ) ;
9098 if ( onMomentumScrollEnd ) onMomentumScrollEnd ( e ) ;
9199 } }
100+ // eslint-disable-next-line react-native/no-inline-styles
101+ contentContainerStyle = { {
102+ // The reason why we do this is because FlashList does not support an array of
103+ // styles (will throw a warning when you supply one).
104+ ...contentContainerStyle ,
105+ paddingTop : absoluteHeader ? absoluteHeaderHeight : 0 ,
106+ } }
107+ automaticallyAdjustsScrollIndicatorInsets = {
108+ automaticallyAdjustsScrollIndicatorInsets !== undefined
109+ ? automaticallyAdjustsScrollIndicatorInsets
110+ : ! absoluteHeader
111+ }
112+ scrollIndicatorInsets = { { top : absoluteHeader ? absoluteHeaderHeight : 0 } }
92113 ListHeaderComponent = {
93114 LargeHeaderComponent ? (
94115 < View
@@ -106,6 +127,12 @@ const FlashListWithHeadersInputComp = <ItemT extends any = any>(
106127 }
107128 { ...rest }
108129 />
130+
131+ { absoluteHeader && (
132+ < View style = { styles . absoluteHeader } onLayout = { onAbsoluteHeaderLayout } >
133+ { HeaderComponent ( { showNavBar, scrollY } ) }
134+ </ View >
135+ ) }
109136 </ View >
110137 ) ;
111138} ;
@@ -117,4 +144,12 @@ const FlashListWithHeaders = React.forwardRef(FlashListWithHeadersInputComp) as
117144
118145export default FlashListWithHeaders ;
119146
120- const styles = StyleSheet . create ( { container : { flex : 1 } } ) ;
147+ const styles = StyleSheet . create ( {
148+ container : { flex : 1 } ,
149+ absoluteHeader : {
150+ position : 'absolute' ,
151+ top : 0 ,
152+ right : 0 ,
153+ left : 0 ,
154+ } ,
155+ } ) ;
0 commit comments