fork
Configure Feed
Select the types of activity you want to include in your feed.
mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
fork
Configure Feed
Select the types of activity you want to include in your feed.
1import React from 'react'
2import {Pressable, View} from 'react-native'
3import {msg} from '@lingui/macro'
4import {useLingui} from '@lingui/react'
5
6import {useRequireAuth} from '#/state/session'
7import {useSession} from '#/state/session'
8import {atoms as a, useTheme} from '#/alf'
9import {Button} from '#/components/Button'
10import {CloseQuote_Stroke2_Corner1_Rounded as Quote} from '#/components/icons/Quote'
11import {Repost_Stroke2_Corner2_Rounded as Repost} from '#/components/icons/Repost'
12import * as Menu from '#/components/Menu'
13import {Text} from '#/components/Typography'
14import {EventStopper} from '../EventStopper'
15
16interface Props {
17 isReposted: boolean
18 repostCount?: number
19 onRepost: () => void
20 onQuote: () => void
21 big?: boolean
22}
23
24export const RepostButton = ({
25 isReposted,
26 repostCount,
27 onRepost,
28 onQuote,
29 big,
30}: Props) => {
31 const t = useTheme()
32 const {_} = useLingui()
33 const {hasSession} = useSession()
34 const requireAuth = useRequireAuth()
35
36 const color = React.useMemo(
37 () => ({
38 color: isReposted ? t.palette.positive_600 : t.palette.contrast_500,
39 }),
40 [t, isReposted],
41 )
42
43 return hasSession ? (
44 <EventStopper onKeyDown={false}>
45 <Menu.Root>
46 <Menu.Trigger label={_(msg`Repost or quote post`)}>
47 {({props, state}) => {
48 return (
49 <Pressable
50 {...props}
51 style={[
52 a.rounded_full,
53 (state.hovered || state.pressed) && {
54 backgroundColor: t.palette.contrast_25,
55 },
56 ]}>
57 <RepostInner
58 isReposted={isReposted}
59 color={color}
60 repostCount={repostCount}
61 big={big}
62 />
63 </Pressable>
64 )
65 }}
66 </Menu.Trigger>
67 <Menu.Outer style={{minWidth: 170}}>
68 <Menu.Item
69 label={isReposted ? _(msg`Undo repost`) : _(msg`Repost`)}
70 testID="repostDropdownRepostBtn"
71 onPress={onRepost}>
72 <Menu.ItemText>
73 {isReposted ? _(msg`Undo repost`) : _(msg`Repost`)}
74 </Menu.ItemText>
75 <Menu.ItemIcon icon={Repost} position="right" />
76 </Menu.Item>
77 <Menu.Item
78 label={_(msg`Quote post`)}
79 testID="repostDropdownQuoteBtn"
80 onPress={onQuote}>
81 <Menu.ItemText>{_(msg`Quote post`)}</Menu.ItemText>
82 <Menu.ItemIcon icon={Quote} position="right" />
83 </Menu.Item>
84 </Menu.Outer>
85 </Menu.Root>
86 </EventStopper>
87 ) : (
88 <Button
89 onPress={() => {
90 requireAuth(() => {})
91 }}
92 label={_(msg`Repost or quote post`)}
93 style={{padding: 0}}
94 hoverStyle={t.atoms.bg_contrast_25}
95 shape="round"
96 variant="ghost"
97 color="secondary">
98 <RepostInner
99 isReposted={isReposted}
100 color={color}
101 repostCount={repostCount}
102 big={big}
103 />
104 </Button>
105 )
106}
107
108const RepostInner = ({
109 isReposted,
110 color,
111 repostCount,
112 big,
113}: {
114 isReposted: boolean
115 color: {color: string}
116 repostCount?: number
117 big?: boolean
118}) => (
119 <View style={[a.flex_row, a.align_center, a.gap_xs, {padding: 5}]}>
120 <Repost style={color} width={big ? 22 : 18} />
121 {typeof repostCount !== 'undefined' && repostCount > 0 ? (
122 <Text
123 testID="repostCount"
124 style={[
125 color,
126 big ? a.text_md : {fontSize: 15},
127 isReposted && [a.font_bold],
128 a.user_select_none,
129 ]}>
130 {repostCount}
131 </Text>
132 ) : undefined}
133 </View>
134)