Skip to content
TypeScript

fix(mobile): scale Android controls with appearance text size (#13356)

Nick Anisimov7a12aff471ff
diff --git a/apps/mobile/src/components/AndroidAnchoredMenu.tsx b/apps/mobile/src/components/AndroidAnchoredMenu.tsx
index dfa0dea8d05..4c465a9f9ef 100644
--- a/apps/mobile/src/components/AndroidAnchoredMenu.tsx
+++ b/apps/mobile/src/components/AndroidAnchoredMenu.tsx
@@ -7,9 +7,9 @@ import { useKeyboardState } from "react-native-keyboard-controller";
import Animated, { FadeIn } from "react-native-reanimated";
import { OverlayPortal } from "./OverlayPortal";
+import { useAndroidControlSizing } from "./useAndroidControlSizing";
import { MaterialMenuPopup } from "./MaterialMenuPopup";
-const MENU_WIDTH = 250;
const SCREEN_MARGIN = 12;
const ANCHOR_GAP = 6;
@@ -55,6 +55,7 @@ export type AndroidAnchoredMenuProps = {
* menus use the native popup for placement, animation and dismissal.
*/
export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
+ const { scale, menuWidth: desiredMenuWidth } = useAndroidControlSizing();
const [anchor, setAnchor] = useState<AnchorSnapshot | null>(null);
const [path, setPath] = useState<readonly MenuAction[]>([]);
// Height of the modal's root view, in the modal's own coordinate space.
@@ -68,6 +69,10 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
// are converted into this frame, so the menu lands correctly no matter
// where the portal host sits (status bar, keyboard resize, etc.).
const [overlay, setOverlay] = useState<OverlayFrame | null>(null);
+ const menuWidth =
+ overlay === null
+ ? desiredMenuWidth
+ : Math.min(desiredMenuWidth, Math.max(0, overlay.width - 2 * SCREEN_MARGIN));
const anchorRef = useRef<View>(null);
const overlayRef = useRef<View>(null);
@@ -131,14 +136,11 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
? 0
: local.x + local.width / 2 <= overlay.width / 2
? local.x
- : local.x + local.width - MENU_WIDTH;
+ : local.x + local.width - menuWidth;
const left =
overlay === null
? 0
- : Math.min(
- Math.max(preferredLeft, SCREEN_MARGIN),
- overlay.width - MENU_WIDTH - SCREEN_MARGIN,
- );
+ : Math.min(Math.max(preferredLeft, SCREEN_MARGIN), overlay.width - menuWidth - SCREEN_MARGIN);
// The keyboard stays up while the menu is open (in-window overlay, no
// focus change), so the space it covers is not usable — without this the
// composer-pill menus "open down" into the IME and can't be tapped.
@@ -201,6 +203,7 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
{!placeable || local === null ? null : !anchor.keyboardWasVisible ? (
<MaterialMenuPopup
anchor={local}
+ menuWidth={menuWidth}
actions={levelActions}
title={props.title}
parent={parent}
@@ -211,10 +214,12 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
) : (
<Animated.View
entering={FadeIn.duration(120)}
- className="absolute w-[250px] overflow-hidden rounded-[4px] bg-card-alt shadow-md"
+ className="absolute overflow-hidden bg-card-alt shadow-md"
style={{
left,
maxHeight,
+ width: menuWidth,
+ borderRadius: 4 * scale,
...(opensDown
? { top: local.y + local.height + ANCHOR_GAP }
: { bottom: (rootHeight ?? 0) - local.y + ANCHOR_GAP }),
@@ -227,7 +232,7 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
active editor; the first item tap must act, not just
dismiss the keyboard. */}
<ScrollView
- contentContainerClassName="py-2"
+ contentContainerStyle={{ paddingVertical: 7 * scale }}
bounces={false}
keyboardShouldPersistTaps="always"
showsVerticalScrollIndicator={false}
@@ -235,6 +240,7 @@ export function AndroidAnchoredMenu(props: AndroidAnchoredMenuProps) {
<MaterialMenuPopup
inline
anchor={local}
+ menuWidth={menuWidth}
actions={levelActions}
title={props.title}
parent={parent}
diff --git a/apps/mobile/src/components/AndroidScreenHeader.tsx b/apps/mobile/src/components/AndroidScreenHeader.tsx
index 6e2095009b3..a8841f39061 100644
--- a/apps/mobile/src/components/AndroidScreenHeader.tsx
+++ b/apps/mobile/src/components/AndroidScreenHeader.tsx
@@ -1,6 +1,5 @@
import { useState, type ReactNode } from "react";
import { View } from "react-native";
-import { useSafeAreaInsets } from "react-native-safe-area-context";
import type { AppSymbolName } from "./AppSymbol";
import { AppText as Text } from "./AppText";
@@ -8,7 +7,7 @@ import { cn } from "../lib/cn";
import { MaterialIconButton } from "./MaterialIconButton";
import { AndroidAnchoredMenu } from "./AndroidAnchoredMenu";
import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
-import { useMaterialToolbarHeight } from "./useMaterialToolbarHeight";
+import { useMaterialToolbarLayout } from "./useMaterialToolbarLayout";
export interface AndroidHeaderAction {
readonly accessibilityLabel: string;
@@ -38,10 +37,11 @@ export function AndroidScreenHeader(props: {
readonly embedded?: boolean;
readonly hideBottomBorder?: boolean;
}) {
- const insets = useSafeAreaInsets();
const titleTypography = useScaledTextRole("title");
const subtitleTypography = useScaledTextRole("label");
- const materialToolbarHeight = useMaterialToolbarHeight();
+ const { height: materialToolbarHeight, ...headerPadding } = useMaterialToolbarLayout(
+ props.embedded,
+ );
const [headerWidth, setHeaderWidth] = useState(0);
const actions = props.actions ?? [];
const directCount = actions.length > 2 ? (headerWidth >= 600 ? 3 : 1) : actions.length;
@@ -51,16 +51,13 @@ export function AndroidScreenHeader(props: {
return (
<View
onLayout={(event) => setHeaderWidth(event.nativeEvent.layout.width)}
- className="border-b border-header-border bg-header px-2 pb-2"
+ className="border-b border-header-border bg-header px-2"
style={{
- paddingTop: props.embedded ? 8 : Math.max(insets.top, 12),
+ ...headerPadding,
borderBottomWidth: props.hideBottomBorder ? 0 : undefined,
}}
>
- <View
- style={{ minHeight: materialToolbarHeight }}
- className="min-h-14 flex-row items-center gap-1"
- >
+ <View style={{ minHeight: materialToolbarHeight }} className="flex-row items-center gap-1">
{props.onBack ? (
<MaterialIconButton
accessibilityLabel="Navigate up"
diff --git a/apps/mobile/src/components/CompactBrandTitle.tsx b/apps/mobile/src/components/CompactBrandTitle.tsx
index a6e2a7fd212..f64370c3cea 100644
--- a/apps/mobile/src/components/CompactBrandTitle.tsx
+++ b/apps/mobile/src/components/CompactBrandTitle.tsx
@@ -6,6 +6,7 @@ import { AppText as Text } from "./AppText";
import { T3Wordmark } from "./T3Wordmark";
import { IPAD_HOME_TITLE_OFFSET } from "../lib/layoutMetrics";
import { resolveMobileStageLabel } from "../lib/mobileBranding";
+import { useAndroidControlSizing } from "./useAndroidControlSizing";
/**
* Horizontal correction applied to content rendered in the brand title slot,
@@ -26,6 +27,7 @@ export function CompactBrandTitle(
) {
const stageLabel = resolveMobileStageLabel(Constants.expoConfig?.extra?.appVariant);
const titleOffset = brandTitleOffset();
+ const { scale } = useAndroidControlSizing();
return (
<View
@@ -34,19 +36,28 @@ export function CompactBrandTitle(
accessible
role="heading"
className="flex-row items-center gap-1.5"
- style={{ marginLeft: titleOffset }}
+ style={[{ marginLeft: titleOffset }, Platform.OS === "android" && { gap: 5.25 * scale }]}
>
- <T3Wordmark colorClassName="accent-icon" height={15} />
+ <T3Wordmark colorClassName="accent-icon" height={Math.round(15 * scale)} />
<Text
allowFontScaling={props.allowFontScaling}
- className="font-t3-medium text-[21px] tracking-[-0.5px] text-foreground-muted"
+ className="font-t3-medium text-foreground-muted"
+ style={{ fontSize: 21 * scale, letterSpacing: -0.5 * scale }}
>
Code
</Text>
- <View className="rounded-full bg-subtle px-1.5 py-0.5">
+ <View
+ className="rounded-full bg-subtle px-1.5 py-0.5"
+ style={
+ Platform.OS === "android"
+ ? { paddingHorizontal: 5.25 * scale, paddingVertical: 1.75 * scale }
+ : undefined
+ }
+ >
<Text
allowFontScaling={props.allowFontScaling}
- className="font-t3-bold text-[9px] tracking-[0.9px] text-foreground-muted uppercase"
+ className="font-t3-bold text-foreground-muted uppercase"
+ style={{ fontSize: 9 * scale, letterSpacing: 0.9 * scale }}
>
{stageLabel}
</Text>
diff --git a/apps/mobile/src/components/ComposerAttachmentButton.tsx b/apps/mobile/src/components/ComposerAttachmentButton.tsx
index 8ea70a45c02..b6b3d6e78a4 100644
--- a/apps/mobile/src/components/ComposerAttachmentButton.tsx
+++ b/apps/mobile/src/components/ComposerAttachmentButton.tsx
@@ -1,6 +1,7 @@
import type { MenuAction } from "@react-native-menu/menu";
import { Pressable } from "react-native";
+import { useAndroidControlSizing } from "./useAndroidControlSizing";
import { SymbolView } from "./AppSymbol";
import { ControlPillMenu } from "./ControlPill";
@@ -15,6 +16,7 @@ export function ComposerAttachmentButton(props: {
readonly onPickMedia: () => Promise<void>;
readonly onPickFiles: () => Promise<void>;
}) {
+ const { scale } = useAndroidControlSizing();
const button = (
<Pressable
accessibilityLabel="Add attachment"
@@ -26,7 +28,7 @@ export function ComposerAttachmentButton(props: {
>
<SymbolView
name="plus"
- size={20}
+ size={Math.round(20 * scale)}
weight="regular"
tintColorClassName="accent-icon"
type="monochrome"
diff --git a/apps/mobile/src/components/ComposerToolbar.tsx b/apps/mobile/src/components/ComposerToolbar.tsx
index 50fbcd253a4..f8a8fb7b66d 100644
--- a/apps/mobile/src/components/ComposerToolbar.tsx
+++ b/apps/mobile/src/components/ComposerToolbar.tsx
@@ -1,6 +1,7 @@
import type { ComponentProps, ReactNode } from "react";
import { useCallback, useMemo, useState } from "react";
import {
+ Platform,
Pressable,
ScrollView,
View,
@@ -14,6 +15,7 @@ import {
import { cn } from "../lib/cn";
import { AppText as Text } from "./AppText";
import { SymbolView } from "./AppSymbol";
+import { useAndroidControlSizing } from "./useAndroidControlSizing";
const COMPOSER_TOOLBAR_GAP = 8;
const COMPOSER_TOOLBAR_FADE_WIDTH = 18;
@@ -30,7 +32,7 @@ export function ComposerInlineControl(props: {
readonly disabled?: boolean;
readonly emphasized?: boolean;
readonly icon?: ComponentProps<typeof SymbolView>["name"];
- readonly iconNode?: ReactNode;
+ readonly renderIcon?: (size: number) => ReactNode;
readonly label: string;
readonly maxWidth?: ViewStyle["maxWidth"];
readonly onPress?: () => void;
@@ -39,6 +41,7 @@ export function ComposerInlineControl(props: {
readonly chevronDirection?: "down" | "right";
readonly showChevron?: boolean;
}) {
+ const { scale, smallIconSize } = useAndroidControlSizing();
return (
<Pressable
accessibilityLabel={props.accessibilityLabel ?? props.label}
@@ -52,12 +55,17 @@ export function ComposerInlineControl(props: {
onPress={props.onPress}
style={{ maxWidth: props.maxWidth ?? 190, opacity: props.disabled ? 0.45 : 1 }}
>
- {props.iconNode ? (
- <View className="size-4 shrink-0 items-center justify-center">{props.iconNode}</View>
+ {props.renderIcon ? (
+ <View
+ className="size-4 shrink-0 items-center justify-center"
+ style={Platform.OS === "android" ? { width: 14 * scale, height: 14 * scale } : undefined}
+ >
+ {props.renderIcon(smallIconSize)}
+ </View>
) : props.icon ? (
<SymbolView
name={props.icon}
- size={16}
+ size={smallIconSize}
tintColorClassName={
props.emphasized || props.selected ? "accent-icon" : "accent-icon-muted"
}
@@ -76,7 +84,7 @@ export function ComposerInlineControl(props: {
{props.showChevron === false ? null : (
<SymbolView
name={props.chevronDirection === "right" ? "chevron.right" : "chevron.down"}
- size={10}
+ size={Math.round(10 * scale)}
tintColorClassName={
props.emphasized || props.selected ? "accent-icon" : "accent-icon-muted"
}
@@ -224,6 +232,8 @@ export function ComposerActionButton(props: {
readonly onPress: () => void;
readonly variant?: "primary" | "danger";
}) {
+ const { scale, smallIconSize } = useAndroidControlSizing();
+ const circleSize = Math.round(30 * scale);
return (
<Pressable
accessibilityLabel={props.accessibilityLabel}
@@ -234,8 +244,9 @@ export function ComposerActionButton(props: {
onPress={props.onPress}
>
<View
+ style={{ width: circleSize, height: circleSize }}
className={cn(
- "size-[30px] items-center justify-center rounded-full",
+ "items-center justify-center rounded-full",
props.variant === "danger"
? "bg-danger"
: props.disabled
@@ -245,7 +256,7 @@ export function ComposerActionButton(props: {
>
<SymbolView
name={props.icon}
- size={16}
+ size={smallIconSize}
weight="semibold"
tintColorClassName={
props.variant === "danger" ? "accent-danger-foreground" : "accent-primary-foreground"
diff --git a/apps/mobile/src/components/ControlPill.tsx b/apps/mobile/src/components/ControlPill.tsx
index d8217ab67df..95a8feb10a2 100644
--- a/apps/mobile/src/components/ControlPill.tsx
+++ b/apps/mobile/src/components/ControlPill.tsx
@@ -5,6 +5,7 @@ import { SymbolView } from "./AppSymbol";
import { AppText as Text } from "./AppText";
import { MaterialIconButton } from "./MaterialIconButton";
import { MaterialButton } from "./MaterialButton";
+import { useAndroidControlSizing } from "./useAndroidControlSizing";
export { ControlPillMenu } from "./ControlPillMenu";
@@ -20,6 +21,7 @@ export function ControlPill(props: {
readonly className?: string;
}) {
const variant = props.variant ?? "circle";
+ const { smallIconSize } = useAndroidControlSizing();
const activatedOnPressInRef = useRef(false);
const handlePressIn = () => {
@@ -133,7 +135,7 @@ export function ControlPill(props: {
) : props.icon ? (
<SymbolView
name={props.icon}
- size={16}
+ size={smallIconSize}
tintColorClassName={iconTintClassName}
type="monochrome"
/>
diff --git a/apps/mobile/src/components/MaterialButton.android.tsx b/apps/mobile/src/components/MaterialButton.android.tsx
index f2df6464f10..f7a62f1ecb0 100644
--- a/apps/mobile/src/components/MaterialButton.android.tsx
+++ b/apps/mobile/src/components/MaterialButton.android.tsx
@@ -14,10 +14,12 @@ import { View } from "react-native";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
import type { MaterialButtonProps } from "./MaterialButton";
+import { useAndroidControlSizing } from "./useAndroidControlSizing";
export function MaterialButton(props: MaterialButtonProps) {
const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
const typography = useScaledTextRole("footnote");
+ const { scale, mediumIconSize } = useAndroidControlSizing();
const tone = props.tone ?? "secondary";
const Component =
tone === "text" ? TextButton : tone === "secondary" ? FilledTonalButton : Button;
@@ -77,11 +79,11 @@ export function MaterialButton(props: MaterialButtonProps) {
{props.loading ? (
<>
<CircularProgressIndicator
- modifiers={[size(18, 18)]}
+ modifiers={[size(mediumIconSize, mediumIconSize)]}
strokeWidth={2}
color={colors["--color-foreground-muted"]}
/>
- <Box modifiers={[size(8, 1)]} />
+ <Box modifiers={[size(8 * scale, 1)]} />
</>
) : null}
<Text style={{ ...typography, fontWeight: "500" }}>{props.label}</Text>
diff --git a/apps/mobile/src/components/MaterialFloatingActionButton.android.tsx b/apps/mobile/src/components/MaterialFloatingActionButton.android.tsx
index 2882d0d91ec..29f396fc9d6 100644
--- a/apps/mobile/src/components/MaterialFloatingActionButton.android.tsx
+++ b/apps/mobile/src/components/MaterialFloatingActionButton.android.tsx
@@ -6,8 +6,9 @@ import {
LargeFloatingActionButton,
Text,
} from "@expo/ui/jetpack-compose";
-import { size } from "@expo/ui/jetpack-compose/modifiers";
+import { defaultMinSize, height, size, width } from "@expo/ui/jetpack-compose/modifiers";
import { View, type StyleProp, type ViewStyle } from "react-native";
+import { useAndroidControlSizing } from "./useAndroidControlSizing";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
import { SymbolView, type AppSymbolName } from "./AppSymbol";
@@ -24,6 +25,8 @@ export function MaterialFloatingActionButton(props: {
}) {
const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
const typography = useScaledTextRole("footnote");
+ const { scale, iconSize: standardIconSize, fabSize, largeFabSize } = useAndroidControlSizing();
+ const buttonSize = props.variant === "large" ? largeFabSize : fabSize;
const primary = props.tone === "primary";
const containerColor = colors[primary ? "--color-primary" : "--color-secondary"];
const contentColor =
@@ -34,7 +37,7 @@ export function MaterialFloatingActionButton(props: {
: props.variant === "large"
? LargeFloatingActionButton
: FloatingActionButton;
- const iconSize = props.variant === "large" ? 36 : 24;
+ const iconSize = props.variant === "large" ? Math.round(36 * scale) : standardIconSize;
return (
<View
accessible
@@ -48,6 +51,11 @@ export function MaterialFloatingActionButton(props: {
<View importantForAccessibility="no-hide-descendants">
<Host matchContents colorScheme={themeAppearance} ignoreSafeAreaKeyboardInsets>
<Component
+ modifiers={[
+ defaultMinSize({ minWidth: buttonSize }),
+ height(buttonSize),
+ ...(props.variant === "extended" ? [] : [width(buttonSize)]),
+ ]}
containerColor={containerColor}
onClick={props.onPress}
expanded={props.expanded}
diff --git a/apps/mobile/src/components/MaterialIconButton.android.tsx b/apps/mobile/src/components/MaterialIconButton.android.tsx
index 21284249f79..64387e3a4f4 100644
--- a/apps/mobile/src/components/MaterialIconButton.android.tsx
+++ b/apps/mobile/src/components/MaterialIconButton.android.tsx
@@ -8,6 +8,7 @@ import { size } from "@expo/ui/jetpack-compose/modifiers";
import { View } from "react-native";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
+import { useAndroidControlSizing } from "./useAndroidControlSizing";
import { SymbolView, type AppSymbolName } from "./AppSymbol";
export function MaterialIconButton(props: {
@@ -20,6 +21,7 @@ export function MaterialIconButton(props: {
readonly tintColorClassName?: string;
}) {
const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
+ const { iconSize, buttonSize } = useAndroidControlSizing();
const variant = props.variant ?? "standard";
const Component =
variant === "standard"
@@ -52,18 +54,18 @@ export function MaterialIconButton(props: {
onAccessibilityAction={() => {
if (!props.disabled) props.onPress?.();
}}
- style={{ width: 48, height: 48 }}
+ style={{ width: buttonSize, height: buttonSize }}
>
<View importantForAccessibility="no-hide-descendants">
<Host
colorScheme={themeAppearance}
ignoreSafeAreaKeyboardInsets
- style={{ width: 48, height: 48 }}
+ style={{ width: buttonSize, height: buttonSize }}
>
<Component
onClick={props.onPress}
enabled={!props.disabled}
- modifiers={[size(48, 48)]}
+ modifiers={[size(buttonSize, buttonSize)]}
colors={
variant === "standard"
? undefined
@@ -78,7 +80,7 @@ export function MaterialIconButton(props: {
<View pointerEvents="none" className="absolute inset-0 items-center justify-center">
<SymbolView
name={props.icon === "ellipsis" ? { ios: "ellipsis", android: "more_vert" } : props.icon}
- size={24}
+ size={iconSize}
tintColorClassName={iconTint}
type="monochrome"
/>
diff --git a/apps/mobile/src/components/MaterialListRow.tsx b/apps/mobile/src/components/MaterialListRow.tsx
index 539472e4bd9..cef104a02f5 100644
--- a/apps/mobile/src/components/MaterialListRow.tsx
+++ b/apps/mobile/src/components/MaterialListRow.tsx
@@ -5,6 +5,7 @@ import { useAppearancePreferences } from "../features/settings/appearance/Appear
import { cn } from "../lib/cn";
import { AppText } from "./AppText";
import { SymbolView } from "./AppSymbol";
+import { useAndroidControlSizing } from "./useAndroidControlSizing";
/** Shared geometry for Material navigation and selection lists. Group rows in one card. */
export function MaterialListRow({
@@ -23,6 +24,7 @@ export function MaterialListRow({
readonly trailing?: ReactNode;
}) {
const { themeVariables } = useAppearancePreferences();
+ const { smallIconSize } = useAndroidControlSizing();
return (
<Pressable
accessibilityRole="button"
@@ -52,7 +54,7 @@ export function MaterialListRow({
{trailing !== undefined ? (
trailing
) : !props.disabled ? (
- <SymbolView name="chevron.right" size={16} tintColorClassName="accent-chevron" />
+ <SymbolView name="chevron.right" size={smallIconSize} tintColorClassName="accent-chevron" />
) : null}
</Pressable>
);
diff --git a/apps/mobile/src/components/MaterialMenuPopup.android.tsx b/apps/mobile/src/components/MaterialMenuPopup.android.tsx
index c49db181503..4f9fe3d1ada 100644
--- a/apps/mobile/src/components/MaterialMenuPopup.android.tsx
+++ b/apps/mobile/src/components/MaterialMenuPopup.android.tsx
@@ -7,9 +7,11 @@ import {
RNHostView,
Text,
} from "@expo/ui/jetpack-compose";
-import { padding, size, width } from "@expo/ui/jetpack-compose/modifiers";
+import { defaultMinSize, padding, size, width } from "@expo/ui/jetpack-compose/modifiers";
import { View } from "react-native";
+import { resolveScaledTextRole } from "../lib/appearancePreferences";
+import { useAndroidControlSizing } from "./useAndroidControlSizing";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import type { MaterialMenuPopupProps } from "./MaterialMenuPopup";
import { isAppSymbolName, SymbolView, type AppSymbolName } from "./AppSymbol";
@@ -19,12 +21,16 @@ function MenuIcon(props: {
readonly destructive?: boolean;
readonly disabled?: boolean;
}) {
+ const { iconSize } = useAndroidControlSizing();
return (
- <RNHostView matchContents modifiers={[size(24, 24)]}>
- <View style={{ width: 24, height: 24 }} importantForAccessibility="no-hide-descendants">
+ <RNHostView matchContents modifiers={[size(iconSize, iconSize)]}>
+ <View
+ style={{ width: iconSize, height: iconSize }}
+ importantForAccessibility="no-hide-descendants"
+ >
<SymbolView
name={props.name}
- size={24}
+ size={iconSize}
type="monochrome"
tintColorClassName={
props.disabled
@@ -41,24 +47,33 @@ function MenuIcon(props: {
/** Native popup positioned at the original trigger, outside virtualized rows. */
export function MaterialMenuPopup(props: MaterialMenuPopupProps) {
- const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
+ const { appearance, themeAppearance, themeVariables: colors } = useAppearancePreferences();
+ const { scale, menuItemHeight } = useAndroidControlSizing();
+ const body = resolveScaledTextRole("body", appearance.baseFontSize);
+ const caption = resolveScaledTextRole("caption", appearance.baseFontSize);
const foreground = colors["--color-foreground"];
const muted = colors["--color-foreground-muted"];
+ // A fixed native item height clips wrapped labels; a minimum lets each row grow.
+ const itemModifiers = [width(props.menuWidth), defaultMinSize({ minHeight: menuItemHeight })];
const items = (
<>
{props.parent ? (
- <DropdownMenuItem onClick={props.onBack} modifiers={[width(250)]}>
+ <DropdownMenuItem onClick={props.onBack} modifiers={itemModifiers}>
<DropdownMenuItem.LeadingIcon>
<MenuIcon name="arrow.left" />
</DropdownMenuItem.LeadingIcon>
<DropdownMenuItem.Text>
- <Text color={foreground} style={{ typography: "bodyLarge" }}>
+ <Text color={foreground} style={{ typography: "bodyLarge", ...body }}>
{props.parent.title}
</Text>
</DropdownMenuItem.Text>
</DropdownMenuItem>
) : props.title ? (
- <Text color={muted} style={{ typography: "bodySmall" }} modifiers={[padding(16, 8, 16, 8)]}>
+ <Text
+ color={muted}
+ style={{ typography: "bodySmall", ...caption }}
+ modifiers={[padding(16 * scale, 8 * scale, 16 * scale, 8 * scale)]}
+ >
{props.title}
</Text>
) : null}
@@ -66,19 +81,22 @@ export function MaterialMenuPopup(props: MaterialMenuPopupProps) {
<DropdownMenuItem
key={action.id ?? `${index}-${action.title}`}
enabled={!action.attributes?.disabled}
- modifiers={[width(250)]}
- elementColors={{
- textColor: action.attributes?.destructive
- ? colors["--color-danger-foreground"]
- : foreground,
- disabledTextColor: muted,
- }}
+ modifiers={itemModifiers}
onClick={() => props.onPress(action)}
>
+ {action.image && isAppSymbolName(action.image) ? (
+ <DropdownMenuItem.LeadingIcon>
+ <MenuIcon
+ name={action.image}
+ destructive={action.attributes?.destructive}
+ disabled={action.attributes?.disabled}
+ />
+ </DropdownMenuItem.LeadingIcon>
+ ) : null}
<DropdownMenuItem.Text>
<Column>
<Text
- style={{ typography: "bodyLarge" }}
+ style={{ typography: "bodyLarge", ...body }}
color={
action.attributes?.disabled
? muted
@@ -90,21 +108,12 @@ export function MaterialMenuPopup(props: MaterialMenuPopupProps) {
{action.title}
</Text>
{action.subtitle ? (
- <Text color={muted} style={{ typography: "bodySmall" }}>
+ <Text color={muted} style={{ typography: "bodySmall", ...caption }}>
{action.subtitle}
</Text>
) : null}
</Column>
</DropdownMenuItem.Text>
- {action.image && isAppSymbolName(action.image) ? (
- <DropdownMenuItem.LeadingIcon>
- <MenuIcon
- name={action.image}
- destructive={action.attributes?.destructive}
- disabled={action.attributes?.disabled}
- />
- </DropdownMenuItem.LeadingIcon>
- ) : null}
{(action.subactions?.length ?? 0) > 0 ? (
<DropdownMenuItem.TrailingIcon>
<MenuIcon name="chevron.right" disabled={action.attributes?.disabled} />
@@ -124,7 +133,7 @@ export function MaterialMenuPopup(props: MaterialMenuPopupProps) {
colorScheme={themeAppearance}
ignoreSafeAreaKeyboardInsets
matchContents
- style={{ width: 250 }}
+ style={{ width: props.menuWidth }}
>
<Column>{items}</Column>
</Host>
diff --git a/apps/mobile/src/components/MaterialMenuPopup.tsx b/apps/mobile/src/components/MaterialMenuPopup.tsx
index 3a23e5de7ab..06019a0e151 100644
--- a/apps/mobile/src/components/MaterialMenuPopup.tsx
+++ b/apps/mobile/src/components/MaterialMenuPopup.tsx
@@ -1,6 +1,7 @@
import type { MenuAction } from "@react-native-menu/menu";
export interface MaterialMenuPopupProps {
+ readonly menuWidth: number;
readonly anchor: {
readonly x: number;
readonly y: number;
diff --git a/apps/mobile/src/components/MaterialScrollComposeButton.android.tsx b/apps/mobile/src/components/MaterialScrollComposeButton.android.tsx
index 018dbdc19b4..8c653e67ee9 100644
--- a/apps/mobile/src/components/MaterialScrollComposeButton.android.tsx
+++ b/apps/mobile/src/components/MaterialScrollComposeButton.android.tsx
@@ -1,9 +1,17 @@
import { Box, ExtendedFloatingActionButton, Host, Icon, Text } from "@expo/ui/jetpack-compose";
-import { fillMaxWidth, onSizeChanged, size } from "@expo/ui/jetpack-compose/modifiers";
+import {
+ defaultMinSize,
+ fillMaxWidth,
+ graphicsLayer,
+ height,
+ onSizeChanged,
+ size,
+} from "@expo/ui/jetpack-compose/modifiers";
import { useCallback, useState } from "react";
import { Pressable, View, type StyleProp, type ViewStyle } from "react-native";
+import { useAndroidControlSizing } from "./useAndroidControlSizing";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
-import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
+import { resolveScaledTextRole } from "../lib/appearancePreferences";
/** Keep the animated width and icon positioning entirely inside Compose, not Yoga. */
export function MaterialScrollComposeButton(props: {
@@ -12,14 +20,23 @@ export function MaterialScrollComposeButton(props: {
readonly className?: string;
readonly style?: StyleProp<ViewStyle>;
}) {
- const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
- const typography = useScaledTextRole("footnote");
- const [expandedWidth, setExpandedWidth] = useState(56);
+ const { appearance, themeAppearance, themeVariables: colors } = useAppearancePreferences();
+ const typography = resolveScaledTextRole("footnote", appearance.baseFontSize);
+ const { iconSize, fabSize } = useAndroidControlSizing();
+ // Scale the native 56dp minimum; keep text and icons at their requested sizes.
+ const nativeSize = Math.max(56, fabSize);
+ const scale = fabSize / nativeSize;
+ const nativeIconSize = Math.round(iconSize / scale);
+ const [buttonWidth, setButtonWidth] = useState(nativeSize);
const rememberWidth = useCallback(({ width }: { width: number }) => {
- setExpandedWidth((previous) => Math.max(previous, width));
+ setButtonWidth((previous) => Math.max(previous, width));
}, []);
return (
- <View pointerEvents="box-none" className={props.className} style={[props.style, { left: 20 }]}>
+ <View
+ pointerEvents="box-none"
+ className={props.className}
+ style={[props.style, { left: 20, height: fabSize }]}
+ >
<View pointerEvents="none" importantForAccessibility="no-hide-descendants">
<Host
matchContents={{ vertical: true }}
@@ -31,13 +48,23 @@ export function MaterialScrollComposeButton(props: {
<ExtendedFloatingActionButton
expanded={props.expanded}
containerColor={colors["--color-primary"]}
- modifiers={[onSizeChanged(rememberWidth)]}
+ modifiers={[
+ defaultMinSize({ minWidth: nativeSize }),
+ height(nativeSize),
+ graphicsLayer({
+ scaleX: scale,
+ scaleY: scale,
+ transformOriginX: 1,
+ transformOriginY: 0,
+ }),
+ onSizeChanged(rememberWidth),
+ ]}
>
<ExtendedFloatingActionButton.Icon>
- <Box modifiers={[size(24, 24)]}>
+ <Box modifiers={[size(nativeIconSize, nativeIconSize)]}>
<Icon
source={require("../../assets/icons/compose.xml")}
- size={24}
+ size={nativeIconSize}
tint={colors["--color-primary-foreground"]}
/>
</Box>
@@ -45,7 +72,11 @@ export function MaterialScrollComposeButton(props: {
<ExtendedFloatingActionButton.Text>
<Text
color={colors["--color-primary-foreground"]}
- style={{ ...typography, fontWeight: "500" }}
+ style={{
+ fontSize: typography.fontSize / scale,
+ lineHeight: typography.lineHeight / scale,
+ fontWeight: "500",
+ }}
>
New thread
</Text>
@@ -65,8 +96,9 @@ export function MaterialScrollComposeButton(props: {
right: 0,
top: 0,
bottom: 0,
- width: props.expanded ? expandedWidth : 56,
- borderRadius: 16,
+ // Release the label area as soon as collapse starts, before native measurements arrive.
+ width: props.expanded ? buttonWidth * scale : fabSize,
+ borderRadius: 16 * scale,
overflow: "hidden",
}}
/>
diff --git a/apps/mobile/src/components/MaterialSearchField.tsx b/apps/mobile/src/components/MaterialSearchField.tsx
index ab96440f5f0..3609430a6e1 100644
--- a/apps/mobile/src/components/MaterialSearchField.tsx
+++ b/apps/mobile/src/components/MaterialSearchField.tsx
@@ -2,6 +2,7 @@ import type { RefObject } from "react";
import { Pressable, TextInput, View } from "react-native";
import { SymbolView } from "./AppSymbol";
+import { useAndroidControlSizing } from "./useAndroidControlSizing";
export function MaterialSearchField({
inputRef,
@@ -18,9 +19,21 @@ export function MaterialSearchField({
readonly value: string;
readonly onChangeText: (value: string) => void;
}) {
+ const { scale, mediumIconSize } = useAndroidControlSizing();
return (
- <View className="h-12 min-w-0 flex-1 flex-row items-center gap-2 rounded-full border border-input-border bg-input px-3">
- <SymbolView name="magnifyingglass" size={18} tintColorClassName="accent-foreground-muted" />
+ <View
+ className="min-w-0 flex-1 flex-row items-center rounded-full border border-input-border bg-input"
+ style={{
+ minHeight: Math.max(48, 42 * scale),
+ gap: 7 * scale,
+ paddingHorizontal: 10.5 * scale,
+ }}
+ >
+ <SymbolView
+ name="magnifyingglass"
+ size={mediumIconSize}
+ tintColorClassName="accent-foreground-muted"
+ />
<TextInput
ref={inputRef}
accessibilityLabel={accessibilityLabel}
@@ -33,7 +46,8 @@ export function MaterialSearchField({
selectionColorClassName="accent-focus/32"
cursorColorClassName="accent-focus"
selectionHandleColorClassName="accent-focus"
- className="min-w-0 flex-1 py-2 font-sans text-base text-foreground"
+ className="min-w-0 flex-1 font-sans text-base text-foreground"
+ style={{ paddingVertical: 7 * scale }}
value={value}
onChangeText={onChangeText}
/>
@@ -49,7 +63,7 @@ export function MaterialSearchField({
>
<SymbolView
name="xmark.circle.fill"
- size={18}
+ size={mediumIconSize}
tintColorClassName="accent-foreground-muted"
/>
</Pressable>
diff --git a/apps/mobile/src/components/ScreenHeader.android.tsx b/apps/mobile/src/components/ScreenHeader.android.tsx
index 61a38c3a00c..1d3232fd164 100644
--- a/apps/mobile/src/components/ScreenHeader.android.tsx
+++ b/apps/mobile/src/components/ScreenHeader.android.tsx
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useRef, useState } from "react";
import { BackHandler, Keyboard, Pressable, TextInput, View } from "react-native";
-import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { useMaterialToolbarLayout } from "./useMaterialToolbarLayout";
import { NativeStackScreenOptions } from "../native/StackHeader";
import { AndroidWorkspaceSidebarButton } from "../features/layout/workspace-sidebar-toolbar";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
@@ -11,10 +11,12 @@ import { ControlPillMenu } from "./ControlPill";
import { MaterialSearchField } from "./MaterialSearchField";
import { androidHeaderMenuActions, findHeaderMenuAction } from "./headerMenu.android";
import type { ScreenHeaderProps } from "./ScreenHeader.types";
+import { useAndroidControlSizing } from "./useAndroidControlSizing";
export function ScreenHeader(props: ScreenHeaderProps) {
const { search } = props;
- const insets = useSafeAreaInsets();
+ const { paddingTop, paddingBottom } = useMaterialToolbarLayout();
+ const { scale, buttonSize, iconSize, smallIconSize } = useAndroidControlSizing();
const { themeVariables } = useAppearancePreferences();
const inputRef = useRef<TextInput>(null);
const [searchOpen, setSearchOpen] = useState(false);
@@ -48,11 +50,12 @@ export function ScreenHeader(props: ScreenHeaderProps) {
<Pressable
accessibilityLabel={menu.title}
accessibilityRole="button"
- className="size-11 items-center justify-center rounded-full bg-subtle"
+ className="items-center justify-center rounded-full bg-subtle"
+ style={{ width: buttonSize, height: buttonSize }}
>
<SymbolView
name={menu.icon}
- size={16}
+ size={smallIconSize}
tintColorClassName="accent-header-foreground"
type="monochrome"
/>
@@ -80,30 +83,43 @@ export function ScreenHeader(props: ScreenHeaderProps) {
<>
{options}
<View
- className="border-b border-header-border bg-header px-3 pb-2.5"
- style={{ paddingTop: Math.max(insets.top, 12), borderBottomWidth: 0 }}
+ className="border-b border-header-border bg-header px-3"
+ style={{
+ paddingTop,
+ paddingBottom: 8.75 * scale,
+ borderBottomWidth: 0,
+ }}
>
- <View className="min-h-12 flex-row items-center gap-2">
+ <View className="flex-row items-center gap-2" style={{ minHeight: buttonSize }}>
{props.onBack ? (
<Pressable
accessibilityLabel="Navigate up"
accessibilityRole="button"
hitSlop={8}
onPress={props.onBack}
- className="size-11 items-center justify-center"
+ className="items-center justify-center"
+ style={{ width: buttonSize, height: buttonSize }}
>
<SymbolView
name="chevron.left"
- size={24}
+ size={iconSize}
tintColorClassName="accent-header-foreground"
type="monochrome"
/>
</Pressable>
) : null}
- <View className="min-h-11 flex-1 flex-row items-center gap-2.5 rounded-2xl bg-input px-3.5">
+ <View
+ className="flex-1 flex-row items-center bg-input"
+ style={{
+ minHeight: Math.max(48, 38.5 * scale),
+ gap: 8.75 * scale,
+ borderRadius: 14 * scale,
+ paddingHorizontal: 12.25 * scale,
+ }}
+ >
<SymbolView
name="magnifyingglass"
- size={17}
+ size={Math.round(17 * scale)}
tintColorClassName="accent-header-foreground"
type="monochrome"
/>
@@ -112,9 +128,14 @@ export function ScreenHeader(props: ScreenHeaderProps) {
autoCapitalize="none"
onChangeText={search.onChangeText}
value={search.value}
- placeholder={search.placeholder}
+ placeholder={
+ search.compactToolbar
+ ? (search.compactPlaceholder ?? search.placeholder)
+ : search.placeholder
+ }
placeholderTextColorClassName="accent-placeholder"
- className="flex-1 py-2 text-base font-sans text-header-foreground"
+ className="flex-1 text-base font-sans text-header-foreground"
+ style={{ paddingVertical: 7 * scale }}
/>
</View>
{menuView}
@@ -173,11 +194,8 @@ export function ScreenHeader(props: ScreenHeaderProps) {
{header}
</View>
{searching ? (
- <View
- className="absolute inset-0 bg-header px-2 pb-2"
- style={{ paddingTop: Math.max(insets.top, 12) }}
- >
- <View className="min-h-14 flex-1 flex-row items-center gap-1">
+ <View className="absolute inset-0 bg-header px-2" style={{ paddingTop, paddingBottom }}>
+ <View className="flex-1 flex-row items-center gap-1">
<ScreenHeaderButton
accessibilityLabel={search.closeAccessibilityLabel ?? "Close search"}
icon="arrow.left"
diff --git a/apps/mobile/src/components/useAndroidControlSizing.ts b/apps/mobile/src/components/useAndroidControlSizing.ts
new file mode 100644
index 00000000000..e2e586bb07a
--- /dev/null
+++ b/apps/mobile/src/components/useAndroidControlSizing.ts
@@ -0,0 +1,13 @@
+import { Platform } from "react-native";
+
+import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
+import { DEFAULT_BASE_FONT_SIZE } from "../lib/appearancePreferences";
+import { resolveAndroidControlSizing } from "../lib/androidControlSizing";
+
+/** Shared layouts keep their existing dimensions on iOS. */
+export function useAndroidControlSizing() {
+ const { appearance } = useAppearancePreferences();
+ return resolveAndroidControlSizing(
+ Platform.OS === "android" ? appearance.baseFontSize : DEFAULT_BASE_FONT_SIZE,
+ );
+}
diff --git a/apps/mobile/src/components/useMaterialToolbarHeight.ts b/apps/mobile/src/components/useMaterialToolbarHeight.ts
deleted file mode 100644
index 26e8510a82f..00000000000
--- a/apps/mobile/src/components/useMaterialToolbarHeight.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { useWindowDimensions } from "react-native";
-
-import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
-
-/** Reserve the same title/subtitle space in every pane, including icon-only and search headers. */
-export function useMaterialToolbarHeight() {
- const title = useScaledTextRole("title");
- const subtitle = useScaledTextRole("label");
- const { fontScale } = useWindowDimensions();
- return Math.ceil(Math.max(56, (title.lineHeight + subtitle.lineHeight) * fontScale + 1));
-}
diff --git a/apps/mobile/src/components/useMaterialToolbarLayout.ts b/apps/mobile/src/components/useMaterialToolbarLayout.ts
new file mode 100644
index 00000000000..f68a6eec7a4
--- /dev/null
+++ b/apps/mobile/src/components/useMaterialToolbarLayout.ts
@@ -0,0 +1,21 @@
+import { useWindowDimensions } from "react-native";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+
+import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
+import { useAndroidControlSizing } from "./useAndroidControlSizing";
+
+/** Shared Android header geometry; class-based spacing uses the app's 14dp rem. */
+export function useMaterialToolbarLayout(embedded = false) {
+ const insets = useSafeAreaInsets();
+ const title = useScaledTextRole("title");
+ const subtitle = useScaledTextRole("label");
+ const { scale } = useAndroidControlSizing();
+ const { fontScale } = useWindowDimensions();
+ return {
+ height: Math.ceil(
+ Math.max(48, 56 * scale, (title.lineHeight + subtitle.lineHeight) * fontScale + 1),
+ ),
+ paddingTop: embedded ? 8 * scale : Math.max(insets.top, 12 * scale),
+ paddingBottom: 7 * scale,
+ };
+}
diff --git a/apps/mobile/src/features/files/MaterialFilesHeader.tsx b/apps/mobile/src/features/files/MaterialFilesHeader.tsx
index 61d007ea5c3..c652ab67d37 100644
--- a/apps/mobile/src/features/files/MaterialFilesHeader.tsx
+++ b/apps/mobile/src/features/files/MaterialFilesHeader.tsx
@@ -1,10 +1,10 @@
import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
import { BackHandler, Keyboard, type TextInput, View } from "react-native";
-import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AndroidHeaderIconButton, AndroidScreenHeader } from "../../components/AndroidScreenHeader";
import { AndroidAnchoredMenu } from "../../components/AndroidAnchoredMenu";
import { MaterialSearchField } from "../../components/MaterialSearchField";
+import { useMaterialToolbarLayout } from "../../components/useMaterialToolbarLayout";
/** Keep Files search in the same header row on compact and expanded layouts. */
export function MaterialFilesHeader(props: {
@@ -15,7 +15,7 @@ export function MaterialFilesHeader(props: {
readonly onBack?: () => void;
readonly leading?: ReactNode;
}) {
- const insets = useSafeAreaInsets();
+ const { paddingTop, paddingBottom } = useMaterialToolbarLayout();
const searchRef = useRef<TextInput>(null);
const [searchOpen, setSearchOpen] = useState(false);
const searching = searchOpen || props.searchQuery.length > 0;
@@ -77,11 +77,8 @@ export function MaterialFilesHeader(props: {
/>
</View>
{searching ? (
- <View
- className="absolute inset-0 bg-header px-2 pb-2"
- style={{ paddingTop: Math.max(insets.top, 12) }}
- >
- <View className="min-h-14 flex-1 flex-row items-center gap-1">
+ <View className="absolute inset-0 bg-header px-2" style={{ paddingTop, paddingBottom }}>
+ <View className="flex-1 flex-row items-center gap-1">
<AndroidHeaderIconButton
accessibilityLabel="Close file search"
icon="arrow.left"
diff --git a/apps/mobile/src/features/home/AndroidHomeFab.android.tsx b/apps/mobile/src/features/home/AndroidHomeFab.android.tsx
index 012feb5ff68..bf466a78e97 100644
--- a/apps/mobile/src/features/home/AndroidHomeFab.android.tsx
+++ b/apps/mobile/src/features/home/AndroidHomeFab.android.tsx
@@ -1,14 +1,23 @@
import { useCallback, useRef, useState, type ComponentProps } from "react";
-import { View, type NativeScrollEvent, type NativeSyntheticEvent } from "react-native";
+import {
+ useWindowDimensions,
+ View,
+ type NativeScrollEvent,
+ type NativeSyntheticEvent,
+} from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { MaterialNewThreadButton } from "../../components/MaterialNewThreadButton";
import type { AndroidHomeFabLayout as SharedAndroidHomeFabLayout } from "./AndroidHomeFab.shared";
import { useWorkspaceState } from "../../state/workspace";
import { MaterialFabScrollContext } from "./MaterialFabScrollContext";
import { updateMaterialFabScroll } from "./material-fab-scroll";
+import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
export function AndroidHomeFabLayout(props: ComponentProps<typeof SharedAndroidHomeFabLayout>) {
const insets = useSafeAreaInsets();
+ const { appearance } = useAppearancePreferences();
+ const { fontScale } = useWindowDimensions();
+ const [layoutWidth, setLayoutWidth] = useState<number | null>(null);
const { state } = useWorkspaceState();
const [expanded, setExpanded] = useState(true);
const scrollState = useRef({ anchor: 0, expanded: true });
@@ -23,11 +32,13 @@ export function AndroidHomeFabLayout(props: ComponentProps<typeof SharedAndroidH
scrollState.current = next;
}, []);
+ // Remount only the FAB when its font or pane changes to clear the cached expanded width.
return (
- <View className="flex-1">
+ <View className="flex-1" onLayout={(event) => setLayoutWidth(event.nativeEvent.layout.width)}>
<MaterialFabScrollContext value={onScroll}>{props.children}</MaterialFabScrollContext>
- {state.hasConnections ? (
+ {state.hasConnections && layoutWidth !== null ? (
<MaterialNewThreadButton
+ key={`${appearance.baseFontSize}:${fontScale}:${layoutWidth}`}
extended
expanded={expanded}
onPress={props.onStartNewTask}
diff --git a/apps/mobile/src/features/home/HomeScreen.tsx b/apps/mobile/src/features/home/HomeScreen.tsx
index 7f4bfcf3a1c..d1d108d3bed 100644
--- a/apps/mobile/src/features/home/HomeScreen.tsx
+++ b/apps/mobile/src/features/home/HomeScreen.tsx
@@ -1,3 +1,4 @@
+import { useAndroidControlSizing } from "../../components/useAndroidControlSizing";
import type { ThreadMoveDestination } from "../threads/threadOrder";
import { computeThreadMoveAvailability } from "../threads/threadOrder";
import { LegendList } from "@legendapp/list/react-native";
@@ -214,6 +215,7 @@ export function HomeScreen(props: HomeScreenProps) {
const queuedThreadKeys = useQueuedThreadKeys();
const openSwipeableRef = useRef<SwipeableMethods | null>(null);
const insets = useSafeAreaInsets();
+ const { fabClearance } = useAndroidControlSizing();
const iosBottomToolbarClearance =
Platform.OS === "ios" && !NATIVE_LIQUID_GLASS_SUPPORTED
? PRE_LIQUID_GLASS_BOTTOM_TOOLBAR_HEIGHT
@@ -983,7 +985,7 @@ export function HomeScreen(props: HomeScreenProps) {
paddingBottom:
Platform.OS === "ios"
? Math.max(insets.bottom, 24) + 96 + iosBottomToolbarClearance
- : Math.max(insets.bottom, 16) + (Platform.OS === "android" ? 148 : 88),
+ : Math.max(insets.bottom, 16) + (Platform.OS === "android" ? fabClearance : 88),
}}
/>
</SwipeableScrollGateProvider>
diff --git a/apps/mobile/src/features/home/MaterialThreadListToolbar.tsx b/apps/mobile/src/features/home/MaterialThreadListToolbar.tsx
index 2d852f8f7be..6cea625aced 100644
--- a/apps/mobile/src/features/home/MaterialThreadListToolbar.tsx
+++ b/apps/mobile/src/features/home/MaterialThreadListToolbar.tsx
@@ -12,7 +12,8 @@ import { MaterialSearchField } from "../../components/MaterialSearchField";
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
import { WorkspaceConnectionTitle } from "./WorkspaceConnectionTitle";
import { useWorkspaceState } from "../../state/workspace";
-import { useMaterialToolbarHeight } from "../../components/useMaterialToolbarHeight";
+import { useAndroidControlSizing } from "../../components/useAndroidControlSizing";
+import { useMaterialToolbarLayout } from "../../components/useMaterialToolbarLayout";
/** One toolbar height for the compact list and expanded sidebar, including search. */
export function MaterialThreadListToolbar(props: {
@@ -28,7 +29,8 @@ export function MaterialThreadListToolbar(props: {
readonly onRequestVisibility?: () => void;
}) {
const insets = useSafeAreaInsets();
- const toolbarHeight = useMaterialToolbarHeight();
+ const { fabSize } = useAndroidControlSizing();
+ const { height: toolbarHeight, ...headerPadding } = useMaterialToolbarLayout();
const { state } = useWorkspaceState();
const { onRequestVisibility, onSearchQueryChange } = props;
const searchRef = useRef<TextInput>(null);
@@ -76,11 +78,9 @@ export function MaterialThreadListToolbar(props: {
<View
onLayout={props.onLayout}
className={
- props.sidebar
- ? "absolute inset-x-0 top-0 z-[4] bg-header px-2 pb-2"
- : "bg-header px-2 pb-2"
+ props.sidebar ? "absolute inset-x-0 top-0 z-[4] bg-header px-2" : "bg-header px-2"
}
- style={{ paddingTop: Math.max(insets.top, 12) }}
+ style={headerPadding}
>
<View className="flex-row items-center gap-1" style={{ minHeight: toolbarHeight }}>
{searching ? (
@@ -116,14 +116,14 @@ export function MaterialThreadListToolbar(props: {
)}
</View>
</View>
- {/* Sit 8dp above the 56dp extended New thread FAB. */}
+ {/* Keep the filter above the New thread FAB at every text size. */}
{state.hasConnections ? (
<View
className="absolute right-5 z-[5]"
style={{
bottom:
(props.sidebar ? Math.max(insets.bottom, 12) + 6 : Math.max(insets.bottom, 16) + 16) +
- 56 +
+ fabSize +
8,
}}
>
diff --git a/apps/mobile/src/features/home/WorkspaceConnectionTitle.tsx b/apps/mobile/src/features/home/WorkspaceConnectionTitle.tsx
index 9b9333b46c7..d2b068a07c5 100644
--- a/apps/mobile/src/features/home/WorkspaceConnectionTitle.tsx
+++ b/apps/mobile/src/features/home/WorkspaceConnectionTitle.tsx
@@ -1,9 +1,10 @@
import type { NativeStackNavigationOptions } from "@react-navigation/native-stack";
import { useEffect, useRef, useState, type ReactNode } from "react";
-import { ActivityIndicator, Animated, Pressable, View } from "react-native";
+import { ActivityIndicator, Animated, Platform, Pressable, View } from "react-native";
import { SymbolView } from "../../components/AppSymbol";
import { AppText as Text } from "../../components/AppText";
+import { useAndroidControlSizing } from "../../components/useAndroidControlSizing";
import {
brandTitleOffset,
CompactBrandTitle,
@@ -105,6 +106,7 @@ export function WorkspaceConnectionTitle(props: {
}) {
const status = useDelayedConnectionStatus();
const size = props.size ?? "navbar";
+ const { scale } = useAndroidControlSizing();
if (status === null) {
return props.grow ? (
@@ -126,26 +128,28 @@ export function WorkspaceConnectionTitle(props: {
hitSlop={8}
onPress={props.onPress}
className="flex-row items-center gap-2"
- style={{ flexShrink: 1, marginLeft: props.statusOffset ?? 0 }}
+ style={[
+ { flexShrink: 1, marginLeft: props.statusOffset ?? 0 },
+ Platform.OS === "android" && { gap: 7 * scale },
+ ]}
>
{status.showsProgress ? (
- <ActivityIndicator colorClassName={"accent-icon-muted"} size="small" />
+ <ActivityIndicator
+ colorClassName={"accent-icon-muted"}
+ size={Platform.OS === "android" ? Math.round(20 * scale) : "small"}
+ />
) : (
<SymbolView
name="wifi.slash"
- size={size === "pageTitle" ? 17 : 15}
+ size={Math.round((size === "pageTitle" ? 17 : 15) * scale)}
tintColorClassName={"accent-icon-muted"}
type="monochrome"
/>
)}
<Text
- className={
- size === "pageTitle"
- ? "text-[20px] font-t3-bold text-foreground-muted"
- : "text-[16px] font-t3-bold text-foreground-muted"
- }
+ className="font-t3-bold text-foreground-muted"
numberOfLines={1}
- style={{ flexShrink: 1 }}
+ style={{ flexShrink: 1, fontSize: (size === "pageTitle" ? 20 : 16) * scale }}
>
{status.label}
</Text>
diff --git a/apps/mobile/src/features/settings/appearance/useScaledTextRole.ts b/apps/mobile/src/features/settings/appearance/useScaledTextRole.ts
index 62f918a0e6b..561cc53e44a 100644
--- a/apps/mobile/src/features/settings/appearance/useScaledTextRole.ts
+++ b/apps/mobile/src/features/settings/appearance/useScaledTextRole.ts
@@ -1,10 +1,6 @@
import { useMemo } from "react";
-import {
- DEFAULT_BASE_FONT_SIZE,
- normalizeBaseFontSize,
- scaledTypographyLineHeight,
-} from "../../../lib/appearancePreferences";
+import { resolveScaledTextRole } from "../../../lib/appearancePreferences";
import { MOBILE_TYPOGRAPHY } from "../../../lib/typography";
import { useAppearancePreferences } from "./AppearancePreferencesProvider";
@@ -20,15 +16,8 @@ export interface ScaledTextRole {
*/
export function useScaledTextRole(role: keyof typeof MOBILE_TYPOGRAPHY): ScaledTextRole {
const { appearance } = useAppearancePreferences();
- return useMemo(() => {
- const baseFontSize = normalizeBaseFontSize(appearance.baseFontSize);
- const typography = MOBILE_TYPOGRAPHY[role];
- return {
- fontSize: Math.max(
- 8,
- Math.round(typography.fontSize * (baseFontSize / DEFAULT_BASE_FONT_SIZE)),
- ),
- lineHeight: scaledTypographyLineHeight(typography, baseFontSize),
- };
- }, [appearance.baseFontSize, role]);
+ return useMemo(
+ () => resolveScaledTextRole(role, appearance.baseFontSize),
+ [appearance.baseFontSize, role],
+ );
}
diff --git a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
index 681f6c5ee52..7e90b074337 100644
--- a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
+++ b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
@@ -132,30 +132,40 @@ import { fileRoutePathSegments } from "../files/filePath";
function NewTaskWorkspaceIcon(props: {
readonly workspaceMode: "local" | "worktree";
readonly worktreePath: string | null;
+ readonly size: number;
}) {
if (props.workspaceMode === "local" && props.worktreePath === null) {
return (
<SymbolView
name="folder"
- size={16}
+ size={props.size}
tintColorClassName="accent-icon-muted"
type="monochrome"
/>
);
}
+ const boxSize = (14 * props.size) / 16;
return (
- <View className="size-4">
+ <View
+ className="size-4"
+ style={Platform.OS === "android" ? { width: boxSize, height: boxSize } : undefined}
+ >
<SymbolView
name="folder"
- size={16}
+ size={props.size}
tintColorClassName="accent-icon-muted"
type="monochrome"
/>
- <View className="absolute -right-1 -bottom-1">
+ <View
+ className="absolute -right-1 -bottom-1"
+ style={
+ Platform.OS === "android" ? { right: -boxSize / 4, bottom: -boxSize / 4 } : undefined
+ }
+ >
<SymbolView
name="arrow.triangle.branch"
- size={9}
+ size={Math.round((9 * props.size) / 16)}
tintColorClassName="accent-icon-muted"
type="monochrome"
/>
@@ -1476,13 +1486,13 @@ export function NewTaskDraftScreen(props: {
accessibilityLabel={`Environment: ${selectedEnvironmentLabel}`}
chevronDirection="right"
disabled={isComposerInteractionLocked || voiceInput.isBusy}
- iconNode={
+ renderIcon={(size) => (
<EnvironmentMachineSymbol
kind={resolveEnvironmentMachineKind(selectedEnvironmentServerConfig)}
- size={16}
+ size={size}
tintColorClassName="accent-icon-muted"
/>
- }
+ )}
label={`on ${selectedEnvironmentLabel}`}
maxWidth={260}
onPress={
@@ -1517,12 +1527,13 @@ export function NewTaskDraftScreen(props: {
accessibilityHint={`Switches to ${flow.workspaceMode === "local" ? "a new worktree" : "the current checkout"}`}
accessibilityLabel={workspaceLabel}
disabled={isComposerInteractionLocked || voiceInput.isBusy}
- iconNode={
+ renderIcon={(size) => (
<NewTaskWorkspaceIcon
workspaceMode={flow.workspaceMode}
worktreePath={flow.selectedWorktreePath}
+ size={size}
/>
- }
+ )}
label={workspaceLabel}
maxWidth={flow.workspaceMode === "local" ? 220 : 148}
onPress={() => flow.setWorkspaceMode(flow.workspaceMode === "local" ? "worktree" : "local")}
@@ -1681,12 +1692,12 @@ export function NewTaskDraftScreen(props: {
accessibilityLabel="Model and reasoning settings"
disabled={isComposerInteractionLocked}
emphasized
- iconNode={
+ renderIcon={(size) => (
<ProviderIcon
provider={flow.selectedModelOption?.providerDriver}
- size={16}
+ size={size}
/>
- }
+ )}
label={flow.selectedModelOption?.label ?? "Choose model"}
maxWidth="100%"
onPress={settingsSheetPresentation.open}
diff --git a/apps/mobile/src/features/threads/ThreadComposer.tsx b/apps/mobile/src/features/threads/ThreadComposer.tsx
index 23ddc65896b..d131dfaa51f 100644
--- a/apps/mobile/src/features/threads/ThreadComposer.tsx
+++ b/apps/mobile/src/features/threads/ThreadComposer.tsx
@@ -961,9 +961,9 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
<ComposerInlineControl
accessibilityLabel="Model and reasoning settings"
emphasized
- iconNode={
- <ProviderIcon provider={currentModelOption?.providerDriver} size={16} />
- }
+ renderIcon={(size) => (
+ <ProviderIcon provider={currentModelOption?.providerDriver} size={size} />
+ )}
label={currentModelOption?.label ?? currentModelSelection.model}
maxWidth="100%"
onPress={openSettings}
diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
index c478bae6312..d9e165bd010 100644
--- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
@@ -1,3 +1,4 @@
+import { useAndroidControlSizing } from "../../components/useAndroidControlSizing";
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
import { computeThreadMoveAvailability } from "./threadOrder";
import type {
@@ -50,7 +51,7 @@ import {
} from "../home/WorkspaceConnectionTitle";
import { SidebarHeaderActions } from "./sidebar-header-actions";
import { MaterialThreadListToolbar } from "../home/MaterialThreadListToolbar";
-import { useMaterialToolbarHeight } from "../../components/useMaterialToolbarHeight";
+import { useMaterialToolbarLayout } from "../../components/useMaterialToolbarLayout";
import { useMaterialFabScroll } from "../home/MaterialFabScrollContext";
import { SidebarFilterButton } from "./sidebar-filter-button";
import { createSidebarHeaderItems } from "./sidebar-native-header-items";
@@ -133,6 +134,7 @@ function ThreadNavigationSidebarPane(
const drawerColor = materialTheme["--color-drawer"];
const insets = useSafeAreaInsets();
+ const { fabClearance } = useAndroidControlSizing();
const projects = useProjects();
const threads = useThreadShells();
const { environments: workspaceEnvironments, state: catalogState } = useWorkspaceState();
@@ -603,14 +605,14 @@ function ThreadNavigationSidebarPane(
);
const [measuredHeaderHeight, setMeasuredHeaderHeight] = useState<number | null>(null);
- const materialToolbarHeight = useMaterialToolbarHeight();
+ const { height, paddingTop, paddingBottom } = useMaterialToolbarLayout();
// The sticky header (title row, search field, optional connection status)
// is measured so the list inset always matches its real height — no
// hardcoded per-variant constants.
const stickyHeaderHeight =
measuredHeaderHeight ??
(Platform.OS === "android"
- ? Math.max(insets.top, 12) + materialToolbarHeight + 8
+ ? paddingTop + height + paddingBottom
: insets.top + SIDEBAR_STICKY_HEADER_HEIGHT);
const topListInset = stickyHeaderHeight + 6;
const handleStickyHeaderLayout = useCallback((event: LayoutChangeEvent) => {
@@ -1039,7 +1041,7 @@ function ThreadNavigationSidebarPane(
{
paddingBottom:
Platform.OS === "android"
- ? Math.max(insets.bottom, 16) + 148 - insets.bottom
+ ? Math.max(insets.bottom, 16) + fabClearance - insets.bottom
: 16 + insets.bottom,
paddingTop: Platform.OS === "android" ? 6 : topListInset,
},
diff --git a/apps/mobile/src/lib/androidControlSizing.test.ts b/apps/mobile/src/lib/androidControlSizing.test.ts
new file mode 100644
index 00000000000..8b9fd9751cb
--- /dev/null
+++ b/apps/mobile/src/lib/androidControlSizing.test.ts
@@ -0,0 +1,22 @@
+import { describe, expect, it } from "vite-plus/test";
+
+import { resolveAndroidControlSizing } from "./androidControlSizing";
+
+describe("Android control sizing", () => {
+ it.each([
+ [11, 17, 48, 48, 172, 48],
+ [16, 24, 48, 56, 250, 48],
+ [22, 33, 66, 77, 344, 66],
+ ])(
+ "scales controls at %ipt",
+ (fontSize, iconSize, buttonSize, fabSize, menuWidth, menuItemHeight) => {
+ expect(resolveAndroidControlSizing(fontSize)).toMatchObject({
+ iconSize,
+ buttonSize,
+ fabSize,
+ menuWidth,
+ menuItemHeight,
+ });
+ },
+ );
+});
diff --git a/apps/mobile/src/lib/androidControlSizing.ts b/apps/mobile/src/lib/androidControlSizing.ts
new file mode 100644
index 00000000000..f6868ad07bd
--- /dev/null
+++ b/apps/mobile/src/lib/androidControlSizing.ts
@@ -0,0 +1,23 @@
+import { DEFAULT_BASE_FONT_SIZE, normalizeBaseFontSize } from "./appearancePreferences";
+
+/** Android controls follow the app's text size; buttons and menu rows retain a 48dp touch target. */
+export function resolveAndroidControlSizing(baseFontSize: number) {
+ const scale = normalizeBaseFontSize(baseFontSize) / DEFAULT_BASE_FONT_SIZE;
+ const iconSize = Math.round(24 * scale);
+ const buttonSize = Math.max(48, Math.round(48 * scale));
+ const fabSize = Math.max(48, Math.round(56 * scale));
+
+ return {
+ scale,
+ iconSize,
+ smallIconSize: Math.round(16 * scale),
+ mediumIconSize: Math.round(18 * scale),
+ buttonSize,
+ fabSize,
+ largeFabSize: Math.round(96 * scale),
+ menuWidth: Math.round(250 * scale),
+ menuItemHeight: Math.max(48, Math.round(48 * scale)),
+ // Two floating actions, their gap, and the space below the lower action.
+ fabClearance: fabSize * 2 + 36,
+ };
+}
diff --git a/apps/mobile/src/lib/appearancePreferences.ts b/apps/mobile/src/lib/appearancePreferences.ts
index 2ce6a8b5a36..981b35808a5 100644
--- a/apps/mobile/src/lib/appearancePreferences.ts
+++ b/apps/mobile/src/lib/appearancePreferences.ts
@@ -219,6 +219,16 @@ export function scaledTypographyLineHeight(
return Math.max(10, Math.round(role.lineHeight * scale));
}
+/** Text dimensions shared by React Native and Compose consumers of an appearance role. */
+export function resolveScaledTextRole(role: keyof typeof MOBILE_TYPOGRAPHY, baseFontSize: number) {
+ const typography = MOBILE_TYPOGRAPHY[role];
+ const scale = normalizeBaseFontSize(baseFontSize) / DEFAULT_BASE_FONT_SIZE;
+ return {
+ fontSize: Math.max(8, Math.round(typography.fontSize * scale)),
+ lineHeight: scaledTypographyLineHeight(typography, baseFontSize),
+ };
+}
+
export function resolveNativeMarkdownTypography(baseFontSize: number): NativeMarkdownTypography {
const fontSizes = resolveMarkdownFontSizes(baseFontSize);
return {