This commit is contained in:
Hailey
2024-01-11 02:01:20 -08:00
parent c6d2e54923
commit 648552eafb
15 changed files with 132 additions and 78 deletions
@@ -369,6 +369,7 @@ let PostThreadItemLoaded = ({
richText={richText}
lineHeight={1.3}
style={s.flex1}
selectable
/>
</View>
) : undefined}
+4 -1
View File
@@ -17,6 +17,7 @@ export function RichText({
lineHeight = 1.2,
style,
numberOfLines,
selectable,
}: {
testID?: string
type?: TypographyVariant
@@ -24,6 +25,7 @@ export function RichText({
lineHeight?: number
style?: StyleProp<TextStyle>
numberOfLines?: number
selectable?: boolean
}) {
const theme = useTheme()
const pal = usePalette('default')
@@ -54,7 +56,8 @@ export function RichText({
style={[style, pal.text, lineHeightStyle]}
numberOfLines={numberOfLines}
// @ts-ignore web only -prf
dataSet={WORD_WRAP}>
dataSet={WORD_WRAP}
selectable={selectable}>
{text}
</Text>
)
+24 -1
View File
@@ -1,13 +1,17 @@
import React from 'react'
import {Text as RNText, TextProps} from 'react-native'
import {StyleSheet, Text as RNText, TextProps} from 'react-native'
import {s, lh} from 'lib/styles'
import {useTheme, TypographyVariant} from 'lib/ThemeContext'
import {SelectableText} from '../../../../../modules/expo-selectable-text'
import {isIOS} from 'platform/detection'
import {fontSize} from '#/alf/tokens'
export type CustomTextProps = TextProps & {
type?: TypographyVariant
lineHeight?: number
title?: string
dataSet?: Record<string, string | number>
selectable?: boolean
}
export function Text({
@@ -17,11 +21,30 @@ export function Text({
style,
title,
dataSet,
selectable,
...props
}: React.PropsWithChildren<CustomTextProps>) {
const theme = useTheme()
const typography = theme.typography[type]
const lineHeightStyle = lineHeight ? lh(theme, type, lineHeight) : undefined
// {"color":"#000000","fontSize":20,"letterSpacing":0.2,"fontWeight":"400","flex":1,"lineHeight":26}
if (selectable && isIOS) {
return (
<SelectableText
selectable
style={StyleSheet.flatten([
s.black,
typography,
lineHeightStyle,
style,
])}>
{children}
</SelectableText>
)
}
return (
<RNText
style={[s.black, typography, lineHeightStyle, style]}