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}