mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
at thread-bug 77 lines 2.4 kB view raw
1import React from 'react' 2import {View} from 'react-native' 3import {msg} from '@lingui/macro' 4import {useLingui} from '@lingui/react' 5 6import {useKawaiiMode} from '#/state/preferences/kawaii' 7import {useSession} from '#/state/session' 8import {useShellLayout} from '#/state/shell/shell-layout' 9import {HomeHeaderLayoutMobile} from '#/view/com/home/HomeHeaderLayoutMobile' 10import {Logo} from '#/view/icons/Logo' 11import {atoms as a, useBreakpoints, useGutters, useTheme} from '#/alf' 12import {ButtonIcon} from '#/components/Button' 13import {Hashtag_Stroke2_Corner0_Rounded as FeedsIcon} from '#/components/icons/Hashtag' 14import * as Layout from '#/components/Layout' 15import {Link} from '#/components/Link' 16 17export function HomeHeaderLayout(props: { 18 children: React.ReactNode 19 tabBarAnchor: JSX.Element | null | undefined 20}) { 21 const {gtMobile} = useBreakpoints() 22 if (!gtMobile) { 23 return <HomeHeaderLayoutMobile {...props} /> 24 } else { 25 return <HomeHeaderLayoutDesktopAndTablet {...props} /> 26 } 27} 28 29function HomeHeaderLayoutDesktopAndTablet({ 30 children, 31 tabBarAnchor, 32}: { 33 children: React.ReactNode 34 tabBarAnchor: JSX.Element | null | undefined 35}) { 36 const t = useTheme() 37 const {headerHeight} = useShellLayout() 38 const {hasSession} = useSession() 39 const {_} = useLingui() 40 const kawaii = useKawaiiMode() 41 const gutters = useGutters([0, 'base']) 42 43 return ( 44 <> 45 {hasSession && ( 46 <Layout.Center> 47 <View 48 style={[a.flex_row, a.align_center, gutters, a.pt_md, t.atoms.bg]}> 49 <View style={{width: 34}} /> 50 <View style={[a.flex_1, a.align_center, a.justify_center]}> 51 <Logo width={kawaii ? 60 : 28} /> 52 </View> 53 <Link 54 to="/feeds" 55 hitSlop={10} 56 label={_(msg`View your feeds and explore more`)} 57 size="small" 58 variant="ghost" 59 color="secondary" 60 shape="square" 61 style={[a.justify_center]}> 62 <ButtonIcon icon={FeedsIcon} size="lg" /> 63 </Link> 64 </View> 65 </Layout.Center> 66 )} 67 {tabBarAnchor} 68 <Layout.Center 69 style={[a.sticky, a.z_10, a.align_center, t.atoms.bg, {top: 0}]} 70 onLayout={e => { 71 headerHeight.set(e.nativeEvent.layout.height) 72 }}> 73 {children} 74 </Layout.Center> 75 </> 76 ) 77}