diff options
author | dan <dan.abramov@gmail.com> | 2023-11-09 20:15:05 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-09 12:15:05 -0800 |
commit | 7a55ca613347680cd94add01faa5dc3f216b9bd2 (patch) | |
tree | d9fa7951b43a8148b44e12a93452e214e1c4a798 /src/view | |
parent | 1dcf882619bc2d6b3eefebf83e76f4b21871b791 (diff) | |
download | voidsky-7a55ca613347680cd94add01faa5dc3f216b9bd2.tar.zst |
Sync top/bottom bar disappearance to the scroll (#1855)
* Disable existing code that toggles shell * Make shell mode a float * Translate based on the gesture * Track header and footer heights * Add web support * Fix types and cleanup * Add back isScrolled logic * Add comments
Diffstat (limited to 'src/view')
-rw-r--r-- | src/view/com/feeds/FeedPage.tsx | 2 | ||||
-rw-r--r-- | src/view/com/notifications/Feed.tsx | 2 | ||||
-rw-r--r-- | src/view/com/pager/FeedsTabBar.web.tsx | 7 | ||||
-rw-r--r-- | src/view/com/pager/FeedsTabBarMobile.tsx | 12 | ||||
-rw-r--r-- | src/view/shell/bottom-bar/BottomBar.tsx | 7 |
5 files changed, 20 insertions, 10 deletions
diff --git a/src/view/com/feeds/FeedPage.tsx b/src/view/com/feeds/FeedPage.tsx index 044f69efe..ffae6cbf4 100644 --- a/src/view/com/feeds/FeedPage.tsx +++ b/src/view/com/feeds/FeedPage.tsx @@ -182,7 +182,7 @@ export const FeedPage = observer(function FeedPageImpl({ feed={feed} scrollElRef={scrollElRef} onScroll={onMainScroll} - scrollEventThrottle={100} + scrollEventThrottle={1} renderEmptyState={renderEmptyState} renderEndOfFeed={renderEndOfFeed} ListHeaderComponent={ListHeaderComponent} diff --git a/src/view/com/notifications/Feed.tsx b/src/view/com/notifications/Feed.tsx index 74769bc76..dff84ec77 100644 --- a/src/view/com/notifications/Feed.tsx +++ b/src/view/com/notifications/Feed.tsx @@ -162,7 +162,7 @@ export const Feed = observer(function Feed({ onEndReached={onEndReached} onEndReachedThreshold={0.6} onScroll={onScroll} - scrollEventThrottle={100} + scrollEventThrottle={1} contentContainerStyle={s.contentContainer} // @ts-ignore our .web version only -prf desktopFixedHeight diff --git a/src/view/com/pager/FeedsTabBar.web.tsx b/src/view/com/pager/FeedsTabBar.web.tsx index 25755bafe..296af76e4 100644 --- a/src/view/com/pager/FeedsTabBar.web.tsx +++ b/src/view/com/pager/FeedsTabBar.web.tsx @@ -10,6 +10,7 @@ import {usePalette} from 'lib/hooks/usePalette' import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' import {FeedsTabBar as FeedsTabBarMobile} from './FeedsTabBarMobile' import {useMinimalShellMode} from 'lib/hooks/useMinimalShellMode' +import {useShellLayout} from '#/state/shell/shell-layout' export const FeedsTabBar = observer(function FeedsTabBarImpl( props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void}, @@ -31,11 +32,15 @@ const FeedsTabBarTablet = observer(function FeedsTabBarTabletImpl( const items = useHomeTabs(store.preferences.pinnedFeeds) const pal = usePalette('default') const {headerMinimalShellTransform} = useMinimalShellMode() + const {headerHeight} = useShellLayout() return ( // @ts-ignore the type signature for transform wrong here, translateX and translateY need to be in separate objects -prf <Animated.View - style={[pal.view, styles.tabBar, headerMinimalShellTransform]}> + style={[pal.view, styles.tabBar, headerMinimalShellTransform]} + onLayout={e => { + headerHeight.value = e.nativeEvent.layout.height + }}> <TabBar key={items.join(',')} {...props} diff --git a/src/view/com/pager/FeedsTabBarMobile.tsx b/src/view/com/pager/FeedsTabBarMobile.tsx index 791fe71be..5fda0a991 100644 --- a/src/view/com/pager/FeedsTabBarMobile.tsx +++ b/src/view/com/pager/FeedsTabBarMobile.tsx @@ -18,6 +18,7 @@ import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useMinimalShellMode} from 'lib/hooks/useMinimalShellMode' import {useSetDrawerOpen} from '#/state/shell/drawer-open' +import {useShellLayout} from '#/state/shell/shell-layout' export const FeedsTabBar = observer(function FeedsTabBarImpl( props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void}, @@ -28,6 +29,7 @@ export const FeedsTabBar = observer(function FeedsTabBarImpl( const setDrawerOpen = useSetDrawerOpen() const items = useHomeTabs(store.preferences.pinnedFeeds) const brandBlue = useColorSchemeStyle(s.brandBlue, s.blue3) + const {headerHeight} = useShellLayout() const {headerMinimalShellTransform} = useMinimalShellMode() const onPressAvi = React.useCallback(() => { @@ -36,12 +38,10 @@ export const FeedsTabBar = observer(function FeedsTabBarImpl( return ( <Animated.View - style={[ - pal.view, - pal.border, - styles.tabBar, - headerMinimalShellTransform, - ]}> + style={[pal.view, pal.border, styles.tabBar, headerMinimalShellTransform]} + onLayout={e => { + headerHeight.value = e.nativeEvent.layout.height + }}> <View style={[pal.view, styles.topBar]}> <View style={[pal.view]}> <TouchableOpacity diff --git a/src/view/shell/bottom-bar/BottomBar.tsx b/src/view/shell/bottom-bar/BottomBar.tsx index 69a7c4c0e..3dd7f57c5 100644 --- a/src/view/shell/bottom-bar/BottomBar.tsx +++ b/src/view/shell/bottom-bar/BottomBar.tsx @@ -27,6 +27,7 @@ import {UserAvatar} from 'view/com/util/UserAvatar' import {useLingui} from '@lingui/react' import {msg} from '@lingui/macro' import {useModalControls} from '#/state/modals' +import {useShellLayout} from '#/state/shell/shell-layout' type TabOptions = 'Home' | 'Search' | 'Notifications' | 'MyProfile' | 'Feeds' @@ -39,6 +40,7 @@ export const BottomBar = observer(function BottomBarImpl({ const {_} = useLingui() const safeAreaInsets = useSafeAreaInsets() const {track} = useAnalytics() + const {footerHeight} = useShellLayout() const {isAtHome, isAtSearch, isAtFeeds, isAtNotifications, isAtMyProfile} = useNavigationTabState() @@ -88,7 +90,10 @@ export const BottomBar = observer(function BottomBarImpl({ pal.border, {paddingBottom: clamp(safeAreaInsets.bottom, 15, 30)}, footerMinimalShellTransform, - ]}> + ]} + onLayout={e => { + footerHeight.value = e.nativeEvent.layout.height + }}> <Btn testID="bottomBarHomeBtn" icon={ |