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
|
import {useCallback, useMemo} from 'react'
import {LayoutAnimation, type TextStyle} from 'react-native'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {HITSLOP_10} from '#/lib/constants'
import {atoms as a, flatten, type TextStyleProp, useTheme} from '#/alf'
import {Button} from '#/components/Button'
import {Text} from '#/components/Typography'
export function ShowMoreTextButton({
onPress: onPressProp,
style,
}: TextStyleProp & {onPress: () => void}) {
const t = useTheme()
const {_} = useLingui()
const onPress = useCallback(() => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)
onPressProp()
}, [onPressProp])
const textStyle = useMemo(() => {
return flatten([a.leading_snug, a.text_sm, style]) as TextStyle & {
fontSize: number
lineHeight: number
}
}, [style])
return (
<Button
label={_(msg`Expand post text`)}
onPress={onPress}
style={[
a.self_start,
{
paddingBottom: textStyle.fontSize / 3,
},
]}
hitSlop={HITSLOP_10}>
{({pressed, hovered}) => (
<Text
style={[
textStyle,
{
color: t.palette.primary_500,
opacity: pressed ? 0.6 : 1,
textDecorationLine: hovered ? 'underline' : undefined,
},
]}>
<Trans>Show More</Trans>
</Text>
)}
</Button>
)
}
|