1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
import {memo} from 'react'
import {View} from 'react-native'
import {msg, Plural, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {
type PostThreadParams,
type ThreadItem,
} from '#/state/queries/usePostThread'
import {
LINEAR_AVI_WIDTH,
REPLY_LINE_WIDTH,
TREE_AVI_WIDTH,
TREE_INDENT,
} from '#/screens/PostThread/const'
import {atoms as a, useTheme} from '#/alf'
import {CirclePlus_Stroke2_Corner0_Rounded as CirclePlus} from '#/components/icons/CirclePlus'
import {Link} from '#/components/Link'
import {Text} from '#/components/Typography'
export const ThreadItemReadMore = memo(function ThreadItemReadMore({
item,
view,
}: {
item: Extract<ThreadItem, {type: 'readMore'}>
view: PostThreadParams['view']
}) {
const t = useTheme()
const {_} = useLingui()
const isTreeView = view === 'tree'
const indent = Math.max(0, item.depth - 1)
const spacers = isTreeView
? Array.from(Array(indent)).map((_, n: number) => {
const isSkipped = item.skippedIndentIndices.has(n)
return (
<View
key={`${item.key}-padding-${n}`}
style={[
t.atoms.border_contrast_low,
{
borderRightWidth: isSkipped ? 0 : REPLY_LINE_WIDTH,
width: TREE_INDENT + TREE_AVI_WIDTH / 2,
left: 1,
},
]}
/>
)
})
: null
return (
<View style={[a.flex_row]}>
{spacers}
<View
style={[
t.atoms.border_contrast_low,
{
marginLeft: isTreeView
? TREE_INDENT + TREE_AVI_WIDTH / 2 - 1
: (LINEAR_AVI_WIDTH - REPLY_LINE_WIDTH) / 2 + 16,
borderLeftWidth: 2,
borderBottomWidth: 2,
borderBottomLeftRadius: a.rounded_sm.borderRadius,
height: 18, // magic, Link below is 38px tall
width: isTreeView ? TREE_INDENT : LINEAR_AVI_WIDTH / 2 + 10,
},
]}
/>
<Link
label={_(msg`Read more replies`)}
to={item.href}
style={[a.pt_sm, a.pb_md, a.gap_xs]}>
{({hovered, pressed}) => {
const interacted = hovered || pressed
return (
<>
<CirclePlus
fill={
interacted
? t.atoms.text_contrast_high.color
: t.atoms.text_contrast_low.color
}
width={18}
/>
<Text
style={[
a.text_sm,
t.atoms.text_contrast_medium,
interacted && a.underline,
]}>
<Trans>
Read{' '}
<Plural
one="# more reply"
other="# more replies"
value={item.moreReplies}
/>
</Trans>
</Text>
</>
)
}}
</Link>
</View>
)
})
|