-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
const { top } = useSafeAreaInsets();
const prevScroll = useRef(0);
const tabMargin = useRef(0)
const navigation = useNavigation();
const tabBarHeight = useBottomTabBarHeight();
useFocusEffect(useCallback(() => {
navigation.getParent()?.setOptions({
tabBarStyle: {
marginBottom: 0
}
});
}, []))
const handleScroll = (e: NativeSyntheticEvent<NativeScrollEvent>) => {
const currentOffset = e.nativeEvent.contentOffset.y;
const maxHeight = e.nativeEvent.contentSize.height - e.nativeEvent.layoutMeasurement.height;
if (currentOffset == 0) {
setNavigation()
}
if (currentOffset > 0 && currentOffset <= maxHeight) {
if (currentOffset > prevScroll.current) {
if (tabMargin.current > -tabBarHeight) {
tabMargin.current = tabMargin.current - 5
}
} else {
if (tabMargin.current < 0) {
tabMargin.current = tabMargin.current + 5;
}
}
if (tabMargin.current > tabBarHeight) {
tabMargin.current = tabBarHeight
}
if (tabMargin.current < -tabBarHeight) {
tabMargin.current = -tabBarHeight
}
navigation.getParent()?.setOptions({
tabBarStyle: {
marginBottom: tabMargin.current
}
});
}
prevScroll.current = currentOffset;
}
<FlashList
onScroll={handleScroll}
scrollEventThrottle={16}
keyExtractor={(item) => item.id as string}
data={data}
onEndReachedThreshold={0.5}
showsVerticalScrollIndicator={false}
renderItem={({ item }) => (
<Link asChild suppressHighlighting href={{
pathname: '/(feed)/thread/[id]',
params: { id: item.id as string }
}}>
<TouchableOpacity activeOpacity={0.8} >
<Thread likeMessage={likeMessage} thread={item} />
</TouchableOpacity>
</Link>
)}
/>Metadata
Metadata
Assignees
Labels
No labels