@devries-cameron20 / t3code-1 / commits / ac57e62f72
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

refactor(mobile): adopt native Android screen headers (#19995)

Julius Marminge committed Oct 15, 2026 at 15:46 UTC ac57e62f723a53142288abfe9809e6fd1d82c0ff
2 files changed +123 -83
apps/mobile/src/components/AndroidScreenHeader.tsx
+112 -78
@@ -1,14 +1,15 @@
1 +import { Column, Text as NativeText, RNHostView } from "@expo/ui/jetpack-compose";
2 import { useState, type ReactNode } from "react";
3 import { ActivityIndicator, View } from "react-native";
4
5 import type { AppSymbolName } from "./AppSymbol";
5 -import { AppText as Text } from "./AppText";
6 -import { cn } from "../lib/cn";
6 +import { NativeAppBar } from "./NativeAppBar.android";
7 import { IconButton } from "./IconButton";
8 import { AndroidAnchoredMenu } from "./AndroidAnchoredMenu";
9 import { splitAndroidHeaderActions } from "./headerMenu.android";
10 import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
11 import { useToolbarLayout } from "./useToolbarLayout";
12 +import { useControlTheme } from "./useControlTheme";
13
14 export interface AndroidHeaderAction {
15 readonly accessibilityLabel: string;
@@ -42,9 +43,10 @@ export function AndroidScreenHeader(props: {
43 readonly embedded?: boolean;
44 readonly hideBottomBorder?: boolean;
45 }) {
46 + const { colors } = useControlTheme();
47 const titleTypography = useScaledTextRole("title");
48 const subtitleTypography = useScaledTextRole("label");
47 - const { height: materialToolbarHeight, ...headerPadding } = useToolbarLayout(props.embedded);
49 + const { paddingTop, paddingBottom } = useToolbarLayout(props.embedded);
50 const [headerWidth, setHeaderWidth] = useState(0);
51 const { visibleActions, overflowActions } = splitAndroidHeaderActions(
52 props.actions ?? [],
@@ -54,88 +56,120 @@ export function AndroidScreenHeader(props: {
56 return (
57 <View
58 onLayout={(event) => setHeaderWidth(event.nativeEvent.layout.width)}
57 - className="border-b border-header-border bg-header px-2"
59 + className="border-b border-header-border bg-header"
60 style={{
59 - ...headerPadding,
61 + paddingTop,
62 + paddingBottom,
63 borderBottomWidth: props.hideBottomBorder ? 0 : undefined,
64 }}
65 >
63 - <View style={{ minHeight: materialToolbarHeight }} className="flex-row items-center gap-1">
64 - {props.onBack ? (
65 - <IconButton
66 - accessibilityLabel="Navigate up"
67 - icon="arrow.left"
68 - tintColorClassName="accent-header-foreground"
69 - onPress={props.onBack}
70 - />
71 - ) : null}
66 + <NativeAppBar
67 + navigationIcon={
68 + props.onBack || props.leading ? (
69 + <View collapsable={false} className="flex-row items-center">
70 + {props.onBack ? (
71 + <IconButton
72 + accessibilityLabel="Navigate up"
73 + icon="arrow.left"
74 + tintColorClassName="accent-header-foreground"
75 + onPress={props.onBack}
76 + />
77 + ) : null}
78
73 - {props.leading}
74 -
75 - <View className={cn("min-w-0 flex-1", !props.onBack && "pl-1")}>
76 - {props.titleContent ?? (
77 - <Text numberOfLines={1} style={titleTypography} className="text-header-foreground">
78 - {props.title}
79 - </Text>
80 - )}
81 - {props.subtitle ? (
82 - <Text
83 - numberOfLines={1}
84 - style={subtitleTypography}
85 - className="mt-px text-[13px] font-t3-medium text-foreground-muted"
86 - >
87 - {props.subtitle}
88 - </Text>
89 - ) : null}
90 - </View>
91 -
92 - {visibleActions.map((action) =>
93 - action.loading ? (
94 - <View
95 - key={action.accessibilityLabel}
96 - accessibilityLabel={action.accessibilityLabel}
97 - className="size-12 items-center justify-center"
98 - >
99 - <ActivityIndicator colorClassName="accent-header-foreground" />
79 + {props.leading}
80 </View>
81 + ) : undefined
82 + }
83 + title={
84 + props.titleContent ? (
85 + <RNHostView matchContents={{ vertical: true }}>
86 + <View collapsable={false}>{props.titleContent}</View>
87 + </RNHostView>
88 + ) : !props.subtitle ? (
89 + <NativeText
90 + color={colors["--color-header-foreground"]}
91 + maxLines={1}
92 + overflow="ellipsis"
93 + style={titleTypography}
94 + >
95 + {props.title}
96 + </NativeText>
97 ) : (
102 - <AndroidHeaderIconButton
103 - key={action.accessibilityLabel}
104 - accessibilityLabel={action.accessibilityLabel}
105 - disabled={action.disabled}
106 - selected={action.selected}
107 - icon={action.icon}
108 - onPress={action.onPress}
109 - />
110 - ),
111 - )}
112 - {overflowActions.length > 0 ? (
113 - <AndroidAnchoredMenu
114 - actions={overflowActions.map((action, index) => ({
115 - id: String(index),
116 - title: action.accessibilityLabel,
117 - attributes: {
118 - disabled: Boolean(action.disabled),
119 - destructive: action.destructive,
120 - state: action.selected ? "on" : undefined,
121 - },
122 - }))}
123 - onPressAction={({ nativeEvent }) =>
124 - overflowActions[Number(nativeEvent.event)]?.onPress()
125 - }
126 - >
127 - {(open) => (
128 - <IconButton
129 - accessibilityLabel="More actions"
130 - icon="ellipsis"
131 - tintColorClassName="accent-header-foreground"
132 - onPress={open}
133 - />
134 - )}
135 - </AndroidAnchoredMenu>
136 - ) : null}
137 - {props.trailing}
138 - </View>
98 + <Column>
99 + <NativeText
100 + color={colors["--color-header-foreground"]}
101 + maxLines={1}
102 + overflow="ellipsis"
103 + style={titleTypography}
104 + >
105 + {props.title}
106 + </NativeText>
107 + {props.subtitle ? (
108 + <NativeText
109 + color={colors["--color-foreground-muted"]}
110 + maxLines={1}
111 + overflow="ellipsis"
112 + style={subtitleTypography}
113 + >
114 + {props.subtitle}
115 + </NativeText>
116 + ) : null}
117 + </Column>
118 + )
119 + }
120 + actions={
121 + visibleActions.length > 0 || overflowActions.length > 0 || props.trailing ? (
122 + <View collapsable={false} className="flex-row items-center">
123 + {visibleActions.map((action) =>
124 + action.loading ? (
125 + <View
126 + key={action.accessibilityLabel}
127 + accessibilityLabel={action.accessibilityLabel}
128 + className="size-12 items-center justify-center"
129 + >
130 + <ActivityIndicator colorClassName="accent-header-foreground" />
131 + </View>
132 + ) : (
133 + <AndroidHeaderIconButton
134 + key={action.accessibilityLabel}
135 + accessibilityLabel={action.accessibilityLabel}
136 + disabled={action.disabled}
137 + selected={action.selected}
138 + icon={action.icon}
139 + onPress={action.onPress}
140 + />
141 + ),
142 + )}
143 + {overflowActions.length > 0 ? (
144 + <AndroidAnchoredMenu
145 + actions={overflowActions.map((action, index) => ({
146 + id: String(index),
147 + title: action.accessibilityLabel,
148 + attributes: {
149 + disabled: Boolean(action.disabled),
150 + destructive: action.destructive,
151 + state: action.selected ? "on" : undefined,
152 + },
153 + }))}
154 + onPressAction={({ nativeEvent }) =>
155 + overflowActions[Number(nativeEvent.event)]?.onPress()
156 + }
157 + >
158 + {(open) => (
159 + <IconButton
160 + accessibilityLabel="More actions"
161 + icon="ellipsis"
162 + tintColorClassName="accent-header-foreground"
163 + onPress={open}
164 + />
165 + )}
166 + </AndroidAnchoredMenu>
167 + ) : null}
168 + {props.trailing}
169 + </View>
170 + ) : undefined
171 + }
172 + />
173 </View>
174 );
175 }
apps/mobile/src/components/AppBar.android.tsx
+11 -5
@@ -180,10 +180,12 @@ export function AppBar(props: AppBarProps) {
180 : props.actions
181 }
182 trailing={
183 - <>
184 - {menuView}
185 - {props.trailing}
186 - </>
183 + menuView?.length || props.trailing ? (
184 + <>
185 + {menuView}
186 + {props.trailing}
187 + </>
188 + ) : undefined
189 }
190 />
191 );
@@ -201,7 +203,11 @@ export function AppBar(props: AppBarProps) {
203 {header}
204 </View>
205 {searching ? (
204 - <View className="absolute inset-0 bg-header px-2" style={{ paddingTop, paddingBottom }}>
206 + <View
207 + className="absolute inset-0 bg-header"
208 + // Match Material TopAppBar's navigation inset so the back button stays put.
209 + style={{ paddingTop, paddingBottom, paddingHorizontal: 4 }}
210 + >
211 <View className="flex-1 flex-row items-center gap-1">
212 <ScreenHeaderButton
213 accessibilityLabel={search.closeAccessibilityLabel ?? "Close search"}