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