diff options
author | dan <dan.abramov@gmail.com> | 2024-02-22 16:03:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-22 16:03:20 +0000 |
commit | 1ccb3be961795c569c8c1eb64ca0617bd6548e79 (patch) | |
tree | d4fe90ae567470c020f7fea896f2a5d4b3186aa3 /src/view/com/home/HomeHeaderLayout.web.tsx | |
parent | 93b5eff4d79a27557338e86c12f887316915a1fb (diff) | |
download | voidsky-1ccb3be961795c569c8c1eb64ca0617bd6548e79.tar.zst |
Refactor feed header components (#2964)
* Move home-related files to view/com/home * Add HomeHeader in front of FeedTabBar * Move isDekstop check outside FeedsTabBar * Remove PWI logic from tabbar * Separate platform-specific layout from shared logic
Diffstat (limited to 'src/view/com/home/HomeHeaderLayout.web.tsx')
-rw-r--r-- | src/view/com/home/HomeHeaderLayout.web.tsx | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/view/com/home/HomeHeaderLayout.web.tsx b/src/view/com/home/HomeHeaderLayout.web.tsx new file mode 100644 index 000000000..47cb00235 --- /dev/null +++ b/src/view/com/home/HomeHeaderLayout.web.tsx @@ -0,0 +1,50 @@ +import React from 'react' +import {StyleSheet} from 'react-native' +import Animated from 'react-native-reanimated' +import {usePalette} from 'lib/hooks/usePalette' +import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' +import {HomeHeaderLayoutMobile} from './HomeHeaderLayoutMobile' +import {useMinimalShellMode} from 'lib/hooks/useMinimalShellMode' +import {useShellLayout} from '#/state/shell/shell-layout' + +export function HomeHeaderLayout({children}: {children: React.ReactNode}) { + const {isMobile} = useWebMediaQueries() + if (isMobile) { + return <HomeHeaderLayoutMobile>{children}</HomeHeaderLayoutMobile> + } else { + return <HomeHeaderLayoutTablet>{children}</HomeHeaderLayoutTablet> + } +} + +function HomeHeaderLayoutTablet({children}: {children: React.ReactNode}) { + 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, pal.border, styles.tabBar, headerMinimalShellTransform]} + onLayout={e => { + headerHeight.value = e.nativeEvent.layout.height + }}> + {children} + </Animated.View> + ) +} + +const styles = StyleSheet.create({ + tabBar: { + // @ts-ignore Web only + position: 'sticky', + zIndex: 1, + // @ts-ignore Web only -prf + left: 'calc(50% - 300px)', + width: 600, + top: 0, + flexDirection: 'row', + alignItems: 'center', + borderLeftWidth: 1, + borderRightWidth: 1, + }, +}) |