From 4604550c1043e5b706168047663c7979c0e1a541 Mon Sep 17 00:00:00 2001 From: peachbits Date: Tue, 17 Nov 2026 23:29:08 -0800 Subject: [PATCH] Sync EdgeText's shrink floor with edge-login-ui-rn edge-login-ui-rn ported EdgeText's minimumFontSize floor and its review reworked it. Bring those changes back so the two copies match again: - Export DEFAULT_MINIMUM_FONT_SCALE (0.65) instead of repeating 0.65. - Only compute the floor when the text is allowed to shrink. Text with shrinking off no longer carries a minimumFontSize it never uses. - Default UnscaledText's minimumFontScale to 0.65, and floor it whenever it shrinks. The fallback symbols in FiatIcon and CryptoIcon shrank with no floor before, so down to React Native's 4pt/4dp. - Document the 4pt (iOS) and 4dp (Android) defaults, how Android floors nested text runs, and that React Native 0.89 makes this unnecessary. Snapshots gain minimumFontScale on UnscaledText and drop minimumFontSize where shrinking is off. --- CHANGELOG.md | 1 + .../__snapshots__/BalanceCard.test.tsx.snap | 38 +++++++++++++++ .../FilledTextInput.test.tsx.snap | 2 + .../LargeUtxoWalletCard.test.tsx.snap | 1 - .../AccelerateTxModal.test.tsx.snap | 1 - .../AirshipFullScreenSpinner.test.tsx.snap | 1 + .../__snapshots__/DateModal.test.tsx.snap | 1 + .../__snapshots__/HelpModal.test.tsx.snap | 1 + .../__snapshots__/LogsModal.test.tsx.snap | 2 + .../WalletListModal.test.tsx.snap | 1 + .../WalletListSortModal.test.tsx.snap | 6 +++ ...reateWalletAccountSetupScene.test.tsx.snap | 2 + .../CurrencyNotificationScene.test.tsx.snap | 2 + .../CurrencySettings.ui.test.tsx.snap | 9 ++++ .../FioAddressDetailsScene.test.tsx.snap | 1 + ...essRegisterSelectWalletScene.test.tsx.snap | 2 + .../FioAddressRegisteredScene.test.tsx.snap | 2 + .../__snapshots__/SendScene2.ui.test.tsx.snap | 10 +--- .../__snapshots__/SettingsScene.test.tsx.snap | 28 +++++++++++ .../SwapConfirmationScene.test.tsx.snap | 1 - .../SwapCreateScene.test.tsx.snap | 1 + src/components/text/UnscaledText.tsx | 33 +++++++++---- src/components/themed/EdgeText.tsx | 47 ++++++++++++++----- 23 files changed, 160 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27fda44edea..86f06c832a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased (develop) +- changed: Shrink-to-fit text that sets no minimum scale, such as the fallback symbols in fiat and crypto icons, now stops shrinking at 65% of its size, matching edge-login-ui-rn - added: Swap success events name the swap mode, including Swap & Send from the send scene - fixed: Android crash when opening DFX and other web pages on some Android 12+ phones, where the blurred header and tab bar redrew the page - fixed: DFX shows an error instead of opening when it blocks the country of the user's internet connection, for Bitcoin and EVM wallets, which Edge logs in to DFX diff --git a/src/__tests__/components/__snapshots__/BalanceCard.test.tsx.snap b/src/__tests__/components/__snapshots__/BalanceCard.test.tsx.snap index f19e9a1c31d..447e450d54e 100644 --- a/src/__tests__/components/__snapshots__/BalanceCard.test.tsx.snap +++ b/src/__tests__/components/__snapshots__/BalanceCard.test.tsx.snap @@ -40,6 +40,7 @@ exports[`BalanceCard should render with loading props 1`] = ` /> = props => { - const { adjustsFontSizeToFit = false, minimumFontScale, style } = props - // Give the new architecture the shrink floor it otherwise ignores: - const floor = - adjustsFontSizeToFit && minimumFontScale != null - ? minimumFontSizeProps(style, minimumFontScale, 14) - : {} - return + const { + adjustsFontSizeToFit = false, + minimumFontScale = DEFAULT_MINIMUM_FONT_SCALE, + style + } = props + // Fabric ignores `minimumFontScale`, so also pass it as an absolute + // `minimumFontSize` floor (see `patches/react-native+0.86.0.patch`): + const floorProps = adjustsFontSizeToFit + ? minimumFontSizeProps(style, minimumFontScale, RN_DEFAULT_FONT_SIZE) + : null + return ( + + ) } diff --git a/src/components/themed/EdgeText.tsx b/src/components/themed/EdgeText.tsx index db28b3e8adf..c7b5ab0b220 100644 --- a/src/components/themed/EdgeText.tsx +++ b/src/components/themed/EdgeText.tsx @@ -66,11 +66,20 @@ export const Paragraph: React.FC = (props: ParagraphProps) => { /** * The new architecture ignores `minimumFontScale` when it shrinks text to fit: - * both platforms floor at an absolute `minimumFontSize` (4pt when unset) and - * render long labels illegibly small. React Native's Text never forwards that - * prop, so `patches/react-native+0.86.0.patch` adds it to the RCTText view - * config and this derives it from the style's font size, in points on iOS and - * in pixels on Android (its shrink loop compares against a pixel text size). + * both platforms floor at an absolute `minimumFontSize` (4pt on iOS and 4dp on + * Android when unset) and render long labels illegibly small. React Native's + * Text never forwards that prop, so `patches/react-native+0.86.0.patch` adds it + * to the RCTText view config and this derives it from the style's font size, + * in points on iOS and in pixels on Android (its shrink loop compares against + * a pixel text size). + * + * The floor is an absolute size, and Android applies it to every nested text + * run, so nested text smaller than `fontSize × minimumFontScale` is enlarged + * to it, and nested text a little smaller than the outer text can shrink less + * than `minimumFontScale` allows. + * + * Remove this, and the patch, once React Native forwards `minimumFontScale` on + * the new architecture (fixed upstream for 0.89). */ export function minimumFontSizeProps( style: StyleProp, @@ -88,6 +97,9 @@ export function minimumFontSizeProps( return props as TextProps } +/** How far shrink-to-fit text may shrink when the caller doesn't say. */ +export const DEFAULT_MINIMUM_FONT_SCALE = 0.65 + interface LabelProps extends TextProps { children: React.ReactNode ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip' @@ -102,7 +114,14 @@ interface LabelProps extends TextProps { // TODO: Rename to LabelText export const EdgeText: React.FC = (props: LabelProps) => { - const { children, style, disableFontScaling = false, ...rest } = props + const { + children, + style, + disableFontScaling = false, + adjustsFontSizeToFit = !disableFontScaling, + minimumFontScale = DEFAULT_MINIMUM_FONT_SCALE, + ...rest + } = props const theme = useTheme() const styles = getStyles(theme) @@ -116,14 +135,16 @@ export const EdgeText: React.FC = (props: LabelProps) => { allowFontScaling={false} style={[styles.common, style, androidAdjustTextStyle(theme)]} numberOfLines={numberOfLines} - adjustsFontSizeToFit={!disableFontScaling} - minimumFontScale={0.65} + adjustsFontSizeToFit={adjustsFontSizeToFit} + minimumFontScale={minimumFontScale} {...rest} - {...minimumFontSizeProps( - [styles.common, style], - rest.minimumFontScale ?? 0.65, - theme.rem(1) - )} + {...(adjustsFontSizeToFit + ? minimumFontSizeProps( + [styles.common, style], + minimumFontScale, + theme.rem(1) + ) + : null)} > {children}