Bluesky app fork with some witchin' additions 馃挮
at main 93 lines 2.9 kB view raw
1import {View} from 'react-native' 2import Animated from 'react-native-reanimated' 3import {useSafeAreaInsets} from 'react-native-safe-area-context' 4import {msg} from '@lingui/core/macro' 5import {useLingui} from '@lingui/react' 6 7import {HITSLOP_10} from '#/lib/constants' 8import {PressableScale} from '#/lib/custom-animations/PressableScale' 9import {useHaptics} from '#/lib/haptics' 10import {useMinimalShellHeaderTransform} from '#/lib/hooks/useMinimalShellTransform' 11import {emitSoftReset} from '#/state/events' 12import {useSession} from '#/state/session' 13import {useShellLayout} from '#/state/shell/shell-layout' 14import {Logo} from '#/view/icons/Logo' 15import {atoms as a, useTheme} from '#/alf' 16import {ButtonIcon} from '#/components/Button' 17import {Hashtag_Stroke2_Corner0_Rounded as FeedsIcon} from '#/components/icons/Hashtag' 18import * as Layout from '#/components/Layout' 19import {Link} from '#/components/Link' 20import {IS_LIQUID_GLASS} from '#/env' 21 22export function HomeHeaderLayoutMobile({ 23 children, 24}: { 25 children: React.ReactNode 26 tabBarAnchor: React.ReactElement | null | undefined 27}) { 28 const t = useTheme() 29 const {_} = useLingui() 30 const {headerHeight} = useShellLayout() 31 const insets = useSafeAreaInsets() 32 const headerMinimalShellTransform = useMinimalShellHeaderTransform() 33 const {hasSession} = useSession() 34 const playHaptic = useHaptics() 35 36 return ( 37 <Animated.View 38 style={[ 39 a.fixed, 40 a.z_10, 41 t.atoms.bg, 42 { 43 top: 0, 44 left: 0, 45 right: 0, 46 }, 47 IS_LIQUID_GLASS && {paddingTop: insets.top}, 48 headerMinimalShellTransform, 49 ]} 50 onLayout={e => { 51 headerHeight.set(e.nativeEvent.layout.height) 52 }}> 53 <Layout.Header.Outer noBottomBorder> 54 <Layout.Header.Slot> 55 <Layout.Header.MenuButton /> 56 </Layout.Header.Slot> 57 58 <View style={[a.flex_1, a.align_center]}> 59 <PressableScale 60 targetScale={0.9} 61 onPress={() => { 62 playHaptic('Light') 63 emitSoftReset() 64 }}> 65 <Logo width={30} /> 66 </PressableScale> 67 </View> 68 69 <Layout.Header.Slot> 70 {hasSession && ( 71 <Link 72 testID="viewHeaderHomeFeedPrefsBtn" 73 to={{screen: 'Feeds'}} 74 hitSlop={HITSLOP_10} 75 label={_(msg`View your feeds and explore more`)} 76 size="small" 77 variant="ghost" 78 color="secondary" 79 shape="square" 80 style={[ 81 a.justify_center, 82 {marginRight: -Layout.BUTTON_VISUAL_ALIGNMENT_OFFSET}, 83 a.bg_transparent, 84 ]}> 85 <ButtonIcon icon={FeedsIcon} size="lg" /> 86 </Link> 87 )} 88 </Layout.Header.Slot> 89 </Layout.Header.Outer> 90 {children} 91 </Animated.View> 92 ) 93}