mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
at static-click 80 lines 2.3 kB view raw
1import React from 'react' 2import {View} from 'react-native' 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 {useHapticsDisabled} from '#/state/preferences' 9import {useProfileQuery} from '#/state/queries/profile' 10import {useSession} from '#/state/session' 11import {UserAvatar} from '#/view/com/util/UserAvatar' 12import {atoms as a, useBreakpoints, useTheme} from '#/alf' 13import {useInteractionState} from '#/components/hooks/useInteractionState' 14import {Text} from '#/components/Typography' 15 16export function PostThreadComposePrompt({ 17 onPressCompose, 18}: { 19 onPressCompose: () => void 20}) { 21 const {currentAccount} = useSession() 22 const {data: profile} = useProfileQuery({did: currentAccount?.did}) 23 const {_} = useLingui() 24 const {gtMobile} = useBreakpoints() 25 const t = useTheme() 26 const playHaptics = useHaptics() 27 const isHapticsDisabled = useHapticsDisabled() 28 const { 29 state: hovered, 30 onIn: onHoverIn, 31 onOut: onHoverOut, 32 } = useInteractionState() 33 34 const onPress = () => { 35 playHaptics('Light') 36 setTimeout( 37 () => { 38 onPressCompose() 39 }, 40 isHapticsDisabled ? 0 : 75, 41 ) 42 } 43 44 return ( 45 <PressableScale 46 accessibilityRole="button" 47 accessibilityLabel={_(msg`Compose reply`)} 48 accessibilityHint={_(msg`Opens composer`)} 49 style={[ 50 gtMobile ? a.py_xs : {paddingTop: 8, paddingBottom: 11}, 51 a.px_sm, 52 a.border_t, 53 t.atoms.border_contrast_low, 54 t.atoms.bg, 55 ]} 56 onPress={onPress} 57 onHoverIn={onHoverIn} 58 onHoverOut={onHoverOut}> 59 <View 60 style={[ 61 a.flex_row, 62 a.align_center, 63 a.p_sm, 64 a.gap_sm, 65 a.rounded_full, 66 (!gtMobile || hovered) && t.atoms.bg_contrast_25, 67 a.transition_color, 68 ]}> 69 <UserAvatar 70 size={gtMobile ? 24 : 22} 71 avatar={profile?.avatar} 72 type={profile?.associated?.labeler ? 'labeler' : 'user'} 73 /> 74 <Text style={[a.text_md, t.atoms.text_contrast_medium]}> 75 <Trans>Write your reply</Trans> 76 </Text> 77 </View> 78 </PressableScale> 79 ) 80}