mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2import {TouchableOpacity, StyleSheet, Keyboard} from 'react-native'
3import {
4 FontAwesomeIcon,
5 FontAwesomeIconStyle,
6} from '@fortawesome/react-native-fontawesome'
7import {usePalette} from 'lib/hooks/usePalette'
8import {useAnalytics} from 'lib/analytics/analytics'
9import {HITSLOP_10} from 'lib/constants'
10import {useLingui} from '@lingui/react'
11import {msg} from '@lingui/macro'
12import {useModalControls} from '#/state/modals'
13import {ThreadgateSetting} from '#/state/queries/threadgate'
14import {isNative} from '#/platform/detection'
15
16export function ThreadgateBtn({
17 threadgate,
18 onChange,
19}: {
20 threadgate: ThreadgateSetting[]
21 onChange: (v: ThreadgateSetting[]) => void
22}) {
23 const pal = usePalette('default')
24 const {track} = useAnalytics()
25 const {_} = useLingui()
26 const {openModal} = useModalControls()
27
28 const onPress = () => {
29 track('Composer:ThreadgateOpened')
30 if (isNative && Keyboard.isVisible()) {
31 Keyboard.dismiss()
32 }
33 openModal({
34 name: 'threadgate',
35 settings: threadgate,
36 onChange,
37 })
38 }
39
40 return (
41 <TouchableOpacity
42 testID="openReplyGateButton"
43 onPress={onPress}
44 style={styles.button}
45 hitSlop={HITSLOP_10}
46 accessibilityRole="button"
47 accessibilityLabel={_(msg`Who can reply`)}
48 accessibilityHint="">
49 <FontAwesomeIcon
50 icon={['far', 'comments']}
51 style={pal.link as FontAwesomeIconStyle}
52 size={24}
53 />
54 {threadgate.length ? (
55 <FontAwesomeIcon
56 icon="check"
57 size={16}
58 style={pal.link as FontAwesomeIconStyle}
59 />
60 ) : null}
61 </TouchableOpacity>
62 )
63}
64
65const styles = StyleSheet.create({
66 button: {
67 flexDirection: 'row',
68 alignItems: 'center',
69 paddingHorizontal: 6,
70 gap: 4,
71 },
72})