Skip to content
TypeScript

refactor(android): every header goes through AppBar, so the filter stays put (#26741)

Julius Marminge5e6c4d92d182
diff --git a/apps/mobile/assets/icons/filter-filled.xml b/apps/mobile/assets/icons/filter-filled.xml
new file mode 100644
index 00000000000..14ad0334005
--- /dev/null
+++ b/apps/mobile/assets/icons/filter-filled.xml
@@ -0,0 +1,7 @@
+<!-- Tabler Icons filter, filled (MIT), matching AppSymbol's line.3.horizontal.decrease.circle.fill. -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp" android:height="24dp"
+ android:viewportWidth="24" android:viewportHeight="24">
+ <path android:fillColor="#000000"
+ android:pathData="M20,3 h-16 a1,1 0 0,0 -1,1 v2.227 l0.008,0.223 a3,3 0 0,0 0.772,1.795 l4.22,4.641 v8.114 a1,1 0 0,0 1.316,0.949 l6,-2 l0.108,-0.043 a1,1 0 0,0 0.576,-0.906 v-6.586 l4.121,-4.12 a3,3 0 0,0 0.879,-2.123 v-2.171 a1,1 0 0,0 -1,-1 z" />
+</vector>
diff --git a/apps/mobile/assets/icons/filter.xml b/apps/mobile/assets/icons/filter.xml
new file mode 100644
index 00000000000..51ba41def08
--- /dev/null
+++ b/apps/mobile/assets/icons/filter.xml
@@ -0,0 +1,8 @@
+<!-- Tabler Icons filter (MIT), matching AppSymbol's line.3.horizontal.decrease.circle.
+ Strokes expanded to fills: Expo UI's vector parser does not support strokes. -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp" android:height="24dp"
+ android:viewportWidth="24" android:viewportHeight="24">
+ <path android:fillColor="#000000"
+ android:pathData="M3,4 A1,1 0 0,1 4,3 L20,3 A1,1 0 0,1 21,4 L21,6.172 A1,1 0 0,1 20.9969,6.2505 L20.9723,6.5633 A1,1 0 0,1 20.9477,6.7183 L20.8745,7.0235 A1,1 0 0,1 20.826,7.1727 L20.7059,7.4627 A1,1 0 0,1 20.6347,7.6025 L20.4707,7.8701 A1,1 0 0,1 20.3778,7.9977 L20.1738,8.2362 A1,1 0 0,1 20.1211,8.2931 L16,12.4142 L16,19 A1,1 0 0,1 15.3162,19.9487 L9.3162,21.9487 A1,1 0 0,1 8,21 L8,12.8866 L3.7801,8.2447 A1,1 0 0,1 3.7328,8.1888 L3.5517,7.9575 A1,1 0 0,1 3.4694,7.8348 L3.3236,7.5783 A1,1 0 0,1 3.2604,7.4451 L3.1539,7.1699 A1,1 0 0,1 3.111,7.0287 L3.0462,6.7409 A1,1 0 0,1 3.0245,6.595 L3.0027,6.3008 A1,1 0 0,1 3,6.227 Z M5,6.1901 L5.0136,6.3737 L5.0459,6.5172 L5.099,6.6544 L5.1716,6.7823 L5.2846,6.9264 L9.7399,11.8273 A1,1 0 0,1 10,12.5 L10,19.6126 L14,18.2792 L14,12 A1,1 0 0,1 14.2929,11.2929 L18.6795,6.9063 L18.8068,6.7576 L18.8883,6.6246 L18.9481,6.4801 L18.9846,6.328 L19,6.1327 L19,5 L5,5 Z" />
+</vector>
diff --git a/apps/mobile/assets/icons/search.xml b/apps/mobile/assets/icons/search.xml
new file mode 100644
index 00000000000..63b232fb961
--- /dev/null
+++ b/apps/mobile/assets/icons/search.xml
@@ -0,0 +1,10 @@
+<!-- Tabler Icons search (MIT), matching AppSymbol's magnifyingglass.
+ Strokes expanded to fills: Expo UI's vector parser does not support strokes. -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp" android:height="24dp"
+ android:viewportWidth="24" android:viewportHeight="24">
+ <path android:fillColor="#000000"
+ android:pathData="M2,10 A8,8 0 1,1 18,10 A8,8 0 1,1 2,10 Z M4,10 A6,6 0 1,0 16,10 A6,6 0 1,0 4,10 Z" />
+ <path android:fillColor="#000000"
+ android:pathData="M14.2929,15.7071 A1,1 0 0,1 15.7071,14.2929 L21.7071,20.2929 A1,1 0 0,1 20.2929,21.7071 Z" />
+</vector>
diff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsx
index 872ca142c8a..601f5100839 100644
--- a/apps/mobile/src/Stack.tsx
+++ b/apps/mobile/src/Stack.tsx
@@ -973,7 +973,7 @@ const RootStackConfig = createWorkspaceStackNavigator({
screen: ConnectOnboardingRouteScreen,
linking: "connect-onboarding",
options: {
- // Android root formSheets lack a native stack bar; the route provides AndroidSheetHeader.
+ // Android root formSheets lack a native stack bar; the route provides its own sheet AppBar.
...(Platform.OS === "android" ? { headerShown: false } : SHEET_SOLID_HEADER_OPTIONS),
title: "Set up T3 Connect",
gestureEnabled: true,
diff --git a/apps/mobile/src/components/ui/AndroidScreenHeader.tsx b/apps/mobile/src/components/ui/AndroidScreenHeader.tsx
index 3d7605b71b5..b7ab699b11b 100644
--- a/apps/mobile/src/components/ui/AndroidScreenHeader.tsx
+++ b/apps/mobile/src/components/ui/AndroidScreenHeader.tsx
@@ -208,9 +208,3 @@ export function AndroidScreenHeader(props: {
</View>
);
}
-
-export function AndroidSheetHeader(
- props: Omit<Parameters<typeof AndroidScreenHeader>[0], "embedded">,
-) {
- return <AndroidScreenHeader {...props} embedded />;
-}
diff --git a/apps/mobile/src/components/ui/AppBar.android.test.tsx b/apps/mobile/src/components/ui/AppBar.android.test.tsx
new file mode 100644
index 00000000000..30b70764820
--- /dev/null
+++ b/apps/mobile/src/components/ui/AppBar.android.test.tsx
@@ -0,0 +1,56 @@
+import { act, type ReactNode } from "react";
+import { createRoot, type Root } from "react-dom/client";
+import { afterEach, expect, it, vi } from "vite-plus/test";
+
+vi.mock("react-native", () => ({
+ View: (props: { readonly children?: ReactNode }) => <div>{props.children}</div>,
+ Keyboard: { dismiss: () => {} },
+ BackHandler: { addEventListener: () => ({ remove: () => {} }) },
+}));
+// React Navigation throws this outside a navigator, as for the Arrange threads sheet.
+vi.mock("@react-navigation/native", () => ({
+ useIsFocused: () => {
+ throw new Error("Couldn't find a navigation object.");
+ },
+}));
+vi.mock("./AndroidScreenHeader", () => ({
+ AndroidScreenHeader: (props: { readonly title: string }) => <h1>{props.title}</h1>,
+}));
+vi.mock("./WorkspaceAppBar.android", () => ({
+ useHasWorkspaceAppBar: () => false,
+ WorkspaceAppBar: () => null,
+}));
+vi.mock("./Menu", () => ({ Menu: (props: { readonly children?: ReactNode }) => props.children }));
+vi.mock("./ScreenHeaderButton.android", () => ({ ScreenHeaderButton: () => null }));
+vi.mock("./SearchField", () => ({ SearchField: () => null }));
+vi.mock("./useToolbarLayout", () => ({
+ useToolbarLayout: () => ({ height: 48, paddingTop: 0, paddingBottom: 0 }),
+}));
+vi.mock("../../native/StackHeader", () => ({ NativeStackScreenOptions: () => null }));
+vi.mock("../../features/layout/workspace-sidebar-toolbar", () => ({
+ AndroidWorkspaceSidebarButton: () => null,
+}));
+vi.mock("../../features/settings/appearance/AppearancePreferencesProvider", () => ({
+ useAppearancePreferences: () => ({ themeVariables: {} }),
+}));
+
+import { AppBar } from "./AppBar.android";
+
+const roots: Root[] = [];
+
+afterEach(() => {
+ for (const root of roots.splice(0)) act(() => root.unmount());
+ document.body.innerHTML = "";
+});
+
+it("renders a sheet bar without search outside a navigation container", () => {
+ vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
+ const container = document.createElement("div");
+ document.body.append(container);
+ const root = createRoot(container);
+ roots.push(root);
+
+ act(() => root.render(<AppBar sheet sidebar={false} title="Arrange threads" />));
+
+ expect(container.textContent).toBe("Arrange threads");
+});
diff --git a/apps/mobile/src/components/ui/AppBar.android.tsx b/apps/mobile/src/components/ui/AppBar.android.tsx
index d156b7ef064..37b67d0305e 100644
--- a/apps/mobile/src/components/ui/AppBar.android.tsx
+++ b/apps/mobile/src/components/ui/AppBar.android.tsx
@@ -1,5 +1,5 @@
-import { useRef, useState } from "react";
-import { Keyboard, Pressable, TextInput, type TextInputInstance, View } from "react-native";
+import { type RefObject, useRef, useState } from "react";
+import { Keyboard, type TextInputInstance, View } from "react-native";
import { useHardwareBack } from "../../lib/backHandler";
import { useToolbarLayout } from "./useToolbarLayout";
import { NativeStackScreenOptions } from "../../native/StackHeader";
@@ -7,155 +7,166 @@ import { AndroidWorkspaceSidebarButton } from "../../features/layout/workspace-s
import { useAppearancePreferences } from "../../features/settings/appearance/AppearancePreferencesProvider";
import { AndroidScreenHeader } from "./AndroidScreenHeader";
import { ScreenHeaderButton } from "./ScreenHeaderButton.android";
-import { SymbolView } from "./AppSymbol";
import { Menu } from "./Menu";
import { SearchField } from "./SearchField";
import { androidHeaderMenuActions, findHeaderMenuAction } from "./headerMenu.android";
-import type { AppBarProps } from "./AppBar.types";
-import { useAndroidControlSizing } from "./useAndroidControlSizing";
+import type { AppBarMenuItem, AppBarProps, AppBarSearch } from "./AppBar.types";
+import { useHasWorkspaceAppBar, WorkspaceAppBar } from "./WorkspaceAppBar.android";
+
+function selectMenuItem(items: ReadonlyArray<AppBarMenuItem>, id: string) {
+ const action = findHeaderMenuAction(items, id);
+ if (action && !action.disabled) action.onPress();
+}
+
+interface SearchState {
+ readonly searching: boolean;
+ readonly open: () => void;
+ readonly close: () => void;
+ readonly inputRef: RefObject<TextInputInstance | null>;
+}
export function AppBar(props: AppBarProps) {
+ return props.search ? (
+ <SearchableAppBar {...props} search={props.search} />
+ ) : (
+ <AppBarView {...props} />
+ );
+}
+
+// Only a bar with search registers for hardware back: its focus check needs a navigation
+// context, and sheet headers such as Arrange threads render outside one.
+function SearchableAppBar(props: AppBarProps & { readonly search: AppBarSearch }) {
const { search } = props;
- const { paddingTop, paddingBottom } = useToolbarLayout();
- const { scale, buttonSize, iconSize, smallIconSize } = useAndroidControlSizing();
- const { themeVariables } = useAppearancePreferences();
- const inputRef = useRef<TextInputInstance>(null);
const [searchOpen, setSearchOpen] = useState(false);
- const searching = search !== undefined && (searchOpen || search.value.length > 0);
- const onSearchChange = search?.onChangeText;
- const closeSearch = () => {
- onSearchChange?.("");
- setSearchOpen(false);
- Keyboard.dismiss();
+ const inputRef = useRef<TextInputInstance>(null);
+ const inline = search.mode === "inline";
+ const controlled = search.active !== undefined;
+ const searching =
+ inline || (controlled ? search.active === true : searchOpen || search.value.length > 0);
+ const open = () => {
+ if (!controlled) setSearchOpen(true);
+ search.onOpen?.();
+ inputRef.current?.focus();
};
- useHardwareBack(searching && search?.mode !== "inline", () => {
- closeSearch();
+ const close = () => {
+ if (!controlled) {
+ search.onChangeText("");
+ setSearchOpen(false);
+ Keyboard.dismiss();
+ }
+ search.onClose?.();
+ };
+ useHardwareBack(searching && !inline && !controlled, () => {
+ close();
return true;
});
+ return <AppBarView {...props} searchState={{ searching, open, close, inputRef }} />;
+}
+
+function AppBarView(props: AppBarProps & { readonly searchState?: SearchState }) {
+ const { search, searchState } = props;
+ const { paddingTop, paddingBottom } = useToolbarLayout(props.sheet);
+ const { themeVariables } = useAppearancePreferences();
+ const inWorkspace = useHasWorkspaceAppBar();
+ const inline = search?.mode === "inline";
+ const searching = searchState?.searching === true;
+ const openSearch = () => searchState?.open();
+ const closeSearch = () => searchState?.close();
+
+ const searchLabel = search?.accessibilityLabel ?? search?.placeholder ?? "";
+ const searchField =
+ search && searchState ? (
+ <SearchField
+ inputRef={searchState.inputRef}
+ accessibilityLabel={searchLabel}
+ clearAccessibilityLabel={search.clearAccessibilityLabel ?? "Clear search"}
+ placeholder={
+ search.compactToolbar
+ ? (search.compactPlaceholder ?? search.placeholder)
+ : search.placeholder
+ }
+ value={search.value}
+ onChangeText={search.onChangeText}
+ autoFocus={!inline}
+ />
+ ) : null;
+
+ if (inWorkspace) {
+ const menu = props.menus?.[0];
+ const icon = typeof menu?.icon === "string" ? menu.icon : menu?.icon.android;
+ return (
+ <WorkspaceAppBar
+ title={props.title}
+ titleContent={props.titleContent}
+ search={
+ search
+ ? {
+ accessibilityLabel: searchLabel,
+ active: searching,
+ field: searchField,
+ onOpen: openSearch,
+ onClose: closeSearch,
+ }
+ : undefined
+ }
+ filter={
+ menu
+ ? {
+ accessibilityLabel: menu.title,
+ customized: icon?.endsWith(".fill") === true,
+ actions: androidHeaderMenuActions(menu.items),
+ onSelect: (id) => selectMenuItem(menu.items, id),
+ }
+ : undefined
+ }
+ />
+ );
+ }
+
const menuView = props.menus?.map((menu) => (
<Menu
key={menu.title}
actions={androidHeaderMenuActions(menu.items)}
isAnchoredToRight
title={menu.status ?? menu.title}
- onPressAction={({ nativeEvent }) => {
- const action = findHeaderMenuAction(menu.items, nativeEvent.event);
- if (action && !action.disabled) action.onPress();
- }}
+ onPressAction={({ nativeEvent }) => selectMenuItem(menu.items, nativeEvent.event)}
>
- {search?.mode === "inline" ? (
- <Pressable
- accessibilityLabel={menu.title}
- accessibilityRole="button"
- className="items-center justify-center rounded-full bg-subtle"
- style={{ width: buttonSize, height: buttonSize }}
- >
- <SymbolView
- name={menu.icon}
- size={smallIconSize}
- tintColorClassName="accent-header-foreground"
- type="monochrome"
- />
- </Pressable>
- ) : (
- <ScreenHeaderButton accessibilityLabel={menu.title} icon={menu.icon} />
- )}
+ <ScreenHeaderButton accessibilityLabel={menu.title} icon={menu.icon} />
</Menu>
));
- const options = (
- <NativeStackScreenOptions
- options={{
- ...props.options,
- ...(props.matchSearchSurface
- ? { contentStyle: { backgroundColor: themeVariables["--color-header"] } }
- : undefined),
- headerShown: false,
- title: props.title,
- }}
- optionsVersion={props.optionsVersion}
- />
- );
- if (search?.mode === "inline") {
- return (
- <>
- {options}
- <View
- className="border-b border-header-border bg-header px-3"
- style={{
- paddingTop,
- paddingBottom: 8.75 * scale,
- borderBottomWidth: 0,
- }}
- >
- <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="items-center justify-center"
- style={{ width: buttonSize, height: buttonSize }}
- >
- <SymbolView
- name="chevron.left"
- size={iconSize}
- tintColorClassName="accent-header-foreground"
- type="monochrome"
- />
- </Pressable>
- ) : null}
- <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={Math.round(17 * scale)}
- tintColorClassName="accent-header-foreground"
- type="monochrome"
- />
- <TextInput
- accessibilityLabel={search.placeholder}
- autoCapitalize="none"
- onChangeText={search.onChangeText}
- value={search.value}
- placeholder={
- search.compactToolbar
- ? (search.compactPlaceholder ?? search.placeholder)
- : search.placeholder
- }
- placeholderTextColorClassName="accent-placeholder"
- className="flex-1 text-base font-sans text-header-foreground"
- style={{ paddingVertical: 7 * scale }}
- />
- </View>
- {menuView}
- </View>
- </View>
- </>
+ const options =
+ props.embedded || props.sheet ? null : (
+ <NativeStackScreenOptions
+ options={{
+ ...props.options,
+ ...(props.matchSearchSurface
+ ? { contentStyle: { backgroundColor: themeVariables["--color-header"] } }
+ : undefined),
+ headerShown: false,
+ title: props.title,
+ }}
+ optionsVersion={props.optionsVersion}
+ />
);
- }
const header = (
<AndroidScreenHeader
title={props.title}
+ titleContent={props.titleContent}
subtitle={props.subtitle}
onBack={props.onBack}
- leading={props.sidebar !== false ? <AndroidWorkspaceSidebarButton /> : undefined}
+ leading={
+ props.leading ?? (props.sidebar !== false ? <AndroidWorkspaceSidebarButton /> : undefined)
+ }
+ embedded={props.sheet}
hideBottomBorder={props.hideBottomBorder}
compact={props.compact}
actions={
- search
+ search && !inline
? [
{
- accessibilityLabel: search.placeholder,
+ accessibilityLabel: searchLabel,
icon: "magnifyingglass",
- onPress: () => setSearchOpen(true),
+ onPress: openSearch,
},
...(search.refreshInToolbar && search.onRefresh
? [
@@ -180,46 +191,54 @@ export function AppBar(props: AppBarProps) {
}
/>
);
+ if (!search) {
+ return (
+ <>
+ {options}
+ {header}
+ </>
+ );
+ }
return (
<>
{options}
- {search ? (
- <View>
+ <View>
+ <View
+ pointerEvents={searching ? "none" : "auto"}
+ accessibilityElementsHidden={searching}
+ importantForAccessibility={searching ? "no-hide-descendants" : "auto"}
+ style={{ opacity: searching ? 0 : 1 }}
+ >
+ {header}
+ </View>
+ {searching ? (
<View
- pointerEvents={searching ? "none" : "auto"}
- accessibilityElementsHidden={searching}
- importantForAccessibility={searching ? "no-hide-descendants" : "auto"}
- style={{ opacity: searching ? 0 : 1 }}
+ className="absolute inset-0 bg-header"
+ // Match Material TopAppBar's 4dp icon inset so buttons stay where the bar drew them.
+ style={{ paddingTop, paddingBottom, paddingHorizontal: 4 }}
>
- {header}
- </View>
- {searching ? (
- <View
- className="absolute inset-0 bg-header"
- // Match Material TopAppBar's navigation inset so the back button stays put.
- style={{ paddingTop, paddingBottom, paddingHorizontal: 4 }}
- >
- <View className="flex-1 flex-row items-center gap-1">
+ <View className="flex-1 flex-row items-center gap-1">
+ {inline ? (
+ props.onBack ? (
+ <ScreenHeaderButton
+ accessibilityLabel="Navigate up"
+ icon="arrow.left"
+ onPress={props.onBack}
+ />
+ ) : null
+ ) : (
<ScreenHeaderButton
accessibilityLabel={search.closeAccessibilityLabel ?? "Close search"}
icon="arrow.left"
onPress={closeSearch}
/>
- <SearchField
- inputRef={inputRef}
- accessibilityLabel={search.placeholder}
- clearAccessibilityLabel={search.clearAccessibilityLabel ?? "Clear search"}
- placeholder={search.placeholder}
- value={search.value}
- onChangeText={search.onChangeText}
- />
- </View>
+ )}
+ {searchField}
+ {inline ? menuView : null}
</View>
- ) : null}
- </View>
- ) : (
- header
- )}
+ </View>
+ ) : null}
+ </View>
</>
);
}
diff --git a/apps/mobile/src/components/ui/AppBar.tsx b/apps/mobile/src/components/ui/AppBar.tsx
index 28372261c57..e8d42fffdfb 100644
--- a/apps/mobile/src/components/ui/AppBar.tsx
+++ b/apps/mobile/src/components/ui/AppBar.tsx
@@ -52,6 +52,7 @@ export function AppBar(props: AppBarProps) {
usesNativeMailSearchToolbar;
const visibleMenus = compactSearch ? (menus?.slice(1) ?? []) : (menus ?? []);
const refresh = search?.refreshInToolbar ? search.onRefresh : undefined;
+ if (props.embedded || props.sheet) return null;
return (
<>
<NativeStackScreenOptions
diff --git a/apps/mobile/src/components/ui/AppBar.types.ts b/apps/mobile/src/components/ui/AppBar.types.ts
index e3db494219d..a83c6cd8acf 100644
--- a/apps/mobile/src/components/ui/AppBar.types.ts
+++ b/apps/mobile/src/components/ui/AppBar.types.ts
@@ -11,6 +11,11 @@ export interface AppBarAction {
readonly loading?: boolean;
readonly selected?: boolean;
readonly tintColor?: ColorValue;
+ /** Android overflow menu: the row's second line. */
+ readonly subtitle?: string;
+ readonly destructive?: boolean;
+ /** Android: always in the overflow menu, never a toolbar button. */
+ readonly overflowOnly?: boolean;
}
export type AppBarMenuItem =
@@ -18,6 +23,8 @@ export type AppBarMenuItem =
readonly id: string;
readonly title: string;
readonly icon?: string;
+ /** Android: tints the icon, such as a label's color dot. */
+ readonly iconColor?: ColorValue;
readonly subtitle?: string;
readonly disabled?: boolean;
readonly selected?: boolean;
@@ -43,6 +50,8 @@ export interface AppBarSearch {
readonly value: string;
readonly onChangeText: (value: string) => void;
readonly placeholder: string;
+ /** Defaults to the placeholder. */
+ readonly accessibilityLabel?: string;
readonly mode?: "inline" | "collapsible";
readonly compactToolbar?: boolean;
readonly compactPlaceholder?: string;
@@ -51,16 +60,28 @@ export interface AppBarSearch {
readonly onRefresh?: () => void;
readonly refreshAccessibilityLabel?: string;
readonly refreshInToolbar?: boolean;
+ /** Controlled open state. The owner then also handles back and the keyboard shortcut. */
+ readonly active?: boolean;
+ readonly onOpen?: () => void;
+ readonly onClose?: () => void;
}
export interface AppBarProps {
readonly title: string;
- readonly subtitle?: string;
+ /** Android: replaces the title text, such as the brand title. iOS ignores it. */
+ readonly titleContent?: ReactNode;
+ readonly subtitle?: string | null;
readonly actions?: ReadonlyArray<AppBarAction>;
readonly menus?: ReadonlyArray<AppBarMenu>;
readonly search?: AppBarSearch;
readonly onBack?: () => void;
readonly sidebar?: boolean;
+ /** Android: replaces the sidebar button at the start of the bar. */
+ readonly leading?: ReactNode;
+ /** Leaves route options to the screen: in-screen bars, and screens that set their own. iOS draws nothing. */
+ readonly embedded?: boolean;
+ /** An embedded bar at the top of a sheet. */
+ readonly sheet?: boolean;
readonly backInSplitView?: {
readonly accessibilityLabel: string;
readonly icon: string;
diff --git a/apps/mobile/src/components/ui/NativeAppBar.android.tsx b/apps/mobile/src/components/ui/NativeAppBar.android.tsx
index 22f8ca65cc4..15a6987ffba 100644
--- a/apps/mobile/src/components/ui/NativeAppBar.android.tsx
+++ b/apps/mobile/src/components/ui/NativeAppBar.android.tsx
@@ -10,6 +10,8 @@ export function NativeAppBar(props: {
readonly title: ReactElement;
readonly navigationIcon?: ReactElement;
readonly actions?: ReactElement;
+ /** Compose nodes laid out by the bar itself, so they never wait on a React Native measure. */
+ readonly nativeActions?: ReactElement;
/** Shorter bar for a one-row title. */
readonly singleLine?: boolean;
}) {
@@ -36,9 +38,10 @@ export function NativeAppBar(props: {
<RNHostView matchContents>{props.navigationIcon}</RNHostView>
</TopAppBar.NavigationIcon>
) : null}
- {props.actions ? (
+ {props.actions || props.nativeActions ? (
<TopAppBar.Actions>
- <RNHostView matchContents>{props.actions}</RNHostView>
+ {props.nativeActions}
+ {props.actions ? <RNHostView matchContents>{props.actions}</RNHostView> : null}
</TopAppBar.Actions>
) : null}
</TopAppBar>
diff --git a/apps/mobile/src/components/ui/Sheet.android.tsx b/apps/mobile/src/components/ui/Sheet.android.tsx
index aaafffb8013..5a193938ae5 100644
--- a/apps/mobile/src/components/ui/Sheet.android.tsx
+++ b/apps/mobile/src/components/ui/Sheet.android.tsx
@@ -2,7 +2,7 @@ import { useState } from "react";
import { View } from "react-native";
import { FormSheet } from "react-native-screens";
import { useResolveClassNames } from "uniwind";
-import { AndroidSheetHeader } from "./AndroidScreenHeader";
+import { AppBar } from "./AppBar";
import { RoutedFormSheetContext } from "./RoutedFormSheetContext";
import { ScreenContent } from "./ScreenContent";
import type { SheetProps } from "./Sheet.types";
@@ -24,7 +24,9 @@ export function Sheet(props: SheetProps) {
{/* Android FormSheet does not bound flex children. Material drags target the first scroll view, so place content before the header. */}
<View collapsable={false} className="absolute inset-0 flex-col-reverse bg-header">
<ScreenContent>{props.children}</ScreenContent>
- <AndroidSheetHeader
+ <AppBar
+ sheet
+ sidebar={false}
title={props.title}
onBack={() => setIsOpen(false)}
hideBottomBorder
diff --git a/apps/mobile/src/components/ui/SheetHeader.android.tsx b/apps/mobile/src/components/ui/SheetHeader.android.tsx
index e56c835365e..da55cc88c22 100644
--- a/apps/mobile/src/components/ui/SheetHeader.android.tsx
+++ b/apps/mobile/src/components/ui/SheetHeader.android.tsx
@@ -1,6 +1,6 @@
import { View } from "react-native";
-import { AndroidScreenHeader } from "./AndroidScreenHeader";
+import { AppBar } from "./AppBar";
import { Button } from "./Button";
import { IconButton } from "./IconButton";
import type { SheetCloseButtonProps, SheetHeaderProps } from "./SheetHeader.types";
@@ -36,8 +36,10 @@ export function SheetHeader(props: SheetHeaderProps) {
) : undefined;
return (
- <AndroidScreenHeader
- embedded={props.presentation === "inline"}
+ <AppBar
+ embedded
+ sheet={props.presentation === "inline"}
+ sidebar={false}
title={props.title}
subtitle={props.subtitle}
leading={
diff --git a/apps/mobile/src/components/ui/WorkspaceAppBar.android.tsx b/apps/mobile/src/components/ui/WorkspaceAppBar.android.tsx
new file mode 100644
index 00000000000..5a6fed51e5d
--- /dev/null
+++ b/apps/mobile/src/components/ui/WorkspaceAppBar.android.tsx
@@ -0,0 +1,233 @@
+import { Box, Icon, IconButton, RNHostView } from "@expo/ui/jetpack-compose";
+import { size } from "@expo/ui/jetpack-compose/modifiers";
+import type { MenuAction } from "@react-native-menu/menu";
+import {
+ createContext,
+ use,
+ useLayoutEffect,
+ useState,
+ useSyncExternalStore,
+ type ReactNode,
+} from "react";
+import { Pressable, View } from "react-native";
+
+import { AndroidAnchoredMenu } from "./AndroidAnchoredMenu";
+import { AndroidHeaderIconButton } from "./AndroidScreenHeader";
+import { AppText } from "./AppText";
+import { NativeAppBar } from "./NativeAppBar.android";
+import { useControlTheme } from "./useControlTheme";
+import { useToolbarLayout } from "./useToolbarLayout";
+
+const SEARCH_ICON = require("../../../assets/icons/search.xml");
+const FILTER_ICON = require("../../../assets/icons/filter.xml");
+const FILTER_FILLED_ICON = require("../../../assets/icons/filter-filled.xml");
+// Material TopAppBar: 48dp icon buttons, the last one 4dp from the end.
+const ACTION_SIZE = 48;
+const ACTION_END_INSET = 4;
+
+export interface WorkspaceAppBarProps {
+ readonly title: string;
+ readonly titleContent?: ReactNode;
+ readonly search?: {
+ readonly accessibilityLabel: string;
+ readonly active: boolean;
+ readonly field: ReactNode;
+ readonly onOpen: () => void;
+ readonly onClose: () => void;
+ };
+ /** Stays trailing while searching, so it never moves and still narrows the results. */
+ readonly filter?: {
+ readonly accessibilityLabel: string;
+ readonly customized: boolean;
+ readonly actions: MenuAction[];
+ readonly onSelect: (id: string) => void;
+ };
+}
+
+function createWorkspaceAppBarStore() {
+ let owner: object | null = null;
+ let content: WorkspaceAppBarProps | null = null;
+ const listeners = new Set<() => void>();
+ const emit = () => {
+ for (const listener of listeners) listener();
+ };
+ return {
+ subscribe: (listener: () => void) => {
+ listeners.add(listener);
+ return () => {
+ listeners.delete(listener);
+ };
+ },
+ get: () => content,
+ set: (nextOwner: object, next: WorkspaceAppBarProps) => {
+ owner = nextOwner;
+ content = next;
+ emit();
+ },
+ clear: (previousOwner: object) => {
+ if (owner !== previousOwner) return;
+ owner = null;
+ content = null;
+ emit();
+ },
+ };
+}
+
+const WorkspaceAppBarStoreContext = createContext<ReturnType<
+ typeof createWorkspaceAppBarStore
+> | null>(null);
+
+/**
+ * Hosts one app bar above a set of workspace tab panes. Hidden panes lay out at zero size, and a
+ * Compose bar inside one takes frames to measure again when it returns, so the bar lives here and
+ * the visible tab projects its contents into it.
+ */
+export function WorkspaceAppBarScope(props: {
+ readonly children: ReactNode;
+ /** Off, panes draw their own bars; the children keep their place so toggling keeps their state. */
+ readonly enabled?: boolean;
+}) {
+ const [store] = useState(createWorkspaceAppBarStore);
+ const enabled = props.enabled ?? true;
+ return (
+ <WorkspaceAppBarStoreContext value={enabled ? store : null}>
+ {enabled ? <WorkspaceAppBarHost /> : null}
+ {props.children}
+ </WorkspaceAppBarStoreContext>
+ );
+}
+
+function WorkspaceAppBarHost() {
+ const store = use(WorkspaceAppBarStoreContext)!;
+ const content = useSyncExternalStore(store.subscribe, store.get, store.get);
+ return <WorkspaceAppBarView {...(content ?? { title: "" })} />;
+}
+
+export function useHasWorkspaceAppBar() {
+ return use(WorkspaceAppBarStoreContext) !== null;
+}
+
+/** Shows a tab's header in the enclosing scope's bar, or inline outside one. */
+export function WorkspaceAppBar(props: WorkspaceAppBarProps) {
+ const store = use(WorkspaceAppBarStoreContext);
+ const [owner] = useState(() => ({}));
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- projects this tab's header into the out-of-tree workspace bar after every commit
+ useLayoutEffect(() => {
+ store?.set(owner, props);
+ });
+ // Hidden panes destroy their effects, so the tab leaving the screen releases the bar.
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- releases the workspace bar when this tab hides or unmounts
+ useLayoutEffect(() => (store ? () => store.clear(owner) : undefined), [store, owner]);
+ return store ? null : <WorkspaceAppBarView {...props} />;
+}
+
+/**
+ * Every tab draws the same bar, so a switch only changes its contents. The actions are Compose nodes
+ * and the title host keeps one height: React Native content hosted in Compose lags Compose's layout
+ * by a frame whenever its size changes, which showed as the filter jumping between tabs.
+ */
+function WorkspaceAppBarView(props: WorkspaceAppBarProps) {
+ const { search, filter } = props;
+ const searching = search?.active === true;
+ const { colors } = useControlTheme();
+ const tint = colors["--color-header-foreground"];
+ const { height, paddingTop, paddingBottom } = useToolbarLayout();
+ const filterMenu = filter ? (
+ <AndroidAnchoredMenu
+ actions={filter.actions}
+ onPressAction={({ nativeEvent }) => filter.onSelect(nativeEvent.event)}
+ >
+ {(open) =>
+ searching ? (
+ <AndroidHeaderIconButton
+ accessibilityLabel={filter.accessibilityLabel}
+ icon={
+ filter.customized
+ ? "line.3.horizontal.decrease.circle.fill"
+ : "line.3.horizontal.decrease.circle"
+ }
+ onPress={open}
+ />
+ ) : (
+ // The bar draws the icon; this takes the touch so the menu can anchor to the slot.
+ <Pressable
+ accessibilityLabel={filter.accessibilityLabel}
+ accessibilityRole="button"
+ android_ripple={{ borderless: true, radius: 20 }}
+ onPress={open}
+ style={{ width: ACTION_SIZE, height: ACTION_SIZE }}
+ />
+ )
+ }
+ </AndroidAnchoredMenu>
+ ) : null;
+ return (
+ <View className="bg-header" style={{ paddingTop, paddingBottom }}>
+ <View
+ pointerEvents={searching ? "none" : "auto"}
+ accessibilityElementsHidden={searching}
+ importantForAccessibility={searching ? "no-hide-descendants" : "auto"}
+ style={{ opacity: searching ? 0 : 1 }}
+ >
+ <NativeAppBar
+ title={
+ <RNHostView matchContents={{ vertical: true }}>
+ <View collapsable={false} className="justify-center" style={{ height: ACTION_SIZE }}>
+ {props.titleContent ?? (
+ <AppText textRole="title" numberOfLines={1} className="text-header-foreground">
+ {props.title}
+ </AppText>
+ )}
+ </View>
+ </RNHostView>
+ }
+ // Both slots always exist: Expo UI applies a child insert or removal a frame before the
+ // other children's new props, so changing the slot count drew the wrong glyph mid-switch.
+ nativeActions={
+ <>
+ <IconButton enabled={search !== undefined} onClick={search?.onOpen}>
+ <Icon
+ source={SEARCH_ICON}
+ size={24}
+ tint={search ? tint : "transparent"}
+ contentDescription={search?.accessibilityLabel}
+ />
+ </IconButton>
+ <Box contentAlignment="center" modifiers={[size(ACTION_SIZE, ACTION_SIZE)]}>
+ <Icon
+ source={filter?.customized ? FILTER_FILLED_ICON : FILTER_ICON}
+ size={24}
+ tint={filter ? tint : "transparent"}
+ />
+ </Box>
+ </>
+ }
+ />
+ {filter && !searching ? (
+ <View
+ className="absolute"
+ style={{ right: ACTION_END_INSET, top: (height - ACTION_SIZE) / 2 }}
+ >
+ {filterMenu}
+ </View>
+ ) : null}
+ </View>
+ {searching ? (
+ <View
+ className="absolute inset-0 bg-header"
+ style={{ paddingTop, paddingBottom, paddingHorizontal: ACTION_END_INSET }}
+ >
+ <View className="flex-1 flex-row items-center gap-1">
+ <AndroidHeaderIconButton
+ accessibilityLabel="Close search"
+ icon="arrow.left"
+ onPress={search.onClose}
+ />
+ {search.field}
+ {filterMenu}
+ </View>
+ </View>
+ ) : null}
+ </View>
+ );
+}
diff --git a/apps/mobile/src/components/ui/headerMenu.android.ts b/apps/mobile/src/components/ui/headerMenu.android.ts
index b47c4fb96a4..1fe463b936f 100644
--- a/apps/mobile/src/components/ui/headerMenu.android.ts
+++ b/apps/mobile/src/components/ui/headerMenu.android.ts
@@ -20,6 +20,7 @@ export function androidHeaderMenuActions(items: ReadonlyArray<AppBarMenuItem>):
title: item.title,
subtitle: item.subtitle,
image: item.icon,
+ imageColor: item.iconColor,
state: item.selected ? "on" : undefined,
attributes: item.disabled ? { disabled: true } : undefined,
},
diff --git a/apps/mobile/src/components/ui/menuActionItems.test.ts b/apps/mobile/src/components/ui/menuActionItems.test.ts
new file mode 100644
index 00000000000..0e5a73dc831
--- /dev/null
+++ b/apps/mobile/src/components/ui/menuActionItems.test.ts
@@ -0,0 +1,59 @@
+import type { MenuAction } from "@react-native-menu/menu";
+import { describe, expect, it, vi } from "vite-plus/test";
+
+import { androidHeaderMenuActions, findHeaderMenuAction } from "./headerMenu.android";
+import { appBarMenuItemsFromActions } from "./menuActionItems";
+
+describe("appBarMenuItemsFromActions", () => {
+ it("round-trips a filter menu through AppBar items back to Android actions", () => {
+ const actions: MenuAction[] = [
+ {
+ id: "labels",
+ title: "Labels",
+ subactions: [
+ {
+ id: "label:bug",
+ title: "bug",
+ image: "circle.fill",
+ imageColor: "#d73a4a",
+ state: "on",
+ },
+ { id: "label:docs", title: "docs", subtitle: "3 open", state: "off" },
+ ],
+ },
+ ];
+ const onSelect = vi.fn();
+
+ const items = appBarMenuItemsFromActions(actions, onSelect);
+
+ expect(androidHeaderMenuActions(items)).toEqual([
+ {
+ id: "labels",
+ title: "Labels",
+ image: undefined,
+ subactions: [
+ {
+ id: "label:bug",
+ title: "bug",
+ subtitle: undefined,
+ image: "circle.fill",
+ imageColor: "#d73a4a",
+ state: "on",
+ attributes: undefined,
+ },
+ {
+ id: "label:docs",
+ title: "docs",
+ subtitle: "3 open",
+ image: undefined,
+ imageColor: undefined,
+ state: undefined,
+ attributes: undefined,
+ },
+ ],
+ },
+ ]);
+ findHeaderMenuAction(items, "label:docs")?.onPress();
+ expect(onSelect).toHaveBeenCalledWith("label:docs");
+ });
+});
diff --git a/apps/mobile/src/components/ui/menuActionItems.ts b/apps/mobile/src/components/ui/menuActionItems.ts
new file mode 100644
index 00000000000..b2687260938
--- /dev/null
+++ b/apps/mobile/src/components/ui/menuActionItems.ts
@@ -0,0 +1,29 @@
+import type { MenuAction } from "@react-native-menu/menu";
+import type { AppBarMenuItem } from "./AppBar.types";
+
+/** Adapts a `MenuAction` tree and its selection handler to `AppBar` menu items. */
+export function appBarMenuItemsFromActions(
+ actions: ReadonlyArray<MenuAction>,
+ onSelect: (id: string) => void,
+): AppBarMenuItem[] {
+ return actions.map((action, index) => {
+ const id = action.id ?? String(index);
+ return action.subactions?.length
+ ? {
+ id,
+ title: action.title,
+ icon: action.image,
+ items: appBarMenuItemsFromActions(action.subactions, onSelect),
+ }
+ : {
+ id,
+ title: action.title,
+ subtitle: action.subtitle,
+ icon: action.image,
+ iconColor: action.imageColor,
+ selected: action.state === "on",
+ disabled: action.attributes?.disabled,
+ onPress: () => onSelect(id),
+ };
+ });
+}
diff --git a/apps/mobile/src/features/connection/ConnectionsRouteScreen.tsx b/apps/mobile/src/features/connection/ConnectionsRouteScreen.tsx
index bac5e09721d..2021bb134e3 100644
--- a/apps/mobile/src/features/connection/ConnectionsRouteScreen.tsx
+++ b/apps/mobile/src/features/connection/ConnectionsRouteScreen.tsx
@@ -7,7 +7,7 @@ import { useState } from "react";
import { Platform, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { useRemoteConnections } from "../../state/use-remote-environment-registry";
import { LocalEnvironmentList } from "./LocalEnvironmentList";
import { PullRequestRoutingSettings } from "./PullRequestRoutingSettings";
@@ -31,7 +31,9 @@ export function ConnectionsRouteScreen() {
return (
<View collapsable={false} className="flex-1 bg-sheet">
{Platform.OS === "android" ? (
- <AndroidScreenHeader
+ <AppBar
+ embedded
+ sidebar={false}
title="Environments"
onBack={() => navigation.goBack()}
actions={[
diff --git a/apps/mobile/src/features/files/AttachmentFileScreen.tsx b/apps/mobile/src/features/files/AttachmentFileScreen.tsx
index a1d3978a57d..ab709a5c512 100644
--- a/apps/mobile/src/features/files/AttachmentFileScreen.tsx
+++ b/apps/mobile/src/features/files/AttachmentFileScreen.tsx
@@ -11,10 +11,8 @@ import {
import { useRef, useState } from "react";
import { Platform, View } from "react-native";
-import {
- AndroidHeaderIconButton,
- AndroidScreenHeader,
-} from "../../components/ui/AndroidScreenHeader";
+import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { Menu } from "../../components/ui/Menu";
import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
import { useAttachmentDocument } from "../../lib/attachmentDocument";
@@ -241,7 +239,9 @@ export function AttachmentFileScreen(props: AttachmentFileScreenProps) {
}}
/>
{isAndroid ? (
- <AndroidScreenHeader
+ <AppBar
+ embedded
+ sidebar={false}
title={params.name}
subtitle={subtitle}
onBack={handleBack}
diff --git a/apps/mobile/src/features/files/FilesHeader.tsx b/apps/mobile/src/features/files/FilesHeader.tsx
index b1e8c825572..292ee471639 100644
--- a/apps/mobile/src/features/files/FilesHeader.tsx
+++ b/apps/mobile/src/features/files/FilesHeader.tsx
@@ -1,10 +1,8 @@
import { useRef, useState, type ReactNode } from "react";
import { Keyboard, type TextInputInstance, View } from "react-native";
-import {
- AndroidHeaderIconButton,
- AndroidScreenHeader,
-} from "../../components/ui/AndroidScreenHeader";
+import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";
import { SearchField } from "../../components/ui/SearchField";
import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
@@ -43,7 +41,9 @@ export function FilesHeader(props: {
importantForAccessibility={searching ? "no-hide-descendants" : "auto"}
style={{ opacity: searching ? 0 : 1 }}
>
- <AndroidScreenHeader
+ <AppBar
+ embedded
+ sidebar={false}
title="Files"
subtitle={props.projectName}
hideBottomBorder
diff --git a/apps/mobile/src/features/files/ZipArchiveView.test.tsx b/apps/mobile/src/features/files/ZipArchiveView.test.tsx
index d26b7ecc4f9..d6b1c4740c4 100644
--- a/apps/mobile/src/features/files/ZipArchiveView.test.tsx
+++ b/apps/mobile/src/features/files/ZipArchiveView.test.tsx
@@ -125,7 +125,8 @@ vi.mock("../../components/ui/Toolbar", () => {
}),
};
});
-vi.mock("../../components/ui/AndroidScreenHeader", () => ({ AndroidScreenHeader: () => null }));
+vi.mock("../../components/ui/AppBar", () => ({ AppBar: () => null }));
+vi.mock("../../components/ui/AndroidScreenHeader", () => ({ AndroidHeaderIconButton: () => null }));
vi.mock("../../components/ui/Menu", () => ({ Menu: () => null }));
vi.mock("../../components/ui/AppSymbol", () => ({ SymbolView: () => null }));
vi.mock("../../components/ui/Progress", () => ({ Progress: () => null }));
diff --git a/apps/mobile/src/features/files/ZipArchiveView.tsx b/apps/mobile/src/features/files/ZipArchiveView.tsx
index bb9931d4e3c..629a81d6950 100644
--- a/apps/mobile/src/features/files/ZipArchiveView.tsx
+++ b/apps/mobile/src/features/files/ZipArchiveView.tsx
@@ -20,7 +20,7 @@ import { Keyboard, Platform, Pressable, ScrollView, TextInput, View } from "reac
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { PierreEntryIcon } from "../../components/PierreEntryIcon";
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { SymbolView } from "../../components/ui/AppSymbol";
import { AppText as Text } from "../../components/ui/AppText";
import { Button } from "../../components/ui/Button";
@@ -306,7 +306,9 @@ function ZipArchiveHeader(props: {
}}
/>
{isAndroid ? (
- <AndroidScreenHeader
+ <AppBar
+ embedded
+ sidebar={false}
title={props.name}
subtitle={props.subtitle}
onBack={() => {
@@ -756,7 +758,9 @@ function ZipEntryView(props: {
}}
/>
{isAndroid ? (
- <AndroidScreenHeader
+ <AppBar
+ embedded
+ sidebar={false}
title={entry.name}
subtitle={subtitle}
onBack={props.onBack}
diff --git a/apps/mobile/src/features/home/HomeHeader.android.tsx b/apps/mobile/src/features/home/HomeHeader.android.tsx
index 1d984c2f0fd..70c23920b76 100644
--- a/apps/mobile/src/features/home/HomeHeader.android.tsx
+++ b/apps/mobile/src/features/home/HomeHeader.android.tsx
@@ -90,7 +90,7 @@ export function HomeHeader(props: HomeHeaderProps) {
onSearchQueryChange={props.onSearchQueryChange}
filterActions={menuActions}
filterCustomized={hasCustomListOptions}
- onFilterAction={handleMenuAction}
+ onFilterSelect={(event) => handleMenuAction({ nativeEvent: { event } })}
onOpenEnvironments={props.onOpenEnvironments}
/>
</>
diff --git a/apps/mobile/src/features/home/HomeRouteScreen.tsx b/apps/mobile/src/features/home/HomeRouteScreen.tsx
index c522da701e7..a916e72329c 100644
--- a/apps/mobile/src/features/home/HomeRouteScreen.tsx
+++ b/apps/mobile/src/features/home/HomeRouteScreen.tsx
@@ -24,7 +24,7 @@ import { useSavedRemoteConnections } from "../../state/use-remote-environment-re
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
import { useDeviceType, useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
import { WorkspaceEmptyDetail } from "../layout/WorkspaceEmptyDetail";
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { AndroidHomeFabLayout } from "./AndroidHomeFab";
import { HomeScreen } from "./HomeScreen";
import { HomeHeader } from "./HomeHeader";
@@ -185,7 +185,7 @@ export function HomeRouteScreen() {
/>
</Toolbar>
) : null}
- {Platform.OS === "android" ? <AndroidScreenHeader title="Threads" /> : null}
+ {Platform.OS === "android" ? <AppBar embedded sidebar={false} title="Threads" /> : null}
<WorkspaceEmptyDetail
onAddConnection={
Platform.OS === "android" && !catalogState.hasConnections
diff --git a/apps/mobile/src/features/home/ThreadListToolbar.android.tsx b/apps/mobile/src/features/home/ThreadListToolbar.android.tsx
new file mode 100644
index 00000000000..4a899867011
--- /dev/null
+++ b/apps/mobile/src/features/home/ThreadListToolbar.android.tsx
@@ -0,0 +1,90 @@
+import { useEffect, useState } from "react";
+import { useNavigation, useNavigationState } from "@react-navigation/native";
+import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
+import { BackHandler, Keyboard } from "react-native";
+
+import { AppBar } from "../../components/ui/AppBar";
+import { appBarMenuItemsFromActions } from "../../components/ui/menuActionItems";
+import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
+import { WorkspaceBrandTitle } from "../workspace/WorkspaceBrandTitle";
+import { useWorkspaceConnectionState } from "../../state/workspace";
+import type { ThreadListToolbarProps } from "./ThreadListToolbar.types";
+
+export function ThreadListToolbar(props: ThreadListToolbarProps) {
+ const navigation = useNavigation();
+ const workspace = useWorkspaceTabs();
+ const isTabActive = workspace?.isTabActive;
+ const homeFocused = useNavigationState((state) => state.routes[state.index]?.name === "Home");
+ const listFocused =
+ homeFocused && (workspace === null || workspace.state.selectedTab === "threads");
+ const connectionState = useWorkspaceConnectionState();
+ const { onRequestVisibility, onSearchQueryChange } = props;
+ const [searchOpen, setSearchOpen] = useState(false);
+ const searching = searchOpen || props.searchQuery.length > 0;
+ const openSearch = () => {
+ onRequestVisibility?.();
+ setSearchOpen(true);
+ return true;
+ };
+ useHardwareKeyboardCommand("focusSearch", openSearch);
+
+ const closeSearch = () => {
+ onSearchQueryChange("");
+ setSearchOpen(false);
+ Keyboard.dismiss();
+ };
+
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes to BackHandler while searching to close search on Android back
+ useEffect(() => {
+ if (!searching || !listFocused) return;
+ const subscription = BackHandler.addEventListener("hardwareBackPress", () => {
+ // Frozen Home screens can keep effects alive after a detail route opens.
+ const state = navigation.getState();
+ if (
+ !state ||
+ state.routes[state.index]?.name !== "Home" ||
+ isTabActive?.("threads") === false
+ )
+ return false;
+ if (Keyboard.isVisible()) Keyboard.dismiss();
+ else closeSearch();
+ return true;
+ });
+ return () => subscription.remove();
+ }, [closeSearch, searching, listFocused, navigation, isTabActive]);
+
+ return (
+ <AppBar
+ title="T3 Code"
+ titleContent={
+ <WorkspaceBrandTitle
+ accessibilityLabel="T3 Code, Threads"
+ onOpenEnvironments={props.onOpenEnvironments}
+ />
+ }
+ sidebar={false}
+ search={{
+ value: props.searchQuery,
+ onChangeText: onSearchQueryChange,
+ placeholder: "Search",
+ accessibilityLabel: "Search threads",
+ active: searching,
+ onOpen: openSearch,
+ onClose: closeSearch,
+ }}
+ menus={
+ connectionState.hasConnections
+ ? [
+ {
+ title: "Filter threads",
+ icon: props.filterCustomized
+ ? "line.3.horizontal.decrease.circle.fill"
+ : "line.3.horizontal.decrease.circle",
+ items: appBarMenuItemsFromActions(props.filterActions, props.onFilterSelect),
+ },
+ ]
+ : undefined
+ }
+ />
+ );
+}
diff --git a/apps/mobile/src/features/home/ThreadListToolbar.tsx b/apps/mobile/src/features/home/ThreadListToolbar.tsx
index 9e8c55fd2b5..8ed77bbcaa8 100644
--- a/apps/mobile/src/features/home/ThreadListToolbar.tsx
+++ b/apps/mobile/src/features/home/ThreadListToolbar.tsx
@@ -1,121 +1,6 @@
-import { useEffect, useRef, useState, type ComponentProps } from "react";
-import { useNavigation, useNavigationState } from "@react-navigation/native";
-import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
-import {
- BackHandler,
- Keyboard,
- type TextInputInstance,
- View,
- type LayoutChangeEvent,
-} from "react-native";
-import type { MenuAction } from "@react-native-menu/menu";
+import type { ThreadListToolbarProps } from "./ThreadListToolbar.types";
-import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
-import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";
-import { Menu } from "../../components/ui/Menu";
-import { SearchField } from "../../components/ui/SearchField";
-import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
-import { WorkspaceListToolbarRow } from "../workspace/WorkspaceListToolbarRow";
-import { useWorkspaceConnectionState } from "../../state/workspace";
-import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
-
-export function ThreadListToolbar(props: {
- readonly searchQuery: string;
- readonly onSearchQueryChange: (query: string) => void;
- readonly filterActions: MenuAction[];
- readonly filterCustomized: boolean;
- readonly onFilterAction: NonNullable<ComponentProps<typeof Menu>["onPressAction"]>;
- readonly onOpenEnvironments: () => void;
- readonly sidebar?: boolean;
- readonly onLayout?: (event: LayoutChangeEvent) => void;
- readonly onRequestVisibility?: () => void;
-}) {
- const navigation = useNavigation();
- const workspace = useWorkspaceTabs();
- const isTabActive = workspace?.isTabActive;
- const homeFocused = useNavigationState((state) => state.routes[state.index]?.name === "Home");
- const listFocused =
- homeFocused && (workspace === null || workspace.state.selectedTab === "threads");
- const { paddingTop, paddingBottom } = useToolbarLayout();
- const connectionState = useWorkspaceConnectionState();
- const { onRequestVisibility, onSearchQueryChange } = props;
- const searchRef = useRef<TextInputInstance>(null);
- const [searchOpen, setSearchOpen] = useState(false);
- const searching = searchOpen || props.searchQuery.length > 0;
- const openSearch = () => {
- onRequestVisibility?.();
- setSearchOpen(true);
- searchRef.current?.focus();
- return true;
- };
- useHardwareKeyboardCommand("focusSearch", openSearch);
-
- const closeSearch = () => {
- onSearchQueryChange("");
- setSearchOpen(false);
- Keyboard.dismiss();
- };
-
- // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes to BackHandler while searching to close search on Android back
- useEffect(() => {
- if (!searching || !listFocused) return;
- const subscription = BackHandler.addEventListener("hardwareBackPress", () => {
- // Frozen Home screens can keep effects alive after a detail route opens.
- const state = navigation.getState();
- if (
- !state ||
- state.routes[state.index]?.name !== "Home" ||
- isTabActive?.("threads") === false
- )
- return false;
- if (Keyboard.isVisible()) Keyboard.dismiss();
- else closeSearch();
- return true;
- });
- return () => subscription.remove();
- }, [closeSearch, searching, listFocused, navigation, isTabActive]);
-
- const filterIcon = props.filterCustomized
- ? "line.3.horizontal.decrease.circle.fill"
- : "line.3.horizontal.decrease.circle";
- const searchField = (
- <SearchField
- inputRef={searchRef}
- accessibilityLabel="Search threads"
- clearAccessibilityLabel="Clear search"
- placeholder="Search"
- value={props.searchQuery}
- onChangeText={onSearchQueryChange}
- />
- );
- const filterButton = connectionState.hasConnections ? (
- <AndroidAnchoredMenu actions={props.filterActions} onPressAction={props.onFilterAction}>
- {(open) => (
- <AndroidHeaderIconButton
- accessibilityLabel="Filter threads"
- icon={filterIcon}
- onPress={open}
- />
- )}
- </AndroidAnchoredMenu>
- ) : null;
-
- return (
- <View
- onLayout={props.onLayout}
- className={props.sidebar ? "absolute inset-x-0 top-0 z-[4] bg-header px-2" : "bg-header px-2"}
- style={{ paddingTop, paddingBottom }}
- >
- <WorkspaceListToolbarRow
- searching={searching}
- searchField={searchField}
- onCloseSearch={closeSearch}
- onOpenSearch={openSearch}
- searchAccessibilityLabel="Search threads"
- titleAccessibilityLabel="T3 Code, Threads"
- onOpenEnvironments={props.onOpenEnvironments}
- filter={filterButton}
- />
- </View>
- );
+/** iOS lists use native header items; only Android draws this toolbar. */
+export function ThreadListToolbar(_props: ThreadListToolbarProps) {
+ return null;
}
diff --git a/apps/mobile/src/features/home/ThreadListToolbar.types.ts b/apps/mobile/src/features/home/ThreadListToolbar.types.ts
new file mode 100644
index 00000000000..6dbf7133154
--- /dev/null
+++ b/apps/mobile/src/features/home/ThreadListToolbar.types.ts
@@ -0,0 +1,11 @@
+import type { MenuAction } from "@react-native-menu/menu";
+
+export interface ThreadListToolbarProps {
+ readonly searchQuery: string;
+ readonly onSearchQueryChange: (query: string) => void;
+ readonly filterActions: MenuAction[];
+ readonly filterCustomized: boolean;
+ readonly onFilterSelect: (id: string) => void;
+ readonly onOpenEnvironments: () => void;
+ readonly onRequestVisibility?: () => void;
+}
diff --git a/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx
index ecd811f4954..b095fe4571b 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx
@@ -14,7 +14,7 @@ import { KeyboardAvoidingView, useKeyboardState } from "react-native-keyboard-co
import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/AppText";
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { Button } from "../../components/ui/Button";
import { GlassSurface } from "../../components/ui/GlassSurface";
import { NativeStackScreenOptions } from "../../native/StackHeader";
@@ -140,7 +140,9 @@ function Discussion({ params }: { params: PullRequestParams & { readonly discuss
options={{ title: "Discussion", unstable_headerSubtitle: `#${params.number}` }}
/>
{Platform.OS === "android" ? (
- <AndroidScreenHeader
+ <AppBar
+ embedded
+ sidebar={false}
title="Discussion"
subtitle={`#${params.number}`}
onBack={() => navigation.goBack()}
diff --git a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
index 6129f80d439..8ce46605584 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
@@ -65,7 +65,7 @@ import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeS
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppText as Text } from "../../components/ui/AppText";
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
import { AndroidWorkspaceSidebarButton } from "../layout/workspace-sidebar-toolbar";
@@ -486,7 +486,9 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
optionsVersion={[layout.usesSplitView, sidebarHeaderItem]}
/>
{Platform.OS === "android" ? (
- <AndroidScreenHeader
+ <AppBar
+ embedded
+ sidebar={false}
title={`#${params.number}${connected ? "" : " · Offline"}`}
subtitle={params.repository}
onBack={layout.usesSplitView ? undefined : returnToList}
@@ -957,7 +959,7 @@ export function PullRequestFileRouteScreen(props: PullRequestFileRouteProps) {
<View className="flex-1 bg-screen">
<NativeStackScreenOptions options={{ title, headerTitle: title }} />
{Platform.OS === "android" ? (
- <AndroidScreenHeader title={title} onBack={() => navigation.goBack()} />
+ <AppBar embedded sidebar={false} title={title} onBack={() => navigation.goBack()} />
) : null}
<View className="flex-1 items-center justify-center">
<AppActivityIndicator accessibilityLabel="Loading changes" />
@@ -1154,7 +1156,9 @@ function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
}}
/>
{Platform.OS === "android" ? (
- <AndroidScreenHeader
+ <AppBar
+ embedded
+ sidebar={false}
title={title}
onBack={() => navigation.goBack()}
trailing={
diff --git a/apps/mobile/src/features/pull-requests/PullRequestSearchSheet.tsx b/apps/mobile/src/features/pull-requests/PullRequestSearchSheet.tsx
index ab7491f4949..8f368fc6188 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestSearchSheet.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestSearchSheet.tsx
@@ -2,7 +2,7 @@ import { useNavigation } from "@react-navigation/native";
import { useRef, type ReactNode } from "react";
import { Platform, View, type TextInputInstance } from "react-native";
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { SearchField } from "../../components/ui/SearchField";
import { SheetHeader } from "../../components/ui/SheetHeader";
import { Toolbar } from "../../components/ui/Toolbar";
@@ -37,7 +37,9 @@ export function PullRequestSearchSheet(props: {
if (Platform.OS === "android") {
return (
<View className="flex-1 bg-sheet" collapsable={false}>
- <AndroidScreenHeader
+ <AppBar
+ embedded
+ sidebar={false}
title={props.title}
hideBottomBorder
onBack={() => navigation.goBack()}
diff --git a/apps/mobile/src/features/pull-requests/PullRequestToolbar.android.tsx b/apps/mobile/src/features/pull-requests/PullRequestToolbar.android.tsx
index 6ba565239dc..407fc554b99 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestToolbar.android.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestToolbar.android.tsx
@@ -1,17 +1,15 @@
import { useNavigation } from "@react-navigation/native";
-import { useEffect, useRef } from "react";
-import { BackHandler, Keyboard, View, type TextInputInstance } from "react-native";
-import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
-import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";
-import { SearchField } from "../../components/ui/SearchField";
-import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
+import { useEffect } from "react";
+import { BackHandler, Keyboard } from "react-native";
+import { AppBar } from "../../components/ui/AppBar";
+import { appBarMenuItemsFromActions } from "../../components/ui/menuActionItems";
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
-import { WorkspaceListToolbarRow } from "../workspace/WorkspaceListToolbarRow";
+import { WorkspaceBrandTitle } from "../workspace/WorkspaceBrandTitle";
import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
import type { PullRequestFilterMenu } from "./PullRequestListFilters";
import { openSettings } from "../settings/settings-navigation";
-/** PR search shares the thread list's Android header row. */
+/** PR search shares the thread list's Android header. */
export function PullRequestToolbar(props: {
readonly filters: PullRequestFilterMenu | null;
readonly onRequestVisibility?: () => void;
@@ -22,7 +20,6 @@ export function PullRequestToolbar(props: {
const { dispatch, getScrollOffset, recordScrollOffset, isTabActive } = workspace;
const { onRequestVisibility } = props;
const tab = workspace.state.tabs.pullRequests;
- const input = useRef<TextInputInstance>(null);
const searching = tab.searchMode !== "resting";
const openSearch = () => {
onRequestVisibility?.();
@@ -32,7 +29,6 @@ export function PullRequestToolbar(props: {
offset: getScrollOffset("pullRequests"),
});
dispatch({ type: "search", tab: "pullRequests" });
- input.current?.focus();
return true;
};
useHardwareKeyboardCommand("focusSearch", openSearch);
@@ -56,47 +52,37 @@ export function PullRequestToolbar(props: {
});
return () => subscription.remove();
}, [searching, closeSearch, navigation, isTabActive]);
- const { paddingTop, paddingBottom } = useToolbarLayout();
return (
- <View className="bg-header px-2" style={{ paddingTop, paddingBottom }}>
- <WorkspaceListToolbarRow
- searching={searching}
- searchField={
- <SearchField
- inputRef={input}
- accessibilityLabel="Search pull requests"
- clearAccessibilityLabel="Clear search"
- placeholder="Search pull requests"
- value={tab.query}
- onChangeText={(query) => dispatch({ type: "query", tab: "pullRequests", query })}
- />
- }
- onCloseSearch={closeSearch}
- onOpenSearch={openSearch}
- searchAccessibilityLabel="Search pull requests"
- titleAccessibilityLabel="T3 Code, Pull requests"
- onOpenEnvironments={() => openSettings(navigation, "SettingsEnvironments")}
- filter={
- filters ? (
- <AndroidAnchoredMenu
- actions={filters.actions}
- onPressAction={({ nativeEvent }) => filters.onSelect(nativeEvent.event)}
- >
- {(open) => (
- <AndroidHeaderIconButton
- accessibilityLabel="Filter pull requests"
- icon={
- filters.customized
- ? "line.3.horizontal.decrease.circle.fill"
- : "line.3.horizontal.decrease.circle"
- }
- onPress={open}
- />
- )}
- </AndroidAnchoredMenu>
- ) : null
- }
- />
- </View>
+ <AppBar
+ title="T3 Code"
+ titleContent={
+ <WorkspaceBrandTitle
+ accessibilityLabel="T3 Code, Pull requests"
+ onOpenEnvironments={() => openSettings(navigation, "SettingsEnvironments")}
+ />
+ }
+ sidebar={false}
+ search={{
+ value: tab.query,
+ onChangeText: (query) => dispatch({ type: "query", tab: "pullRequests", query }),
+ placeholder: "Search pull requests",
+ active: searching,
+ onOpen: openSearch,
+ onClose: closeSearch,
+ }}
+ menus={
+ filters
+ ? [
+ {
+ title: "Filter pull requests",
+ icon: filters.customized
+ ? "line.3.horizontal.decrease.circle.fill"
+ : "line.3.horizontal.decrease.circle",
+ items: appBarMenuItemsFromActions(filters.actions, filters.onSelect),
+ },
+ ]
+ : undefined
+ }
+ />
);
}
diff --git a/apps/mobile/src/features/pull-requests/guide/PullRequestGuideScreen.tsx b/apps/mobile/src/features/pull-requests/guide/PullRequestGuideScreen.tsx
index 3cae97487f9..84b8dcb9f5a 100644
--- a/apps/mobile/src/features/pull-requests/guide/PullRequestGuideScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/guide/PullRequestGuideScreen.tsx
@@ -5,7 +5,7 @@ import type { FileDiffMetadata } from "@pierre/diffs";
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
import { useEffect } from "react";
import { Platform, Pressable, View } from "react-native";
-import { AndroidScreenHeader } from "../../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../../components/ui/AppBar";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import {
letterStopNotes,
@@ -139,7 +139,9 @@ export function PullRequestGuideStopScreen({ route }: StaticScreenProps<GuideSto
}}
/>
{Platform.OS === "android" ? (
- <AndroidScreenHeader
+ <AppBar
+ embedded
+ sidebar={false}
title={`Stop ${route.params.position + 1}`}
onBack={() => navigation.goBack()}
trailing={
diff --git a/apps/mobile/src/features/review/ReviewSheet.tsx b/apps/mobile/src/features/review/ReviewSheet.tsx
index 08a2fe57958..05706adf828 100644
--- a/apps/mobile/src/features/review/ReviewSheet.tsx
+++ b/apps/mobile/src/features/review/ReviewSheet.tsx
@@ -28,7 +28,6 @@ import { NativeInspectorContent } from "../../native/NativeInspectorContent";
import { AppText as Text } from "../../components/ui/AppText";
import { SymbolView } from "../../components/ui/AppSymbol";
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
import { ScreenContent } from "../../components/ui/ScreenContent";
import { cn } from "../../lib/cn";
import { environmentCatalog } from "../../connection/catalog";
@@ -398,7 +397,9 @@ function ReviewFileNavigator({
}
>
{Platform.OS === "android" ? (
- <AndroidScreenHeader
+ <AppBar
+ embedded
+ sidebar={false}
title="Changed files"
subtitle={`${files.length} ${files.length === 1 ? "file" : "files"}`}
hideBottomBorder
diff --git a/apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx
index 1d8e5fb9a56..be974f882df 100644
--- a/apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx
@@ -5,7 +5,7 @@ import { AsyncResult } from "effect/reactivity";
import { Platform, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { AppText as Text } from "../../components/ui/AppText";
import { NativeStackScreenOptions } from "../../native/StackHeader";
import {
@@ -48,7 +48,7 @@ export function SettingsKeyboardRouteScreen() {
{Platform.OS === "android" ? (
<>
<NativeStackScreenOptions options={{ headerShown: false }} />
- <AndroidScreenHeader title="Keyboard" onBack={() => navigation.goBack()} />
+ <AppBar embedded sidebar={false} title="Keyboard" onBack={() => navigation.goBack()} />
</>
) : null}
<ScrollView
diff --git a/apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsx
index d3ae7691811..d68578961c1 100644
--- a/apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsx
@@ -39,7 +39,7 @@ import { SettingsSection } from "./components/SettingsSection";
import { ListActionRow as SettingsActionRow } from "../../components/ui/ListActionRow";
import { SettingsSwitchRow } from "./components/SettingsSwitchRow";
import {
- AndroidSettingsEnvironmentFilter,
+ useSettingsEnvironmentMenu,
SettingsEnvironmentFilterHeader,
} from "./components/SettingsEnvironmentFilterHeader";
import { useSettingsEnvironmentFilter, type SettingsTarget } from "./settings-environment-filter";
@@ -49,6 +49,7 @@ import { DEFAULT_SETTINGS_PAGE } from "../workspace/workspace-tab-navigation";
import { readUnloadedThreadCount } from "../../state/olderSettledShelf";
export function SettingsProjectOverviewRouteScreen() {
+ const environmentMenu = useSettingsEnvironmentMenu();
const insets = useSafeAreaInsets();
const [isRemoving, setIsRemoving] = useState(false);
const removalPending = useRef(false);
@@ -88,7 +89,7 @@ export function SettingsProjectOverviewRouteScreen() {
return (
<>
<SettingsEnvironmentFilterHeader />
- <SettingsScreen title="Projects" trailing={<AndroidSettingsEnvironmentFilter />}>
+ <SettingsScreen title="Projects" menus={[environmentMenu]}>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
showsVerticalScrollIndicator={false}
diff --git a/apps/mobile/src/features/settings/SettingsProviderAccountsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsProviderAccountsRouteScreen.tsx
index 859aa0ea989..d7e847a182f 100644
--- a/apps/mobile/src/features/settings/SettingsProviderAccountsRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsProviderAccountsRouteScreen.tsx
@@ -29,7 +29,7 @@ import { useEnvironmentsWithScope } from "../../state/session";
import { useAtomCommand } from "../../state/use-atom-command";
import { ListActionRow as SettingsActionRow } from "../../components/ui/ListActionRow";
import {
- AndroidSettingsEnvironmentFilter,
+ useSettingsEnvironmentMenu,
SettingsEnvironmentFilterHeader,
} from "./components/SettingsEnvironmentFilterHeader";
import { SettingsScreen } from "./components/SettingsScreen";
@@ -37,6 +37,7 @@ import { SettingsSection } from "./components/SettingsSection";
import { useSettingsEnvironmentFilter, type SettingsTarget } from "./settings-environment-filter";
export function SettingsProviderAccountsRouteScreen() {
+ const environmentMenu = useSettingsEnvironmentMenu();
const { selectedTargets } = useSettingsEnvironmentFilter();
const permittedEnvironments = useEnvironmentsWithScope(selectedTargets, AuthProvidersManageScope);
const providersByEnvironment = useAtomValue(environmentPresentations.providersByEnvironmentAtom);
@@ -44,7 +45,7 @@ export function SettingsProviderAccountsRouteScreen() {
return (
<>
<SettingsEnvironmentFilterHeader />
- <SettingsScreen title="Providers" trailing={<AndroidSettingsEnvironmentFilter />}>
+ <SettingsScreen title="Providers" menus={[environmentMenu]}>
<ScreenScrollView
className="flex-1"
contentInsetAdjustmentBehavior="automatic"
diff --git a/apps/mobile/src/features/settings/SettingsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsRouteScreen.tsx
index 59e75efa60c..b39c1b5a5cc 100644
--- a/apps/mobile/src/features/settings/SettingsRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsRouteScreen.tsx
@@ -31,7 +31,7 @@ import { SettingsSection, SettingsSidebarContext } from "./components/SettingsSe
import { SettingsScreen } from "./components/SettingsScreen";
import type { SettingsPageTarget } from "./components/settings-page-targets";
import {
- AndroidSettingsEnvironmentFilter,
+ useSettingsEnvironmentMenu,
SettingsEnvironmentFilterHeader,
} from "./components/SettingsEnvironmentFilterHeader";
import { useSettingsEnvironmentFilter } from "./settings-environment-filter";
@@ -59,6 +59,7 @@ export function SettingsListScreen(props: {
}) {
const surface = useWorkspaceSurface();
const workspace = useWorkspaceTabs();
+ const environmentMenu = useSettingsEnvironmentMenu();
const inSidebar = props.sidebar;
const selected = props.selected;
const sidebar = inSidebar ? { selected } : null;
@@ -76,7 +77,7 @@ export function SettingsListScreen(props: {
<SettingsScreen
title="Settings"
workspaceRoot={inSidebar}
- trailing={<AndroidSettingsEnvironmentFilter />}
+ menus={[environmentMenu]}
search={
workspace
? {
diff --git a/apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx
index 0832ee39450..5a867b623fe 100644
--- a/apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx
@@ -67,7 +67,7 @@ import { resolveNewTaskBranchLabel } from "../threads/new-task-context-presentat
import { useVoiceInputController } from "../voice-input/useVoiceInputController";
import { ScheduledTaskPromptField } from "./components/ScheduledTaskPromptField";
import {
- AndroidSettingsEnvironmentFilter,
+ useSettingsEnvironmentMenu,
SettingsEnvironmentFilterHeader,
} from "./components/SettingsEnvironmentFilterHeader";
import { SettingsScreen } from "./components/SettingsScreen";
@@ -400,6 +400,7 @@ export function SettingsScheduledTasksRouteScreen() {
const { startEditor, resetEditor } = useScheduledTaskEditor();
const navigation = useNavigation<NativeStackNavigationProp<ScheduledTaskRoutes>>();
const insets = useSafeAreaInsets();
+ const environmentMenu = useSettingsEnvironmentMenu();
const newTask = () => {
if (visibleEnvironments.length === 0) return;
resetEditor();
@@ -422,21 +423,19 @@ export function SettingsScheduledTasksRouteScreen() {
/>
<SettingsScreen
title="Scheduled tasks"
- trailing={
- <View className="flex-row items-center">
- <AndroidSettingsEnvironmentFilter />
- <Pressable
- accessibilityRole="button"
- accessibilityLabel="New task"
- accessibilityState={{ disabled: visibleEnvironments.length === 0 }}
- disabled={visibleEnvironments.length === 0}
- onPress={newTask}
- className="size-11 items-center justify-center rounded-full disabled:opacity-50"
- >
- <SymbolView name="plus" size={22} tintColorClassName="accent-icon" />
- </Pressable>
- </View>
+ actions={
+ Platform.OS === "android"
+ ? [
+ {
+ accessibilityLabel: "New task",
+ icon: "plus",
+ disabled: visibleEnvironments.length === 0,
+ onPress: newTask,
+ },
+ ]
+ : undefined
}
+ menus={[environmentMenu]}
>
<ScrollView
keyboardShouldPersistTaps="handled"
diff --git a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx
index 698536b9ec1..bae80ff3279 100644
--- a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx
+++ b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx
@@ -87,7 +87,11 @@ vi.mock("../../components/ui/Button", () => ({
}));
vi.mock("./components/SettingsScreen", () => ({ SettingsScreen: Children }));
vi.mock("./components/SettingsEnvironmentFilterHeader", () => ({
- AndroidSettingsEnvironmentFilter: () => null,
+ useSettingsEnvironmentMenu: () => ({
+ title: "Filter",
+ icon: "line.3.horizontal.decrease.circle",
+ items: [],
+ }),
SettingsEnvironmentFilterHeader: () => null,
}));
vi.mock("./components/DatabaseStorageNotice", () => ({ DatabaseStorageNotice: () => null }));
diff --git a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx
index f35c6a29bd8..2c282db9e80 100644
--- a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx
@@ -23,7 +23,7 @@ import {
} from "../threads/thread-settings-options";
import { SettingsScreen } from "./components/SettingsScreen";
import {
- AndroidSettingsEnvironmentFilter,
+ useSettingsEnvironmentMenu,
SettingsEnvironmentFilterHeader,
} from "./components/SettingsEnvironmentFilterHeader";
import { BranchNamingSettings } from "./components/BranchNamingSettings";
@@ -177,6 +177,7 @@ export function SettingsEnvironmentMaintenanceRouteScreen() {
}
function ServerSettingsDetail(props: { readonly page: SettingsPage }) {
+ const environmentMenu = useSettingsEnvironmentMenu();
const insets = useSafeAreaInsets();
const navigation = useNavigation();
const { selectedTargets, projectGroups, selectedProjectKey } = useSettingsEnvironmentFilter();
@@ -285,10 +286,7 @@ function ServerSettingsDetail(props: { readonly page: SettingsPage }) {
return (
<>
<SettingsEnvironmentFilterHeader />
- <SettingsScreen
- title={PAGE_TITLES[props.page]}
- trailing={<AndroidSettingsEnvironmentFilter />}
- >
+ <SettingsScreen title={PAGE_TITLES[props.page]} menus={[environmentMenu]}>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
showsVerticalScrollIndicator={false}
diff --git a/apps/mobile/src/features/settings/components/SettingsEnvironmentFilterHeader.tsx b/apps/mobile/src/features/settings/components/SettingsEnvironmentFilterHeader.tsx
index b0c27f39748..2ec1982167a 100644
--- a/apps/mobile/src/features/settings/components/SettingsEnvironmentFilterHeader.tsx
+++ b/apps/mobile/src/features/settings/components/SettingsEnvironmentFilterHeader.tsx
@@ -1,9 +1,8 @@
import type { NativeStackHeaderItem } from "@react-navigation/native-stack";
import { resolveEnvironmentMachineKind } from "@t3tools/contracts";
-import { Platform, Pressable } from "react-native";
+import { Platform } from "react-native";
-import { Menu } from "../../../components/ui/Menu";
-import { SymbolView } from "../../../components/ui/AppSymbol";
+import type { AppBarMenu } from "../../../components/ui/AppBar.types";
import { ENVIRONMENT_MACHINE_SYMBOLS } from "../../../components/EnvironmentMachineSymbol";
import { NativeStackScreenOptions } from "../../../native/StackHeader";
import { withNativeGlassHeaderItem } from "../../layout/native-glass-header-items";
@@ -116,7 +115,8 @@ export function SettingsEnvironmentFilterHeader(props: {
);
}
-export function AndroidSettingsEnvironmentFilter() {
+/** Android's settings scope filter, as an `AppBar` menu. */
+export function useSettingsEnvironmentMenu(): AppBarMenu {
const {
availableTargets,
selectedIds,
@@ -126,69 +126,41 @@ export function AndroidSettingsEnvironmentFilter() {
selectedProjectKey,
selectProject,
} = useSettingsEnvironmentFilter();
- const filterIcon =
- selectedIds === null && selectedProjectKey === null
- ? "line.3.horizontal.decrease"
- : "line.3.horizontal.decrease.circle.fill";
-
- return (
- <Menu
- accessible
- accessibilityRole="button"
- accessibilityLabel="Filter settings environments and projects"
- title="Settings scope"
- actions={[
- {
- id: "all",
- title: "All connected environments",
- state: selectedIds === null ? ("on" as const) : ("off" as const),
- },
- ...availableTargets.map((entry) => ({
- id: `environment:${entry.environmentId}`,
- title: `Environment · ${entry.label}`,
- image: ENVIRONMENT_MACHINE_SYMBOLS[resolveEnvironmentMachineKind(entry.serverConfig)],
- subtitle: entry.displayUrl ?? undefined,
- state:
- selectedIds === null || selectedIds.has(entry.environmentId)
- ? ("on" as const)
- : ("off" as const),
- })),
- {
- id: "project:all",
- title: "All projects",
- state: selectedProjectKey === null ? ("on" as const) : ("off" as const),
- },
- ...selectableProjectGroups.map((group) => ({
- id: `project:${group.key}`,
- title: `Project · ${projectMenuLabel(group)}`,
- state: selectedProjectKey === group.key ? ("on" as const) : ("off" as const),
- })),
- ]}
- onPressAction={({ nativeEvent }) => {
- if (nativeEvent.event === "all") selectAll();
- else if (nativeEvent.event === "project:all") selectProject(null);
- else if (nativeEvent.event.startsWith("project:")) {
- const group = selectableProjectGroups.find(
- (entry) => `project:${entry.key}` === nativeEvent.event,
- );
- if (group) selectProject(group.key);
- } else {
- const target = availableTargets.find(
- (entry) => `environment:${entry.environmentId}` === nativeEvent.event,
- );
- if (target) toggleEnvironment(target.environmentId);
- }
- }}
- >
- <Pressable
- accessibilityRole="button"
- accessibilityLabel="Filter settings environments and projects"
- className="size-11 items-center justify-center rounded-full"
- >
- <SymbolView name={filterIcon} size={22} tintColorClassName="accent-icon" />
- </Pressable>
- </Menu>
- );
+ return {
+ title: "Filter settings environments and projects",
+ icon:
+ selectedIds === null && selectedProjectKey === null
+ ? "line.3.horizontal.decrease.circle"
+ : "line.3.horizontal.decrease.circle.fill",
+ items: [
+ {
+ id: "all",
+ title: "All connected environments",
+ selected: selectedIds === null,
+ onPress: selectAll,
+ },
+ ...availableTargets.map((entry) => ({
+ id: `environment:${entry.environmentId}`,
+ title: `Environment · ${entry.label}`,
+ icon: ENVIRONMENT_MACHINE_SYMBOLS[resolveEnvironmentMachineKind(entry.serverConfig)],
+ subtitle: entry.displayUrl ?? undefined,
+ selected: selectedIds === null || selectedIds.has(entry.environmentId),
+ onPress: () => toggleEnvironment(entry.environmentId),
+ })),
+ {
+ id: "project:all",
+ title: "All projects",
+ selected: selectedProjectKey === null,
+ onPress: () => selectProject(null),
+ },
+ ...selectableProjectGroups.map((group) => ({
+ id: `project:${group.key}`,
+ title: `Project · ${projectMenuLabel(group)}`,
+ selected: selectedProjectKey === group.key,
+ onPress: () => selectProject(group.key),
+ })),
+ ],
+ };
}
const projectMenuLabel = (group: { readonly label: string; readonly archived: boolean }) =>
diff --git a/apps/mobile/src/features/settings/components/SettingsScreen.tsx b/apps/mobile/src/features/settings/components/SettingsScreen.tsx
index b61a57c8b75..1faefbd49ee 100644
--- a/apps/mobile/src/features/settings/components/SettingsScreen.tsx
+++ b/apps/mobile/src/features/settings/components/SettingsScreen.tsx
@@ -2,7 +2,6 @@ import { useNavigation, useRoute } from "@react-navigation/native";
import type { ReactNode } from "react";
import { Platform, View } from "react-native";
-import { AndroidSheetHeader } from "../../../components/ui/AndroidScreenHeader";
import type { AppBarProps } from "../../../components/ui/AppBar.types";
import { AppBar } from "../../../components/ui/AppBar";
import { ScreenContent as SettingsScreenContent } from "../../../components/ui/ScreenContent";
@@ -19,7 +18,7 @@ import {
export { SettingsScreenContent };
export function SettingsScreen(
- props: Pick<AppBarProps, "title" | "actions" | "trailing" | "search"> & {
+ props: Pick<AppBarProps, "title" | "actions" | "trailing" | "search" | "menus"> & {
readonly children: ReactNode;
readonly formSheet?: boolean;
readonly workspaceRoot?: boolean;
@@ -44,25 +43,18 @@ export function SettingsScreen(
return (
<View collapsable={false} className={`flex-1 ${surfaceClassName}`}>
- {Platform.OS === "android" && props.formSheet ? (
- <AndroidSheetHeader
- title={props.title}
- actions={props.actions}
- trailing={props.trailing}
- onBack={() => navigation.goBack()}
- hideBottomBorder
- />
- ) : (
- <AppBar
- title={props.title}
- actions={props.actions}
- search={props.search}
- trailing={Platform.OS === "android" ? props.trailing : undefined}
- sidebar={false}
- onBack={workspaceRoot ? undefined : () => navigation.goBack()}
- hideBottomBorder={!props.formSheet}
- />
- )}
+ <AppBar
+ title={props.title}
+ actions={props.actions}
+ search={props.search}
+ trailing={Platform.OS === "android" ? props.trailing : undefined}
+ // iOS screens put their filter menus in native header items themselves.
+ menus={Platform.OS === "android" ? props.menus : undefined}
+ sheet={Platform.OS === "android" && props.formSheet}
+ sidebar={false}
+ onBack={workspaceRoot ? undefined : () => navigation.goBack()}
+ hideBottomBorder={!props.formSheet || Platform.OS === "android"}
+ />
<ScreenScrollViewBottomInset value={deviceType === "pad" || compactTabs ? 80 : 0}>
<ScreenScrollViewSurface value={surfaceClassName}>
{props.formSheet && Platform.OS !== "android" ? (
diff --git a/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx b/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx
index 04c9a4bf4c9..e2661226c91 100644
--- a/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx
+++ b/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx
@@ -25,7 +25,7 @@ import { sanitizeNewRefName } from "@t3tools/shared/git";
import { Platform, Pressable, ScrollView, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { ScreenContent } from "../../components/ui/ScreenContent";
import { SymbolView } from "../../components/ui/AppSymbol";
import { AppText as Text } from "../../components/ui/AppText";
@@ -195,7 +195,9 @@ export function NewTaskEnvironmentPickerRouteScreen() {
}}
/>
{Platform.OS === "android" ? (
- <AndroidScreenHeader
+ <AppBar
+ embedded
+ sidebar={false}
title="Environment"
hideBottomBorder
onBack={() => navigation.goBack()}
@@ -485,7 +487,9 @@ export function BranchPickerScreen(props: {
return (
<View className="flex-1 bg-sheet" collapsable={false}>
<NativeStackScreenOptions options={{ headerShown: false }} />
- <AndroidScreenHeader
+ <AppBar
+ embedded
+ sidebar={false}
title={props.title}
hideBottomBorder
onBack={() => navigation.goBack()}
diff --git a/apps/mobile/src/features/threads/ThreadAgentsSheet.tsx b/apps/mobile/src/features/threads/ThreadAgentsSheet.tsx
index 03915d47bc2..7f6d47e9833 100644
--- a/apps/mobile/src/features/threads/ThreadAgentsSheet.tsx
+++ b/apps/mobile/src/features/threads/ThreadAgentsSheet.tsx
@@ -20,7 +20,7 @@ import { Platform, Pressable, ScrollView, View } from "react-native";
import { ScreenStack } from "react-native-screens";
import { useSafeAreaInsets } from "react-native-safe-area-context";
-import { AndroidSheetHeader } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { AppText as Text } from "../../components/ui/AppText";
import { environmentThreadDetails } from "../../state/threads";
import { NativeStackScreenOptions, nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";
@@ -166,7 +166,7 @@ export function ThreadAgentsSheet({ route }: StaticScreenProps<AgentsTarget>) {
return (
<View collapsable={false} className="flex-1 bg-sheet">
<NativeStackScreenOptions options={{ sheetCornerRadius: 28 }} />
- <AndroidSheetHeader title="Agents" onBack={() => navigation.goBack()} />
+ <AppBar sheet sidebar={false} title="Agents" onBack={() => navigation.goBack()} />
<ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
</View>
);
diff --git a/apps/mobile/src/features/threads/ThreadBackgroundWorkSheet.tsx b/apps/mobile/src/features/threads/ThreadBackgroundWorkSheet.tsx
index c4db6d7a937..03427b8f623 100644
--- a/apps/mobile/src/features/threads/ThreadBackgroundWorkSheet.tsx
+++ b/apps/mobile/src/features/threads/ThreadBackgroundWorkSheet.tsx
@@ -11,7 +11,7 @@ import { Platform, Pressable, ScrollView, View } from "react-native";
import { ScreenStack } from "react-native-screens";
import { useSafeAreaInsets } from "react-native-safe-area-context";
-import { AndroidSheetHeader } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { SymbolView } from "../../components/ui/AppSymbol";
import { AppText as Text } from "../../components/ui/AppText";
import { ScreenContent } from "../../components/ui/ScreenContent";
@@ -97,7 +97,7 @@ export function ThreadBackgroundWorkSheet({ route }: StaticScreenProps<Backgroun
return (
<View collapsable={false} className="flex-1 bg-sheet">
<NativeStackScreenOptions options={{ sheetCornerRadius: 28 }} />
- <AndroidSheetHeader title="Background work" onBack={() => navigation.goBack()} />
+ <AppBar sheet sidebar={false} title="Background work" onBack={() => navigation.goBack()} />
<ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
</View>
);
diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
index 3bbc39d5b9a..f03f8296ced 100644
--- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
@@ -61,7 +61,6 @@ import {
} from "../home/WorkspaceConnectionTitle";
import { SidebarHeaderActions } from "./sidebar-header-actions";
import { ThreadListToolbar } from "../home/ThreadListToolbar";
-import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
import { useFabScroll } from "../home/FabScrollContext";
import { SidebarFilterButton } from "./sidebar-filter-button";
import { createSidebarHeaderItems } from "./sidebar-native-header-items";
@@ -414,12 +413,7 @@ function ThreadNavigationSidebarPane(
};
const [measuredHeaderHeight, setMeasuredHeaderHeight] = useState<number | null>(null);
- const { height, paddingTop, paddingBottom } = useToolbarLayout();
- const stickyHeaderHeight =
- measuredHeaderHeight ??
- (Platform.OS === "android"
- ? paddingTop + height + paddingBottom
- : insets.top + SIDEBAR_STICKY_HEADER_HEIGHT);
+ const stickyHeaderHeight = measuredHeaderHeight ?? insets.top + SIDEBAR_STICKY_HEADER_HEIGHT;
const topListInset = stickyHeaderHeight + 6;
const handleStickyHeaderLayout = (event: LayoutChangeEvent) => {
const nextHeight = event.nativeEvent.layout.height;
@@ -789,7 +783,6 @@ function ThreadNavigationSidebarPane(
style={
Platform.OS === "android"
? {
- marginTop: stickyHeaderHeight,
marginHorizontal: 4,
paddingBottom: insets.bottom,
backgroundColor: drawerColor,
@@ -845,13 +838,11 @@ function ThreadNavigationSidebarPane(
{Platform.OS === "android" ? (
<ThreadListToolbar
- sidebar
- onLayout={handleStickyHeaderLayout}
searchQuery={props.searchQuery}
onSearchQueryChange={props.onSearchQueryChange}
filterActions={listMenuActions}
filterCustomized={filterCustomized}
- onFilterAction={handleListMenuAction}
+ onFilterSelect={(event) => handleListMenuAction({ nativeEvent: { event } })}
onOpenEnvironments={props.onOpenEnvironmentSettings}
onRequestVisibility={props.onRequestVisibility}
/>
diff --git a/apps/mobile/src/features/threads/ThreadPullRequestsSheet.tsx b/apps/mobile/src/features/threads/ThreadPullRequestsSheet.tsx
index ce17eb7afca..40ea2c9de9b 100644
--- a/apps/mobile/src/features/threads/ThreadPullRequestsSheet.tsx
+++ b/apps/mobile/src/features/threads/ThreadPullRequestsSheet.tsx
@@ -4,7 +4,7 @@ import { useMemo } from "react";
import { Platform, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
-import { AndroidSheetHeader } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { AppText as Text } from "../../components/ui/AppText";
import { ScreenContent } from "../../components/ui/ScreenContent";
import { SheetHeader } from "../../components/ui/SheetHeader";
@@ -111,7 +111,9 @@ export function ThreadPullRequestsSheet(
return (
<View collapsable={false} className="flex-1 bg-header">
<NativeStackScreenOptions options={{ sheetCornerRadius: 28 }} />
- <AndroidSheetHeader
+ <AppBar
+ sheet
+ sidebar={false}
title={title}
hideBottomBorder
onBack={() => navigation.goBack()}
diff --git a/apps/mobile/src/features/threads/ThreadQueueControl.tsx b/apps/mobile/src/features/threads/ThreadQueueControl.tsx
index bfdbc3b5232..31559398d64 100644
--- a/apps/mobile/src/features/threads/ThreadQueueControl.tsx
+++ b/apps/mobile/src/features/threads/ThreadQueueControl.tsx
@@ -20,7 +20,7 @@ import { Screen, ScreenStack, ScreenStackHeaderConfig } from "react-native-scree
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { Button } from "../../components/ui/Button";
-import { AndroidSheetHeader } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { AppText as Text } from "../../components/ui/AppText";
import { SymbolView } from "../../components/ui/AppSymbol";
import { Menu } from "../../components/ui/Menu";
@@ -395,7 +395,7 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
<GestureHandlerRootView style={{ flex: 1 }}>
<View collapsable={false} className="flex-1 bg-sheet">
<NativeStackScreenOptions options={{ sheetCornerRadius: 28 }} />
- <AndroidSheetHeader title="Queued" onBack={() => navigation.goBack()} />
+ <AppBar sheet sidebar={false} title="Queued" onBack={() => navigation.goBack()} />
<ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
</View>
</GestureHandlerRootView>
diff --git a/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx b/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
index ce4a8a8833b..4e7552a5083 100644
--- a/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
+++ b/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
@@ -59,7 +59,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
import { SymbolView } from "../../components/ui/AppSymbol";
import { AppText as Text } from "../../components/ui/AppText";
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";
import { IconButton } from "../../components/ui/IconButton";
import { ProviderIcon } from "../../components/ProviderIcon";
@@ -1433,7 +1433,9 @@ function ThreadSettingsChoiceScreen() {
<>
<NativeStackScreenOptions options={{ headerShown: Platform.OS !== "android" }} />
{Platform.OS === "android" ? (
- <AndroidScreenHeader
+ <AppBar
+ embedded
+ sidebar={false}
title={route.params.title}
onBack={() => navigation.goBack()}
hideBottomBorder
diff --git a/apps/mobile/src/features/threads/git/GitBranchesSheet.occupancy.test.tsx b/apps/mobile/src/features/threads/git/GitBranchesSheet.occupancy.test.tsx
index e611b95d3f6..87aca82de51 100644
--- a/apps/mobile/src/features/threads/git/GitBranchesSheet.occupancy.test.tsx
+++ b/apps/mobile/src/features/threads/git/GitBranchesSheet.occupancy.test.tsx
@@ -19,7 +19,7 @@ vi.mock("react-native", () => ({
}));
vi.mock("@react-navigation/native", () => ({ useNavigation: () => ({}) }));
vi.mock("react-native-safe-area-context", () => ({ useSafeAreaInsets: () => ({ bottom: 0 }) }));
-vi.mock("../../../components/ui/AndroidScreenHeader", () => ({ AndroidSheetHeader: () => null }));
+vi.mock("../../../components/ui/AppBar", () => ({ AppBar: () => null }));
vi.mock("../../../components/ui/SheetHeader", () => ({ SheetHeader: () => null }));
vi.mock("../../../components/ui/ScreenContent", () => ({
ScreenContent: ({ children }: { children: ReactNode }) => <div>{children}</div>,
diff --git a/apps/mobile/src/features/threads/git/GitBranchesSheet.test.tsx b/apps/mobile/src/features/threads/git/GitBranchesSheet.test.tsx
index bc999e3e1cb..22b750fca72 100644
--- a/apps/mobile/src/features/threads/git/GitBranchesSheet.test.tsx
+++ b/apps/mobile/src/features/threads/git/GitBranchesSheet.test.tsx
@@ -27,7 +27,7 @@ vi.mock("react-native", () => ({
vi.mock("react-native-safe-area-context", () => ({
useSafeAreaInsets: () => ({ bottom: 0 }),
}));
-vi.mock("../../../components/ui/AndroidScreenHeader", () => ({ AndroidSheetHeader: () => null }));
+vi.mock("../../../components/ui/AppBar", () => ({ AppBar: () => null }));
vi.mock("../../../components/ui/SheetHeader", () => ({ SheetHeader: () => null }));
vi.mock("../../../components/ui/ScreenContent", () => ({
ScreenContent: ({ children }: { children: ReactNode }) => children,
diff --git a/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx b/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx
index 61c7a7ad6e4..9123a8d8c87 100644
--- a/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx
+++ b/apps/mobile/src/features/threads/git/GitBranchesSheet.tsx
@@ -4,7 +4,7 @@ import { useState } from "react";
import { Platform, Pressable, ScrollView, useWindowDimensions, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
-import { AndroidSheetHeader } from "../../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../../components/ui/AppBar";
import { SheetHeader } from "../../../components/ui/SheetHeader";
import { ScreenContent } from "../../../components/ui/ScreenContent";
import { NativeStackScreenOptions } from "../../../native/StackHeader";
@@ -78,7 +78,9 @@ export function GitBranchesSheet(_props: GitBranchesSheetProps) {
/>
) : null}
{Platform.OS === "android" ? (
- <AndroidSheetHeader
+ <AppBar
+ sheet
+ sidebar={false}
title="Branches & worktrees"
onBack={() => navigation.goBack()}
hideBottomBorder
diff --git a/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx b/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx
index ad76eb41540..7452490b71f 100644
--- a/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx
+++ b/apps/mobile/src/features/threads/git/GitConfirmSheet.tsx
@@ -9,7 +9,7 @@ import { Platform, ScrollView, useWindowDimensions, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
-import { AndroidSheetHeader } from "../../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../../components/ui/AppBar";
import { ScreenContent } from "../../../components/ui/ScreenContent";
import { NativeStackScreenOptions } from "../../../native/StackHeader";
import { AppText as Text } from "../../../components/ui/AppText";
@@ -130,7 +130,9 @@ export function GitConfirmSheet(props: GitConfirmSheetProps) {
/>
) : null}
{Platform.OS === "android" ? (
- <AndroidSheetHeader
+ <AppBar
+ sheet
+ sidebar={false}
title="Confirm action"
onBack={() => navigation.goBack()}
hideBottomBorder
diff --git a/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx b/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx
index ac60fb66f6a..48fb704fa88 100644
--- a/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx
+++ b/apps/mobile/src/features/threads/git/GitOverviewSheet.tsx
@@ -23,10 +23,8 @@ import { ScreenStack } from "react-native-screens";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { NativeInspectorContent } from "../../../native/NativeInspectorContent";
import { NativeHeader, NativeScreen } from "../../../native/ThemedScreenStack";
-import {
- AndroidHeaderIconButton,
- AndroidSheetHeader,
-} from "../../../components/ui/AndroidScreenHeader";
+import { AndroidHeaderIconButton } from "../../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../../components/ui/AppBar";
import { AndroidAnchoredMenu } from "../../../components/ui/AndroidAnchoredMenu";
import { ListRow } from "../../../components/ui/ListRow";
import { ListSection } from "../../../components/ui/ListSection";
@@ -467,7 +465,9 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
</Text>
</View>
) : (
- <AndroidSheetHeader
+ <AppBar
+ sheet
+ sidebar={false}
title={currentBranchLabel}
hideBottomBorder={Platform.OS === "android"}
subtitle={currentStatusSummary}
diff --git a/apps/mobile/src/features/threads/worktree-setup-sheet.android.tsx b/apps/mobile/src/features/threads/worktree-setup-sheet.android.tsx
index 31e00d43963..3c2fb80b6ad 100644
--- a/apps/mobile/src/features/threads/worktree-setup-sheet.android.tsx
+++ b/apps/mobile/src/features/threads/worktree-setup-sheet.android.tsx
@@ -1,7 +1,7 @@
import { Host, ModalBottomSheet, RNHostView } from "@expo/ui/jetpack-compose";
import { View, useWindowDimensions } from "react-native";
import { withUniwind } from "uniwind";
-import { AndroidSheetHeader } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import type { WorktreeSetupSheetProps } from "./worktree-setup-sheet";
const NativeBottomSheet = withUniwind(ModalBottomSheet, {
@@ -24,7 +24,9 @@ export function WorktreeSetupSheet({ children, height, onClose }: WorktreeSetupS
height: Math.min((height || 360) + 64, window.height * 0.85),
}}
>
- <AndroidSheetHeader
+ <AppBar
+ sheet
+ sidebar={false}
title="Worktree setup"
actions={[
{ accessibilityLabel: "Close setup details", icon: "xmark", onPress: onClose },
diff --git a/apps/mobile/src/features/usage/UsageRouteScreen.tsx b/apps/mobile/src/features/usage/UsageRouteScreen.tsx
index 32e12be28f0..aa0f8045398 100644
--- a/apps/mobile/src/features/usage/UsageRouteScreen.tsx
+++ b/apps/mobile/src/features/usage/UsageRouteScreen.tsx
@@ -30,7 +30,7 @@ import {
usageSourceMessages,
} from "@t3tools/shared/usageFormat";
import { useRef, useState, type ReactNode } from "react";
-import { Platform, Pressable, RefreshControl, View } from "react-native";
+import { Platform, RefreshControl, View } from "react-native";
import Animated, { FadeIn, ReduceMotion } from "react-native-reanimated";
import { useSafeAreaInsets } from "react-native-safe-area-context";
@@ -48,8 +48,6 @@ import { UsageDailyChart } from "./UsageDailyChart";
import { toggleUsageEnvironment } from "./usageEnvironmentSelection";
import { useRefreshLimits } from "./UsageLimitsSection";
import { UsageLimitsSection } from "./UsageLimitsPooled";
-import { Menu } from "../../components/ui/Menu";
-import { SymbolView } from "../../components/ui/AppSymbol";
import { NativeStackScreenOptions } from "../../native/StackHeader";
import { withNativeGlassHeaderItem } from "../layout/native-glass-header-items";
import type { UsageChartMetric } from "./usageChartData";
@@ -225,30 +223,27 @@ function UsageScreen(props: {
const id = EnvironmentId.make(value);
setSelectedEnvironmentIds((selected) => toggleUsageEnvironment(selected, environments, id));
};
- const environmentFilter = showEnvironmentFilter ? (
- <Menu
- accessible
- accessibilityRole="button"
- accessibilityLabel="Filter usage environments"
- title="Environments"
- actions={environmentActions}
- onPressAction={({ nativeEvent }) => selectEnvironment(nativeEvent.event)}
- >
- <Pressable
- accessibilityRole="button"
- accessibilityLabel="Filter usage environments"
- className={cn(
- "items-center justify-center rounded-full",
- Platform.OS === "ios" ? "size-[28px]" : "size-[44px]",
- )}
- >
- <SymbolView name={filterIcon} size={22} tintColorClassName="accent-icon" />
- </Pressable>
- </Menu>
- ) : null;
+ const environmentMenu = {
+ title: "Filter usage environments",
+ icon:
+ selectedEnvironmentIds === null
+ ? ("line.3.horizontal.decrease.circle" as const)
+ : ("line.3.horizontal.decrease.circle.fill" as const),
+ items: environmentActions.map((action) => ({
+ id: action.id,
+ title: action.title,
+ subtitle: action.subtitle,
+ selected: action.state === "on",
+ onPress: () => selectEnvironment(action.id),
+ })),
+ };
return (
- <SettingsScreen title="Usage" trailing={environmentFilter} workspaceRoot={props.workspace}>
+ <SettingsScreen
+ title="Usage"
+ menus={showEnvironmentFilter ? [environmentMenu] : undefined}
+ workspaceRoot={props.workspace}
+ >
{Platform.OS === "ios" ? (
<NativeStackScreenOptions
optionsVersion={JSON.stringify({ showEnvironmentFilter, filterIcon, environmentActions })}
diff --git a/apps/mobile/src/features/workspace/AndroidWorkspaceSidebar.android.tsx b/apps/mobile/src/features/workspace/AndroidWorkspaceSidebar.android.tsx
index b3fde507437..7d3ce6f36b2 100644
--- a/apps/mobile/src/features/workspace/AndroidWorkspaceSidebar.android.tsx
+++ b/apps/mobile/src/features/workspace/AndroidWorkspaceSidebar.android.tsx
@@ -12,6 +12,7 @@ import { PullRequestsScreen } from "../pull-requests/PullRequestsScreen";
import { PullRequestToolbar } from "../pull-requests/PullRequestToolbar.android";
import { WorkspaceTabsContext, useWorkspaceTabs } from "./WorkspaceTabsContext";
import { WorkspaceTabPanes } from "./WorkspaceTabPanes";
+import { WorkspaceAppBarScope } from "../../components/ui/WorkspaceAppBar.android";
export function AndroidWorkspaceSidebar(props: {
readonly children: ReactNode;
@@ -29,32 +30,34 @@ export function AndroidWorkspaceSidebar(props: {
const context = { ...workspace, bottomClearance };
if (enabled.length === 0) return <WorkspaceNoTabs />;
return (
- <WorkspaceTabPanes
- tabs={NAVIGATION_TAB_ORDER}
- selected={workspace.state.selectedTab}
- renderTab={(tab) =>
- tab === "threads" ? (
- props.children
- ) : tab !== "pullRequests" ? (
- <View className="flex-1 bg-screen" />
- ) : (
- <WorkspaceTabsContext value={context}>
- <PullRequestsScreen
- sidebar
- selectedPullRequestKey={props.selectedPullRequestKey}
- renderFrame={(filters, list) => (
- <View className="flex-1 bg-header">
- <PullRequestToolbar
- filters={filters}
- onRequestVisibility={props.onRequestVisibility}
- />
- <ScreenContent insetHorizontal>{list}</ScreenContent>
- </View>
- )}
- />
- </WorkspaceTabsContext>
- )
- }
- />
+ <WorkspaceAppBarScope>
+ <WorkspaceTabPanes
+ tabs={NAVIGATION_TAB_ORDER}
+ selected={workspace.state.selectedTab}
+ renderTab={(tab) =>
+ tab === "threads" ? (
+ props.children
+ ) : tab !== "pullRequests" ? (
+ <View className="flex-1 bg-screen" />
+ ) : (
+ <WorkspaceTabsContext value={context}>
+ <PullRequestsScreen
+ sidebar
+ selectedPullRequestKey={props.selectedPullRequestKey}
+ renderFrame={(filters, list) => (
+ <View className="flex-1 bg-header">
+ <PullRequestToolbar
+ filters={filters}
+ onRequestVisibility={props.onRequestVisibility}
+ />
+ <ScreenContent insetHorizontal>{list}</ScreenContent>
+ </View>
+ )}
+ />
+ </WorkspaceTabsContext>
+ )
+ }
+ />
+ </WorkspaceAppBarScope>
);
}
diff --git a/apps/mobile/src/features/workspace/WorkspaceBrandTitle.tsx b/apps/mobile/src/features/workspace/WorkspaceBrandTitle.tsx
new file mode 100644
index 00000000000..a1e2d4fc32a
--- /dev/null
+++ b/apps/mobile/src/features/workspace/WorkspaceBrandTitle.tsx
@@ -0,0 +1,22 @@
+import { CompactBrandTitle } from "../../components/CompactBrandTitle";
+import { WorkspaceConnectionTitle } from "../home/WorkspaceConnectionTitle";
+
+/** The title of a workspace list tab: the brand and the connection status. */
+export function WorkspaceBrandTitle(props: {
+ readonly accessibilityLabel: string;
+ readonly onOpenEnvironments: () => void;
+}) {
+ return (
+ <WorkspaceConnectionTitle
+ grow
+ onPress={props.onOpenEnvironments}
+ brand={
+ <CompactBrandTitle
+ allowFontScaling={false}
+ accessibilityLabel={props.accessibilityLabel}
+ fit
+ />
+ }
+ />
+ );
+}
diff --git a/apps/mobile/src/features/workspace/WorkspaceListToolbarRow.tsx b/apps/mobile/src/features/workspace/WorkspaceListToolbarRow.tsx
deleted file mode 100644
index 07515a8d712..00000000000
--- a/apps/mobile/src/features/workspace/WorkspaceListToolbarRow.tsx
+++ /dev/null
@@ -1,63 +0,0 @@
-import type { ReactNode } from "react";
-import { View } from "react-native";
-import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
-import { CompactBrandTitle } from "../../components/CompactBrandTitle";
-import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
-import { WorkspaceConnectionTitle } from "../home/WorkspaceConnectionTitle";
-
-/**
- * The Android header row above each workspace tab's list. Both tabs draw this same row, so
- * switching tabs leaves the title and buttons where they were. It is plain React Native rather
- * than the Compose app bar: a hidden tab lays out at zero size, and Compose-hosted content takes
- * several frames to measure again when the tab comes back.
- */
-export function WorkspaceListToolbarRow(props: {
- readonly searching: boolean;
- readonly searchField: ReactNode;
- readonly onCloseSearch: () => void;
- readonly onOpenSearch: () => void;
- readonly searchAccessibilityLabel: string;
- readonly titleAccessibilityLabel: string;
- readonly onOpenEnvironments: () => void;
- /** Stays trailing while searching, so it never moves and still narrows the results. */
- readonly filter: ReactNode;
-}) {
- const { height } = useToolbarLayout();
- return (
- <View className="flex-row items-center gap-1" style={{ minHeight: height }}>
- {props.searching ? (
- <>
- <AndroidHeaderIconButton
- accessibilityLabel="Close search"
- icon="arrow.left"
- onPress={props.onCloseSearch}
- />
- {props.searchField}
- {props.filter}
- </>
- ) : (
- <>
- <View className="min-w-0 flex-1 pl-4">
- <WorkspaceConnectionTitle
- grow
- onPress={props.onOpenEnvironments}
- brand={
- <CompactBrandTitle
- allowFontScaling={false}
- accessibilityLabel={props.titleAccessibilityLabel}
- fit
- />
- }
- />
- </View>
- <AndroidHeaderIconButton
- accessibilityLabel={props.searchAccessibilityLabel}
- icon="magnifyingglass"
- onPress={props.onOpenSearch}
- />
- {props.filter}
- </>
- )}
- </View>
- );
-}
diff --git a/apps/mobile/src/features/workspace/WorkspaceRootScreen.android.tsx b/apps/mobile/src/features/workspace/WorkspaceRootScreen.android.tsx
index a5849398a84..2b32d48bef9 100644
--- a/apps/mobile/src/features/workspace/WorkspaceRootScreen.android.tsx
+++ b/apps/mobile/src/features/workspace/WorkspaceRootScreen.android.tsx
@@ -6,7 +6,7 @@ import { WorkspaceExtraTab } from "./WorkspaceExtraTab";
import { View } from "react-native";
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
import { NativeStackScreenOptions } from "../../native/StackHeader";
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { EmptyState } from "../../components/ui/EmptyState";
import { ScreenContent } from "../../components/ui/ScreenContent";
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
@@ -18,6 +18,7 @@ import { AndroidWorkspaceNavigation, FloatingWorkspaceTabs } from "./AndroidWork
import { FLOATING_TABS } from "./floating-workspace-tabs";
import { WorkspaceTabsContext, useWorkspaceTabs } from "./WorkspaceTabsContext";
import { WorkspaceTabPanes } from "./WorkspaceTabPanes";
+import { WorkspaceAppBarScope } from "../../components/ui/WorkspaceAppBar.android";
import type { WorkspaceTab } from "./workspace-tabs-state";
const TABS: readonly WorkspaceTab[] = NAVIGATION_TAB_ORDER;
@@ -65,38 +66,40 @@ export function WorkspaceRootScreen() {
<WorkspaceNoTabs />
)
) : (
- <WorkspaceTabPanes
- tabs={TABS}
- selected={tab}
- renderTab={(tab) =>
- tab === "threads" ? (
- <HomeRouteScreen />
- ) : tab !== "pullRequests" ? (
- <WorkspaceExtraTab tab={tab} />
- ) : layout.usesSplitView ? (
- <>
- <NativeStackScreenOptions options={{ headerShown: false }} />
- <AndroidScreenHeader title="Pull requests" />
- <View className="flex-1 items-center justify-center px-10">
- <EmptyState
- title="Select a pull request"
- detail="Choose a pull request from the sidebar to review it."
- variant="plain"
- />
- </View>
- </>
- ) : (
- <PullRequestsScreen
- renderFrame={(filters, list) => (
- <>
- <PullRequestToolbar filters={filters} />
- <ScreenContent>{list}</ScreenContent>
- </>
- )}
- />
- )
- }
- />
+ <WorkspaceAppBarScope enabled={!layout.usesSplitView}>
+ <WorkspaceTabPanes
+ tabs={TABS}
+ selected={tab}
+ renderTab={(tab) =>
+ tab === "threads" ? (
+ <HomeRouteScreen />
+ ) : tab !== "pullRequests" ? (
+ <WorkspaceExtraTab tab={tab} />
+ ) : layout.usesSplitView ? (
+ <>
+ <NativeStackScreenOptions options={{ headerShown: false }} />
+ <AppBar embedded sidebar={false} title="Pull requests" />
+ <View className="flex-1 items-center justify-center px-10">
+ <EmptyState
+ title="Select a pull request"
+ detail="Choose a pull request from the sidebar to review it."
+ variant="plain"
+ />
+ </View>
+ </>
+ ) : (
+ <PullRequestsScreen
+ renderFrame={(filters, list) => (
+ <>
+ <PullRequestToolbar filters={filters} />
+ <ScreenContent>{list}</ScreenContent>
+ </>
+ )}
+ />
+ )
+ }
+ />
+ </WorkspaceAppBarScope>
)}
</SafeAreaInsetsContext>
{layout.usesSplitView ? null : floatingTabsEnabled ? (
diff --git a/apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx b/apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx
index b9f497cae56..7d4c5cb993d 100644
--- a/apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx
+++ b/apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx
@@ -10,7 +10,7 @@ import { useKeyboardState } from "react-native-keyboard-controller";
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
import { CompactBrandTitle } from "../../components/CompactBrandTitle";
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
+import { AppBar } from "../../components/ui/AppBar";
import { HeaderItemsWidthContext } from "../../native/header-items-width";
import { NativeStackScreenOptions } from "../../native/StackHeader";
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
@@ -164,7 +164,9 @@ function WorkspaceRootContent() {
}}
/>
) : (
- <AndroidScreenHeader
+ <AppBar
+ embedded
+ sidebar={false}
title="T3 Code"
titleContent={renderHeaderTitle()}
actions={[
diff --git a/apps/mobile/src/features/workspace/workspace-tabs-state.test.ts b/apps/mobile/src/features/workspace/workspace-tabs-state.test.ts
index cf4b3a0efa5..fde64ea6ff7 100644
--- a/apps/mobile/src/features/workspace/workspace-tabs-state.test.ts
+++ b/apps/mobile/src/features/workspace/workspace-tabs-state.test.ts
@@ -212,7 +212,7 @@ vi.mock("./WorkspaceExtraTab", () => ({
},
}));
vi.mock("../../native/StackHeader", () => ({ NativeStackScreenOptions: () => null }));
-vi.mock("../../components/ui/AndroidScreenHeader", () => ({ AndroidScreenHeader: () => null }));
+vi.mock("../../components/ui/AppBar", () => ({ AppBar: () => null }));
vi.mock("../../components/ui/EmptyState", () => ({ EmptyState: () => null }));
vi.mock("../../components/ui/ScreenContent", () => ({
ScreenContent: ({ children }: { children: ReactNode }) => createElement("div", null, children),
@@ -232,6 +232,9 @@ vi.mock("./AndroidWorkspaceNavigation", () => ({
FloatingWorkspaceTabs: () => null,
}));
vi.mock("./WorkspaceNoTabs", () => ({ WorkspaceNoTabs: () => null }));
+vi.mock("../../components/ui/WorkspaceAppBar.android", () => ({
+ WorkspaceAppBarScope: ({ children }: { children: ReactNode }) => children,
+}));
function setup(split: boolean, floating: boolean) {
mocks.split = split;
diff --git a/apps/mobile/vite.config.ts b/apps/mobile/vite.config.ts
index 5e2e5a8e356..6f5c4558b5a 100644
--- a/apps/mobile/vite.config.ts
+++ b/apps/mobile/vite.config.ts
@@ -20,6 +20,7 @@ const reactTests = [
"src/components/ProjectFavicon.test.tsx",
"src/components/ui/Dialog.android.test.tsx",
"src/features/pull-requests/usePullRequestList.test.tsx",
+ "src/components/ui/AppBar.android.test.tsx",
"src/features/files/ZipArchiveView.test.tsx",
"src/features/pull-requests/guide/useReviewGuide.test.tsx",
"src/features/settings/SettingsServerControlsRouteScreen.test.tsx",
diff --git a/vite.config.ts b/vite.config.ts
index 468837c2556..c92ad24843f 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -386,6 +386,27 @@ export default defineConfig({
],
},
},
+ {
+ files: ["apps/mobile/src/features/**"],
+ rules: {
+ "eslint/no-restricted-imports": [
+ "error",
+ {
+ paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS],
+ patterns: [
+ {
+ group: [
+ "**/components/ui/AndroidScreenHeader",
+ "**/components/ui/WorkspaceAppBar*",
+ ],
+ importNames: ["AndroidScreenHeader", "WorkspaceAppBar"],
+ message: "Use AppBar, so every screen gets the same header and button metrics.",
+ },
+ ],
+ },
+ ],
+ },
+ },
{
files: ["apps/web/src/components/pullRequest/pullRequestIcons.tsx"],
rules: { "eslint/no-restricted-imports": ["error", { paths: RESTRICTED_IMPORT_PATHS }] },