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