mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import {useCallback, useMemo} from 'react'
2import {LayoutAnimation, type TextStyle} from 'react-native'
3import {msg, Trans} from '@lingui/macro'
4import {useLingui} from '@lingui/react'
5
6import {HITSLOP_10} from '#/lib/constants'
7import {atoms as a, flatten, type TextStyleProp, useTheme} from '#/alf'
8import {Button} from '#/components/Button'
9import {Text} from '#/components/Typography'
10
11export function ShowMoreTextButton({
12 onPress: onPressProp,
13 style,
14}: TextStyleProp & {onPress: () => void}) {
15 const t = useTheme()
16 const {_} = useLingui()
17
18 const onPress = useCallback(() => {
19 LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)
20 onPressProp()
21 }, [onPressProp])
22
23 const textStyle = useMemo(() => {
24 return flatten([a.leading_snug, a.text_sm, style]) as TextStyle & {
25 fontSize: number
26 lineHeight: number
27 }
28 }, [style])
29
30 return (
31 <Button
32 label={_(msg`Expand post text`)}
33 onPress={onPress}
34 style={[
35 a.self_start,
36 {
37 paddingBottom: textStyle.fontSize / 3,
38 },
39 ]}
40 hitSlop={HITSLOP_10}>
41 {({pressed, hovered}) => (
42 <Text
43 style={[
44 textStyle,
45 {
46 color: t.palette.primary_500,
47 opacity: pressed ? 0.6 : 1,
48 textDecorationLine: hovered ? 'underline' : undefined,
49 },
50 ]}>
51 <Trans>Show More</Trans>
52 </Text>
53 )}
54 </Button>
55 )
56}