Skip to content

Commit d225379

Browse files
refactor(mobile): the inspector's bar is its pane's AppBar
Each inspector pane built its own header. On iOS the Files and Git panes mounted a one-screen native stack with a hand-written header config, and Android drew separate headers, so features branched by platform and threaded a header inset through. The iPhone git sheet had no close button. Inspector panes now render AppBar like any screen. The inspector collects the options their AppBar sets, per pane since hidden panes stay mounted, and draws them: in the native inspector column's own navigation bar on iOS 26, and in a one-screen native stack in the JS column and the sheet. On Android the AppBar draws inline as before. In the inspector, AppBar adds a close button that hides the column or dismisses the sheet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 96b563a commit d225379

29 files changed

Lines changed: 654 additions & 917 deletions

‎apps/mobile/modules/t3-native-controls/ios/T3ScrollEdgeBleedView.swift‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,11 @@ final class T3ScrollEdgeBleedView: ExpoView {
9595
// The vertical-bar API ships in the iOS 27.1 SDK (UIKit 9127.0.85); see T3LayoutMetricsView.
9696
#if canImport(UIKit, _version: 9127.0.85)
9797
if #available(iOS 27.1, *) {
98+
// UIKit leaves the trait unset in a split view's inspector column, though the bar overlaps
99+
// it; the flush check above still decides whether this view sits at the bar.
100+
let traits = window?.rootViewController?.traitCollection ?? traitCollection
98101
let rtl = effectiveUserInterfaceLayoutDirection == .rightToLeft
99-
switch traitCollection.verticalBarEdge {
102+
switch traits.verticalBarEdge {
100103
case .leading: return rtl ? .right : .left
101104
case .trailing: return rtl ? .left : .right
102105
default: return nil

‎apps/mobile/src/Stack.tsx‎

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ import {
1111
StackActions,
1212
useNavigation,
1313
} from "@react-navigation/native";
14-
import {
15-
createNativeStackScreen,
16-
type NativeStackNavigationOptions,
17-
} from "@react-navigation/native-stack";
14+
import { createNativeStackScreen } from "@react-navigation/native-stack";
1815
import type { ReactNode } from "react";
1916
import { Platform, Pressable, ScrollView, StyleSheet, useWindowDimensions } from "react-native";
2017
import { useResolveClassNames } from "uniwind";
@@ -141,33 +138,12 @@ import {
141138
SettingsLegalDocumentCloseHeaderButton,
142139
SettingsLegalDocumentExternalHeaderButton,
143140
} from "./features/settings/components/SettingsLegalDocumentRouteScreen";
144-
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "./native/native-glass";
141+
import { GLASS_HEADER_OPTIONS, type AppScreenOptions } from "./native/glass-header-options";
145142
import { deriveLayout } from "./lib/layout";
146143
import { useNativeLayoutMetrics } from "./native/native-layout-metrics";
147-
import { nativeHeaderScrollEdgeEffects } from "./native/StackHeader";
148144
import { HORIZONTAL_FORM_SHEET_OPTIONS, formSheetDetents } from "./native/sheet-surface";
149145
import { workspaceDetailRouter } from "./features/workspace/workspace-detail-selection";
150146

151-
const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
152-
153-
type AppScreenOptions = NativeStackNavigationOptions & {
154-
readonly unstable_navigationItemStyle?: "editor";
155-
readonly unstable_headerMinimizationBehavior?: "onScrollUp" | "never";
156-
};
157-
158-
const GLASS_HEADER_OPTIONS: AppScreenOptions = {
159-
headerBackButtonDisplayMode: "minimal",
160-
headerBackTitle: "",
161-
headerLargeTitle: false,
162-
headerShadowVisible: false,
163-
headerShown: true,
164-
headerStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? { backgroundColor: "transparent" } : undefined,
165-
headerTitleStyle: { fontSize: 18, fontWeight: "800" },
166-
headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,
167-
scrollEdgeEffects: NATIVE_LIQUID_GLASS_SUPPORTED ? HEADER_SCROLL_EDGE_EFFECTS : undefined,
168-
unstable_navigationItemStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? "editor" : undefined,
169-
};
170-
171147
// Hiding Android's native header after mount can leave detail panes measured short.
172148
// These screens render their own Material toolbar, so hide it from the first layout.
173149
const DETAIL_HEADER_OPTIONS: AppScreenOptions = {

‎apps/mobile/src/components/ui/AppBar.android.tsx‎

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { type RefObject, useRef, useState } from "react";
1+
import { type RefObject, use, useRef, useState } from "react";
22
import { Keyboard, type TextInputInstance, View } from "react-native";
33
import { useHardwareBack } from "../../lib/backHandler";
44
import { useToolbarLayout } from "./useToolbarLayout";
55
import { NativeStackScreenOptions } from "../../native/StackHeader";
66
import { useSidebarToggle } from "../../features/layout/useSidebarToggle";
7+
import { InspectorCloseContext } from "../../features/layout/inspector-bar-store";
78
import { useAppearancePreferences } from "../../features/settings/appearance/AppearancePreferencesProvider";
89
import { AndroidHeaderIconButton, AndroidScreenHeader } from "./AndroidScreenHeader";
910
import { ScreenHeaderButton } from "./ScreenHeaderButton.android";
@@ -69,8 +70,15 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
6970
const { themeVariables } = useAppearancePreferences();
7071
const inWorkspace = useHasWorkspaceAppBar();
7172
const sidebarToggle = useSidebarToggle();
73+
const closeInspector = use(InspectorCloseContext);
7274
const inline = search?.mode === "inline";
7375
const searching = searchState?.searching === true;
76+
const actions = props.refresh
77+
? [
78+
...(props.actions ?? []),
79+
{ ...props.refresh, icon: "arrow.clockwise" as const, overflowOnly: true },
80+
]
81+
: props.actions;
7482
const openSearch = () => searchState?.open();
7583
const closeSearch = () => searchState?.close();
7684

@@ -177,24 +185,22 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
177185
icon: "magnifyingglass",
178186
onPress: openSearch,
179187
},
180-
...(search.refreshInToolbar && search.onRefresh
181-
? [
182-
{
183-
accessibilityLabel: search.refreshAccessibilityLabel ?? "Refresh",
184-
icon: "arrow.clockwise" as const,
185-
onPress: search.onRefresh,
186-
},
187-
]
188-
: []),
189-
...(props.actions ?? []),
188+
...(actions ?? []),
190189
]
191-
: props.actions
190+
: actions
192191
}
193192
trailing={
194-
menuView?.length || props.trailing ? (
193+
menuView?.length || props.trailing || closeInspector ? (
195194
<>
196195
{menuView}
197196
{props.trailing}
197+
{closeInspector ? (
198+
<AndroidHeaderIconButton
199+
accessibilityLabel="Close inspector"
200+
icon="xmark"
201+
onPress={closeInspector}
202+
/>
203+
) : null}
198204
</>
199205
) : undefined
200206
}

‎apps/mobile/src/components/ui/AppBar.tsx‎

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import { Toolbar } from "./Toolbar";
22
import { AppActivityIndicator } from "./AppActivityIndicator";
33
import type { HeaderBarButtonMailSearchToolbarItem } from "react-native-screens";
4-
import { useId } from "react";
4+
import { use, useId, useLayoutEffect } from "react";
55
import { View } from "react-native";
66
import { createNativeHeaderMenu } from "./nativeHeaderMenu.ios";
77
import { ScreenHeaderButton } from "./ScreenHeaderButton";
8-
import { NativeStackScreenOptions } from "../../native/StackHeader";
8+
import { NativeStackScreenOptions, useScreenOptionsWriter } from "../../native/StackHeader";
99
import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspaceColumns";
1010
import { useDeviceType } from "../../native/native-layout-metrics";
11+
import { isDuoDevice } from "../../lib/device-type";
1112
import { useAdaptiveWorkspaceLayout } from "../../features/layout/AdaptiveWorkspaceLayout";
1213
import { useSidebarToggle } from "../../features/layout/useSidebarToggle";
14+
import { InspectorCloseContext } from "../../features/layout/inspector-bar-store";
1315
import {
1416
createNativeMailSearchToolbarItem,
1517
NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED,
@@ -44,6 +46,15 @@ export function AppBar(props: AppBarProps) {
4446
const headerId = useId();
4547
const { layout } = useAdaptiveWorkspaceLayout();
4648
const sidebarToggle = useSidebarToggle();
49+
const closeInspector = use(InspectorCloseContext);
50+
const setOptions = useScreenOptionsWriter();
51+
const ownsInspectorBar = closeInspector !== null && !props.embedded && !props.sheet;
52+
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- an inspector pane that stops drawing its bar must not leave it in the out-of-tree inspector bar
53+
useLayoutEffect(() => {
54+
if (!ownsInspectorBar || !setOptions) return;
55+
setOptions({ headerShown: true });
56+
return () => setOptions({ headerShown: false });
57+
}, [ownsInspectorBar, setOptions]);
4758
// The Duo's native columns show their own sidebar button while the sidebar is open.
4859
const showsSidebarToggle =
4960
sidebarToggle !== null &&
@@ -62,16 +73,18 @@ export function AppBar(props: AppBarProps) {
6273
(search.compactToolbar ?? !layout.usesSplitView) &&
6374
usesNativeMailSearchToolbar;
6475
const visibleMenus = compactSearch ? (menus?.slice(1) ?? []) : (menus ?? []);
65-
const refresh = search?.refreshInToolbar ? search.onRefresh : undefined;
76+
// Where the mail toolbar isn't used, the Duo keeps search at the bottom of the pane like its
77+
// workspace lists; elsewhere inline search is a button in the bar.
78+
const duoBottomSearch =
79+
search !== undefined &&
80+
!compactSearch &&
81+
NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED &&
82+
isDuoDevice(deviceType);
6683
if (props.embedded || props.sheet) return null;
6784
return (
6885
<>
6986
<NativeStackScreenOptions
70-
optionsVersion={[
71-
props.optionsVersion,
72-
compactSearch ? menu : undefined,
73-
compactSearch ? refresh : undefined,
74-
]}
87+
optionsVersion={[props.optionsVersion, compactSearch ? menu : undefined]}
7588
options={{
7689
headerShown: true,
7790
headerBackVisible: splitBack === null,
@@ -89,13 +102,6 @@ export function AppBar(props: AppBarProps) {
89102
placeholder: search.compactPlaceholder ?? search.placeholder,
90103
onSearchTextChange: search.onChangeText,
91104
searchTextChangeId: `${headerId}-search-text`,
92-
...(refresh
93-
? {
94-
composeButtonId: `${headerId}-refresh`,
95-
composeSystemImageName: "arrow.clockwise",
96-
onComposePress: refresh,
97-
}
98-
: undefined),
99105
...(menu
100106
? {
101107
filterButtonId: `${headerId}-filter`,
@@ -110,12 +116,16 @@ export function AppBar(props: AppBarProps) {
110116
? undefined
111117
: {
112118
allowToolbarIntegration: true,
113-
...(NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED && search.mode === "inline"
114-
? { placement: "integratedButton" as const }
115-
: undefined),
119+
...(duoBottomSearch
120+
? { placement: "integrated" as const }
121+
: NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED && search.mode === "inline"
122+
? { placement: "integratedButton" as const }
123+
: undefined),
116124
autoCapitalize: "none",
117125
hideNavigationBar: false,
118-
...(search.mode === "inline" ? { obscureBackground: false } : undefined),
126+
...(search.mode === "inline" || duoBottomSearch
127+
? { obscureBackground: false }
128+
: undefined),
119129
placeholder: search.placeholder,
120130
onChangeText: (event) => search.onChangeText(event.nativeEvent.text),
121131
onCancelButtonPress: () => search.onChangeText(""),
@@ -140,10 +150,7 @@ export function AppBar(props: AppBarProps) {
140150
) : null}
141151
</Toolbar>
142152
) : null}
143-
{(props.actions?.length ||
144-
(!compactSearch && refresh) ||
145-
visibleMenus.length ||
146-
props.trailing) &&
153+
{(props.actions?.length || visibleMenus.length || props.trailing || closeInspector) &&
147154
props.options?.unstable_headerRightItems === undefined ? (
148155
<Toolbar placement="right">
149156
{props.actions?.map(({ loading, ...action }) =>
@@ -165,16 +172,21 @@ export function AppBar(props: AppBarProps) {
165172
/>
166173
),
167174
)}
168-
{refresh && !compactSearch ? (
175+
{visibleMenus.map(createNativeHeaderMenu)}
176+
{props.trailing}
177+
{closeInspector ? (
169178
<ScreenHeaderButton
170-
accessibilityLabel={search?.refreshAccessibilityLabel}
171-
icon="arrow.clockwise"
172-
onPress={refresh}
179+
accessibilityLabel="Close inspector"
180+
icon="xmark"
181+
onPress={closeInspector}
173182
separateBackground
174183
/>
175184
) : null}
176-
{visibleMenus.map(createNativeHeaderMenu)}
177-
{props.trailing}
185+
</Toolbar>
186+
) : null}
187+
{duoBottomSearch ? (
188+
<Toolbar placement="bottom">
189+
<Toolbar.SearchBarSlot />
178190
</Toolbar>
179191
) : null}
180192
</>

‎apps/mobile/src/components/ui/AppBar.types.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ export interface AppBarSearch {
5757
readonly compactPlaceholder?: string;
5858
readonly closeAccessibilityLabel?: string;
5959
readonly clearAccessibilityLabel?: string;
60-
readonly onRefresh?: () => void;
61-
readonly refreshAccessibilityLabel?: string;
62-
readonly refreshInToolbar?: boolean;
6360
/** Controlled open state. The owner then also handles back and the keyboard shortcut. */
6461
readonly active?: boolean;
6562
readonly onOpen?: () => void;
@@ -72,6 +69,8 @@ export interface AppBarProps {
7269
readonly titleContent?: ReactNode;
7370
readonly subtitle?: string | null;
7471
readonly actions?: ReadonlyArray<AppBarAction>;
72+
/** Pull-to-refresh is the gesture on both platforms; Android also lists this in the overflow menu. */
73+
readonly refresh?: Pick<AppBarAction, "accessibilityLabel" | "disabled" | "onPress">;
7574
readonly menus?: ReadonlyArray<AppBarMenu>;
7675
readonly search?: AppBarSearch;
7776
readonly onBack?: () => void;

‎apps/mobile/src/features/files/FilesHeader.tsx‎

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)