From 9f5661bfb13438785d4a7f3f41bf8a4ff41245e5 Mon Sep 17 00:00:00 2001 From: Hailey Date: Sat, 9 Nov 2024 15:22:48 -0800 Subject: [PATCH] improvements to Text --- src/view/com/util/text/Text.tsx | 57 ++++++++++++++++----------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/src/view/com/util/text/Text.tsx b/src/view/com/util/text/Text.tsx index 42ea79b8fb..e16003507d 100644 --- a/src/view/com/util/text/Text.tsx +++ b/src/view/com/util/text/Text.tsx @@ -60,7 +60,7 @@ export function Text({ } } - if (selectable && isIOS) { + const textProps = React.useMemo(() => { const flattened = StyleSheet.flatten([ s.black, typography, @@ -74,49 +74,46 @@ export function Text({ // @ts-ignore if (flattened.fontSize) { // @ts-ignore - flattened.fontSize = flattened.fontSize * fonts.scaleMultiplier + flattened.fontSize = Math.round( + // @ts-ignore + flattened.fontSize * fonts.scaleMultiplier, + ) } const shared = { - uiTextView: true, + uiTextView: selectable && isIOS, selectable, style: flattened, + dataSet: Object.assign({tooltip: title}, dataSet || {}), ...props, } + return shared + }, [ + dataSet, + fonts.family, + fonts.scaleMultiplier, + lineHeightStyle, + props, + selectable, + style, + title, + typography, + ]) + + if (selectable && isIOS) { return ( - - {isIOS && emoji ? renderChildrenWithEmoji(children, shared) : children} + + {isIOS && emoji + ? renderChildrenWithEmoji(children, textProps) + : children} ) } - 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 ( - - {isIOS && emoji ? renderChildrenWithEmoji(children, shared) : children} + + {isIOS && emoji ? renderChildrenWithEmoji(children, textProps) : children} ) }