render TextInput if text should be selectable

This commit is contained in:
Ansh Nanda
2023-04-11 13:43:32 -07:00
parent 14c8473210
commit d59d701e79
3 changed files with 18 additions and 1 deletions
+13 -1
View File
@@ -1,5 +1,5 @@
import React from 'react'
import {Text as RNText, TextProps} from 'react-native'
import {Text as RNText, TextInput, TextProps} from 'react-native'
import {s, lh} from 'lib/styles'
import {useTheme, TypographyVariant} from 'lib/ThemeContext'
@@ -13,11 +13,23 @@ export function Text({
children,
lineHeight,
style,
selectable,
...props
}: React.PropsWithChildren<CustomTextProps>) {
const theme = useTheme()
const typography = theme.typography[type]
const lineHeightStyle = lineHeight ? lh(theme, type, lineHeight) : undefined
if (selectable) {
return (
<TextInput
value={children as string}
scrollEnabled={false}
style={[s.black, typography, lineHeightStyle, style]}
editable={false}
multiline={true}
/>
)
}
return (
<RNText style={[s.black, typography, lineHeightStyle, style]} {...props}>
{children}