improvements to Text

This commit is contained in:
Hailey
2024-11-09 15:22:48 -08:00
parent 3aeee1e4aa
commit 9f5661bfb1
+27 -30
View File
@@ -60,7 +60,7 @@ export function Text({
} }
} }
if (selectable && isIOS) { const textProps = React.useMemo(() => {
const flattened = StyleSheet.flatten([ const flattened = StyleSheet.flatten([
s.black, s.black,
typography, typography,
@@ -74,49 +74,46 @@ export function Text({
// @ts-ignore // @ts-ignore
if (flattened.fontSize) { if (flattened.fontSize) {
// @ts-ignore // @ts-ignore
flattened.fontSize = flattened.fontSize * fonts.scaleMultiplier flattened.fontSize = Math.round(
// @ts-ignore
flattened.fontSize * fonts.scaleMultiplier,
)
} }
const shared = { const shared = {
uiTextView: true, uiTextView: selectable && isIOS,
selectable, selectable,
style: flattened, style: flattened,
dataSet: Object.assign({tooltip: title}, dataSet || {}),
...props, ...props,
} }
return shared
}, [
dataSet,
fonts.family,
fonts.scaleMultiplier,
lineHeightStyle,
props,
selectable,
style,
title,
typography,
])
if (selectable && isIOS) {
return ( return (
<UITextView {...shared}> <UITextView {...textProps}>
{isIOS && emoji ? renderChildrenWithEmoji(children, shared) : children} {isIOS && emoji
? renderChildrenWithEmoji(children, textProps)
: children}
</UITextView> </UITextView>
) )
} }
const flattened = StyleSheet.flatten([
s.black,
typography,
lineHeightStyle,
style,
])
applyFonts(flattened, fonts.family)
// should always be defined on `typography`
// @ts-ignore
if (flattened.fontSize) {
// @ts-ignore
flattened.fontSize = flattened.fontSize * fonts.scaleMultiplier
}
const shared = {
selectable,
style: flattened,
dataSet: Object.assign({tooltip: title}, dataSet || {}),
...props,
}
return ( return (
<RNText {...shared}> <RNText {...textProps}>
{isIOS && emoji ? renderChildrenWithEmoji(children, shared) : children} {isIOS && emoji ? renderChildrenWithEmoji(children, textProps) : children}
</RNText> </RNText>
) )
} }