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