mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import {type StyleProp, View, type ViewStyle} from 'react-native'
2import {LinearGradient} from 'expo-linear-gradient'
3import {msg, Trans} from '@lingui/macro'
4import {useLingui} from '@lingui/react'
5
6import {PressableScale} from '#/lib/custom-animations/PressableScale'
7import {useHaptics} from '#/lib/haptics'
8import {useHideBottomBarBorderForScreen} from '#/lib/hooks/useHideBottomBarBorder'
9import {useProfileQuery} from '#/state/queries/profile'
10import {useSession} from '#/state/session'
11import {UserAvatar} from '#/view/com/util/UserAvatar'
12import {atoms as a, ios, native, useBreakpoints, useTheme} from '#/alf'
13import {transparentifyColor} from '#/alf/util/colorGeneration'
14import {useInteractionState} from '#/components/hooks/useInteractionState'
15import {Text} from '#/components/Typography'
16
17export function PostThreadComposePrompt({
18 onPressCompose,
19 style,
20}: {
21 onPressCompose: () => void
22 style?: StyleProp<ViewStyle>
23}) {
24 const {currentAccount} = useSession()
25 const {data: profile} = useProfileQuery({did: currentAccount?.did})
26 const {_} = useLingui()
27 const {gtMobile} = useBreakpoints()
28 const t = useTheme()
29 const playHaptic = useHaptics()
30 const {
31 state: hovered,
32 onIn: onHoverIn,
33 onOut: onHoverOut,
34 } = useInteractionState()
35
36 useHideBottomBarBorderForScreen()
37
38 return (
39 <View
40 style={[
41 a.px_sm,
42 gtMobile
43 ? [a.py_xs, a.border_t, t.atoms.border_contrast_low, t.atoms.bg]
44 : [a.pb_2xs],
45 style,
46 ]}>
47 {!gtMobile && (
48 <LinearGradient
49 key={t.name} // android does not update when you change the colors. sigh.
50 start={[0.5, 0]}
51 end={[0.5, 1]}
52 colors={[
53 transparentifyColor(t.atoms.bg.backgroundColor, 0),
54 t.atoms.bg.backgroundColor,
55 ]}
56 locations={[0.15, 0.4]}
57 style={[a.absolute, a.inset_0]}
58 />
59 )}
60 <PressableScale
61 accessibilityRole="button"
62 accessibilityLabel={_(msg`Compose reply`)}
63 accessibilityHint={_(msg`Opens composer`)}
64 onPress={() => {
65 onPressCompose()
66 playHaptic('Light')
67 }}
68 onLongPress={ios(() => {
69 onPressCompose()
70 playHaptic('Heavy')
71 })}
72 onHoverIn={onHoverIn}
73 onHoverOut={onHoverOut}
74 style={[
75 a.flex_row,
76 a.align_center,
77 a.p_sm,
78 a.gap_sm,
79 a.rounded_full,
80 (!gtMobile || hovered) && t.atoms.bg_contrast_25,
81 native([a.border, t.atoms.border_contrast_low]),
82 a.transition_color,
83 ]}>
84 <UserAvatar
85 size={24}
86 avatar={profile?.avatar}
87 type={profile?.associated?.labeler ? 'labeler' : 'user'}
88 />
89 <Text style={[a.text_md, t.atoms.text_contrast_medium]}>
90 <Trans>Write your reply</Trans>
91 </Text>
92 </PressableScale>
93 </View>
94 )
95}