From c627a766cd7491e12e31e6a37bf114e3ddb24f7e Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 9 Nov 2023 21:45:31 +0000 Subject: [PATCH] Show tabs when swiping feeds (#1856) --- src/view/com/pager/Pager.tsx | 11 ++++++++--- src/view/screens/Home.tsx | 10 ++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/view/com/pager/Pager.tsx b/src/view/com/pager/Pager.tsx index 531a41ee2b..d70087504f 100644 --- a/src/view/com/pager/Pager.tsx +++ b/src/view/com/pager/Pager.tsx @@ -26,6 +26,9 @@ interface Props { renderTabBar: RenderTabBarFn onPageSelected?: (index: number) => void onPageSelecting?: (index: number) => void + onPageScrollStateChanged?: ( + scrollState: 'idle' | 'dragging' | 'settling', + ) => void testID?: string } export const Pager = forwardRef>( @@ -35,6 +38,7 @@ export const Pager = forwardRef>( tabBarPosition = 'top', initialPage = 0, renderTabBar, + onPageScrollStateChanged, onPageSelected, onPageSelecting, testID, @@ -97,11 +101,12 @@ export const Pager = forwardRef>( [lastOffset, lastDirection, onPageSelecting], ) - const onPageScrollStateChanged = React.useCallback( + const handlePageScrollStateChanged = React.useCallback( (e: PageScrollStateChangedNativeEvent) => { scrollState.current = e.nativeEvent.pageScrollState + onPageScrollStateChanged?.(e.nativeEvent.pageScrollState) }, - [scrollState], + [scrollState, onPageScrollStateChanged], ) const onTabBarSelect = React.useCallback( @@ -123,7 +128,7 @@ export const Pager = forwardRef>( ref={pagerView} style={s.flex1} initialPage={initialPage} - onPageScrollStateChanged={onPageScrollStateChanged} + onPageScrollStateChanged={handlePageScrollStateChanged} onPageSelected={onPageSelectedInner} onPageScroll={onPageScroll}> {children} diff --git a/src/view/screens/Home.tsx b/src/view/screens/Home.tsx index c581753277..d6603a9369 100644 --- a/src/view/screens/Home.tsx +++ b/src/view/screens/Home.tsx @@ -85,6 +85,15 @@ export const HomeScreen = withAuthRequired( store.emitScreenSoftReset() }, [store]) + const onPageScrollStateChanged = React.useCallback( + (state: 'idle' | 'dragging' | 'settling') => { + if (state === 'dragging') { + setMinimalShellMode(false) + } + }, + [setMinimalShellMode], + ) + const renderTabBar = React.useCallback( (props: RenderTabBarFnProps) => { return ( @@ -113,6 +122,7 @@ export const HomeScreen = withAuthRequired( ref={pagerRef} testID="homeScreen" onPageSelected={onPageSelected} + onPageScrollStateChanged={onPageScrollStateChanged} renderTabBar={renderTabBar} tabBarPosition="top">