From 58e6ff9ccf9489f4f480fe012467f44ecd3aa385 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Sun, 15 Sep 2024 12:48:13 -0500 Subject: [PATCH] Apply to old Text component --- src/view/com/util/text/Text.tsx | 51 +++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/src/view/com/util/text/Text.tsx b/src/view/com/util/text/Text.tsx index 2ea9586eed..2a6a4c6e85 100644 --- a/src/view/com/util/text/Text.tsx +++ b/src/view/com/util/text/Text.tsx @@ -1,10 +1,11 @@ import React from 'react' -import {Text as RNText, TextProps} from 'react-native' +import {StyleSheet, Text as RNText, TextProps} from 'react-native' import {UITextView} from 'react-native-uitextview' import {lh, s} from 'lib/styles' import {TypographyVariant, useTheme} from 'lib/ThemeContext' import {isIOS, isWeb} from 'platform/detection' +import {applyFonts, useAlf} from '#/alf' export type CustomTextProps = TextProps & { type?: TypographyVariant @@ -32,11 +33,30 @@ export function Text({ const theme = useTheme() const typography = theme.typography[type] const lineHeightStyle = lineHeight ? lh(theme, type, lineHeight) : undefined + const {fonts, flags} = useAlf() if (selectable && isIOS) { + const flattened = StyleSheet.flatten([ + s.black, + typography, + lineHeightStyle, + style, + ]) + + if (flags.neue && fonts.family === 'theme') { + applyFonts(flattened) + } + + // should always be defined on `typography` + // @ts-ignore + if (flattened.fontSize) { + // @ts-ignore + flattened.fontSize = flattened.fontSize * fonts.scale + } + return ( @@ -45,15 +65,28 @@ export function Text({ ) } + const flattened = StyleSheet.flatten([ + s.black, + typography, + isWeb && fontFamilyStyle, + lineHeightStyle, + style, + ]) + + if (flags.neue && fonts.family === 'theme') { + applyFonts(flattened) + } + + // should always be defined on `typography` + // @ts-ignore + if (flattened.fontSize) { + // @ts-ignore + flattened.fontSize = flattened.fontSize * fonts.scale + } + return (