diff options
Diffstat (limited to 'src/view/com/pager')
-rw-r--r-- | src/view/com/pager/PagerWithHeader.web.tsx | 60 |
1 files changed, 11 insertions, 49 deletions
diff --git a/src/view/com/pager/PagerWithHeader.web.tsx b/src/view/com/pager/PagerWithHeader.web.tsx index 13c723f47..3335532b3 100644 --- a/src/view/com/pager/PagerWithHeader.web.tsx +++ b/src/view/com/pager/PagerWithHeader.web.tsx @@ -1,10 +1,10 @@ import * as React from 'react' -import {ScrollView, StyleSheet, View} from 'react-native' +import {ScrollView, View} from 'react-native' import {useAnimatedRef} from 'react-native-reanimated' -import {usePalette} from '#/lib/hooks/usePalette' -import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' import {Pager, PagerRef, RenderTabBarFnProps} from '#/view/com/pager/Pager' +import {atoms as a, web} from '#/alf' +import * as Layout from '#/components/Layout' import {ListMethods} from '../util/List' import {TabBar} from './TabBar' @@ -121,30 +121,19 @@ let PagerTabBar = ({ onSelect?: (index: number) => void tabBarAnchor?: JSX.Element | null | undefined }): React.ReactNode => { - const pal = usePalette('default') - const {isMobile} = useWebMediaQueries() return ( <> - <View - style={[ - !isMobile && styles.headerContainerDesktop, - pal.border, - !isHeaderReady && styles.loadingHeader, - ]}> - {renderHeader?.()} - </View> + <Layout.Center>{renderHeader?.()}</Layout.Center> {tabBarAnchor} - <View - style={[ - styles.tabBarContainer, - isMobile - ? styles.tabBarContainerMobile - : styles.tabBarContainerDesktop, - pal.border, + <Layout.Center + style={web([ + a.sticky, + a.z_10, { + top: 0, display: isHeaderReady ? undefined : 'none', }, - ]}> + ])}> <TabBar testID={testID} items={items} @@ -154,7 +143,7 @@ let PagerTabBar = ({ dragProgress={undefined as any /* native-only */} dragState={undefined as any /* native-only */} /> - </View> + </Layout.Center> </> ) } @@ -180,33 +169,6 @@ function PagerItem({ }) } -const styles = StyleSheet.create({ - headerContainerDesktop: { - marginHorizontal: 'auto', - width: 600, - borderLeftWidth: 1, - borderRightWidth: 1, - }, - tabBarContainer: { - // @ts-ignore web-only - position: 'sticky', - top: 0, - zIndex: 1, - }, - tabBarContainerDesktop: { - marginHorizontal: 'auto', - width: 600, - borderLeftWidth: 1, - borderRightWidth: 1, - }, - tabBarContainerMobile: { - paddingHorizontal: 0, - }, - loadingHeader: { - borderColor: 'transparent', - }, -}) - function toArray<T>(v: T | T[]): T[] { if (Array.isArray(v)) { return v |