Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(mobile): complete iphone duo layout support (#129626)

Chris Volzerb9e5100819b1
diff --git a/products/mobile/.argent/flows/demo-smoke.yaml b/products/mobile/.argent/flows/demo-smoke.yaml
index aae0669c646d..593dfb7b1058 100644
--- a/products/mobile/.argent/flows/demo-smoke.yaml
+++ b/products/mobile/.argent/flows/demo-smoke.yaml
@@ -70,13 +70,13 @@ steps:
- await: { visible: { text: Which deploy caused this? } }
- echo: Reply shown. Close the chat. Expect the report again
- - tap: { id: chat-back }
- - await: { hidden: { id: chat-back } }
+ - tap: { text: Back }
+ - await: { hidden: { id: chat-input } }
- await: { visible: { id: decision-request } }
- await: { idle: true }
- echo: On the report. Go back. Expect the inbox
- - tap: { id: report-back }
+ - tap: { text: Back }
- await: { visible: { id: inbox-screen } }
- await: { idle: true }
@@ -90,11 +90,11 @@ steps:
- tap: { id: chat-row-session-demo-session-flaky-test }
- await: { visible: { id: session-thread } }
- await: { idle: true }
- - assert: { visible: { id: chat-more } }
+ - assert: { visible: { text: Chat options } }
- assert: { visible: { id: session-assistant } }
- echo: Session open. Close it. Expect the chats list again
- - tap: { id: chat-back }
+ - tap: { text: Back }
- await: { visible: { id: chats-screen } }
- await: { idle: true }
@@ -104,7 +104,7 @@ steps:
- await: { idle: true }
- echo: Decision card open. Close the session. Expect the chats list again
- - tap: { id: chat-back }
+ - tap: { text: Back }
- await: { visible: { id: chats-screen } }
- await: { idle: true }
@@ -114,7 +114,7 @@ steps:
- await: { idle: true }
- echo: On the inbox. Open the menu. Expect Settings in it
- - tap: { id: tabs-more }
+ - tap: { text: More }
- await: { visible: { id: nav-settings } }
- await: { idle: true }
diff --git a/products/mobile/.argent/flows/screenshot-capture.yaml b/products/mobile/.argent/flows/screenshot-capture.yaml
index 4153cf0a86a6..ee35eb1748ac 100644
--- a/products/mobile/.argent/flows/screenshot-capture.yaml
+++ b/products/mobile/.argent/flows/screenshot-capture.yaml
@@ -28,9 +28,9 @@ steps:
- echo: Chat
- tool: screenshot
args: { scale: 1, includeImageInContext: false }
- - tap: { id: chat-back }
- - await: { visible: { id: report-back } }
- - tap: { id: report-back }
+ - tap: { text: Back }
+ - await: { visible: { text: Back } }
+ - tap: { text: Back }
- await: { visible: { id: inbox-screen } }
- tap: { id: inbox-nav-views }
- await: { visible: { id: views-screen } }
diff --git a/products/mobile/.argent/flows/views-smoke.yaml b/products/mobile/.argent/flows/views-smoke.yaml
index c7246efe6c05..15aa82761905 100644
--- a/products/mobile/.argent/flows/views-smoke.yaml
+++ b/products/mobile/.argent/flows/views-smoke.yaml
@@ -18,11 +18,11 @@ steps:
- assert: { text: { in: { id: views-pin-dashboard-demo-dash-kpis }, contains: Product KPIs } }
- echo: On Views. Open Edit pins and show Signups as a number. Expect the big value
- - tap: { id: tabs-more }
+ - tap: { text: More }
- tap: { id: views-edit-pins }
- await: { visible: { id: edit-pins-sheet } }
- tap: { id: edit-pin-mode-number-insight-demo-ins-signups }
- - tap: { id: edit-pins-done }
+ - tap: { text: Done }
- await: { visible: { id: views-pin-value-insight-demo-ins-signups } }
- await: { idle: true }
@@ -90,9 +90,9 @@ steps:
- await: { idle: true }
- echo: Close full screen and go back. Expect the dashboard
- - tap: { id: chart-fullscreen-back }
+ - tap: { text: Back }
- await: { visible: { id: insight-scroll } }
- - tap: { id: view-back }
+ - tap: { text: Back }
- await: { visible: { id: dashboard-tiles } }
- await: { idle: true }
@@ -118,7 +118,7 @@ steps:
- tap: { id: view-tile-fullscreen-8 }
- await: { visible: { id: chart-fullscreen-funnel } }
- await: { idle: true }
- - tap: { id: chart-fullscreen-back }
+ - tap: { text: Back }
- await: { visible: { id: view-tile-fullscreen-8 } }
- await: { idle: true }
@@ -132,7 +132,7 @@ steps:
- await: { idle: true }
- echo: Go back. Expect Views
- - tap: { id: view-back }
+ - tap: { text: Back }
- await: { visible: { id: views-screen } }
- await: { idle: true }
@@ -146,7 +146,7 @@ steps:
- await: { idle: true }
- echo: On the dashboard list. Go back. Expect Views
- - tap: { id: views-browse-back }
+ - tap: { text: Back }
- await: { visible: { id: views-screen } }
- await: { idle: true }
@@ -156,7 +156,7 @@ steps:
- await: { idle: true }
- echo: On the inbox. Open the menu. Expect Settings in it
- - tap: { id: tabs-more }
+ - tap: { text: More }
- await: { visible: { id: nav-settings } }
- await: { idle: true }
diff --git a/products/mobile/app.config.ts b/products/mobile/app.config.ts
index 84f05b65773e..eb74e424ce6f 100644
--- a/products/mobile/app.config.ts
+++ b/products/mobile/app.config.ts
@@ -59,7 +59,7 @@ export default ({ config, projectRoot }: ConfigContext): ExpoConfig => {
slug: 'posthog',
owner: 'posthog',
scheme,
- version: '1.9.0',
+ version: '1.10.0',
orientation: 'default',
userInterfaceStyle: 'automatic',
icon: icons.png,
diff --git a/products/mobile/app/(tabs)/chats/_layout.tsx b/products/mobile/app/(tabs)/chats/_layout.tsx
new file mode 100644
index 000000000000..64c7879530b7
--- /dev/null
+++ b/products/mobile/app/(tabs)/chats/_layout.tsx
@@ -0,0 +1,6 @@
+import { Stack } from 'expo-router'
+import type { ReactElement } from 'react'
+
+export default function TabStack(): ReactElement {
+ return <Stack screenOptions={{ headerShown: false }} />
+}
diff --git a/products/mobile/app/(tabs)/chats.tsx b/products/mobile/app/(tabs)/chats/index.tsx
similarity index 51%
rename from products/mobile/app/(tabs)/chats.tsx
rename to products/mobile/app/(tabs)/chats/index.tsx
index 58acc4c3c655..c61e1b34864f 100644
--- a/products/mobile/app/(tabs)/chats.tsx
+++ b/products/mobile/app/(tabs)/chats/index.tsx
@@ -1,7 +1,11 @@
import type { ReactElement } from 'react'
-
import { ChatsScreen } from '@/features/chats/ChatsScreen'
+import { TabScene } from '@/features/tabs/TabScene'
export default function ChatsRoute(): ReactElement {
- return <ChatsScreen />
+ return (
+ <TabScene tab="chats">
+ <ChatsScreen />
+ </TabScene>
+ )
}
diff --git a/products/mobile/app/(tabs)/errors/_layout.tsx b/products/mobile/app/(tabs)/errors/_layout.tsx
new file mode 100644
index 000000000000..64c7879530b7
--- /dev/null
+++ b/products/mobile/app/(tabs)/errors/_layout.tsx
@@ -0,0 +1,6 @@
+import { Stack } from 'expo-router'
+import type { ReactElement } from 'react'
+
+export default function TabStack(): ReactElement {
+ return <Stack screenOptions={{ headerShown: false }} />
+}
diff --git a/products/mobile/app/(tabs)/errors.tsx b/products/mobile/app/(tabs)/errors/index.tsx
similarity index 55%
rename from products/mobile/app/(tabs)/errors.tsx
rename to products/mobile/app/(tabs)/errors/index.tsx
index f38cd2b9ac39..f20e4b9fc5e0 100644
--- a/products/mobile/app/(tabs)/errors.tsx
+++ b/products/mobile/app/(tabs)/errors/index.tsx
@@ -1,14 +1,15 @@
import type { ReactElement } from 'react'
-
import { ErrorsListScreen } from '@/features/errors/ErrorsListScreen'
-
import { MobileProductGate } from '@/features/tabs/MobileProductGate'
+import { TabScene } from '@/features/tabs/TabScene'
import { FEATURE_FLAGS } from '@/lib/featureFlags'
export default function ErrorsTabRoute(): ReactElement {
return (
- <MobileProductGate flag={FEATURE_FLAGS.errorTracking}>
- <ErrorsListScreen chrome="tab" />
- </MobileProductGate>
+ <TabScene tab="errors">
+ <MobileProductGate flag={FEATURE_FLAGS.errorTracking}>
+ <ErrorsListScreen chrome="tab" />
+ </MobileProductGate>
+ </TabScene>
)
}
diff --git a/products/mobile/app/(tabs)/inbox/_layout.tsx b/products/mobile/app/(tabs)/inbox/_layout.tsx
new file mode 100644
index 000000000000..64c7879530b7
--- /dev/null
+++ b/products/mobile/app/(tabs)/inbox/_layout.tsx
@@ -0,0 +1,6 @@
+import { Stack } from 'expo-router'
+import type { ReactElement } from 'react'
+
+export default function TabStack(): ReactElement {
+ return <Stack screenOptions={{ headerShown: false }} />
+}
diff --git a/products/mobile/app/(tabs)/inbox.tsx b/products/mobile/app/(tabs)/inbox/index.tsx
similarity index 51%
rename from products/mobile/app/(tabs)/inbox.tsx
rename to products/mobile/app/(tabs)/inbox/index.tsx
index 728c26370070..f103dbe259e6 100644
--- a/products/mobile/app/(tabs)/inbox.tsx
+++ b/products/mobile/app/(tabs)/inbox/index.tsx
@@ -1,7 +1,11 @@
import type { ReactElement } from 'react'
-
import { InboxScreen } from '@/features/inbox/InboxScreen'
+import { TabScene } from '@/features/tabs/TabScene'
export default function InboxRoute(): ReactElement {
- return <InboxScreen />
+ return (
+ <TabScene tab="inbox">
+ <InboxScreen />
+ </TabScene>
+ )
}
diff --git a/products/mobile/app/(tabs)/replay/_layout.tsx b/products/mobile/app/(tabs)/replay/_layout.tsx
new file mode 100644
index 000000000000..64c7879530b7
--- /dev/null
+++ b/products/mobile/app/(tabs)/replay/_layout.tsx
@@ -0,0 +1,6 @@
+import { Stack } from 'expo-router'
+import type { ReactElement } from 'react'
+
+export default function TabStack(): ReactElement {
+ return <Stack screenOptions={{ headerShown: false }} />
+}
diff --git a/products/mobile/app/(tabs)/replay.tsx b/products/mobile/app/(tabs)/replay/index.tsx
similarity index 55%
rename from products/mobile/app/(tabs)/replay.tsx
rename to products/mobile/app/(tabs)/replay/index.tsx
index ed6678101975..6faa1246efb9 100644
--- a/products/mobile/app/(tabs)/replay.tsx
+++ b/products/mobile/app/(tabs)/replay/index.tsx
@@ -1,14 +1,15 @@
import type { ReactElement } from 'react'
-
import { ReplayListScreen } from '@/features/replay/ReplayListScreen'
-
import { MobileProductGate } from '@/features/tabs/MobileProductGate'
+import { TabScene } from '@/features/tabs/TabScene'
import { FEATURE_FLAGS } from '@/lib/featureFlags'
export default function ReplayTabRoute(): ReactElement {
return (
- <MobileProductGate flag={FEATURE_FLAGS.sessionReplay}>
- <ReplayListScreen chrome="tab" />
- </MobileProductGate>
+ <TabScene tab="replay">
+ <MobileProductGate flag={FEATURE_FLAGS.sessionReplay}>
+ <ReplayListScreen chrome="tab" />
+ </MobileProductGate>
+ </TabScene>
)
}
diff --git a/products/mobile/app/(tabs)/views/_layout.tsx b/products/mobile/app/(tabs)/views/_layout.tsx
new file mode 100644
index 000000000000..64c7879530b7
--- /dev/null
+++ b/products/mobile/app/(tabs)/views/_layout.tsx
@@ -0,0 +1,6 @@
+import { Stack } from 'expo-router'
+import type { ReactElement } from 'react'
+
+export default function TabStack(): ReactElement {
+ return <Stack screenOptions={{ headerShown: false }} />
+}
diff --git a/products/mobile/app/(tabs)/views.tsx b/products/mobile/app/(tabs)/views/index.tsx
similarity index 52%
rename from products/mobile/app/(tabs)/views.tsx
rename to products/mobile/app/(tabs)/views/index.tsx
index 2d0618b284a4..6c6a12bf6ee8 100644
--- a/products/mobile/app/(tabs)/views.tsx
+++ b/products/mobile/app/(tabs)/views/index.tsx
@@ -1,7 +1,12 @@
import type { ReactElement } from 'react'
+import { TabScene } from '@/features/tabs/TabScene'
import { ViewsScreen } from '@/features/views/list/ViewsScreen'
export default function ViewsRoute(): ReactElement {
- return <ViewsScreen />
+ return (
+ <TabScene tab="views">
+ <ViewsScreen />
+ </TabScene>
+ )
}
diff --git a/products/mobile/app/_layout.tsx b/products/mobile/app/_layout.tsx
index 24fe667ddd39..d1ffb9a585d9 100644
--- a/products/mobile/app/_layout.tsx
+++ b/products/mobile/app/_layout.tsx
@@ -1,12 +1,13 @@
import { QueryClientProvider } from '@tanstack/react-query'
-import { Stack, useSegments } from 'expo-router'
+import { DarkTheme, DefaultTheme, Stack, ThemeProvider, useSegments } from 'expo-router'
import * as SplashScreen from 'expo-splash-screen'
import { StatusBar } from 'expo-status-bar'
-import { type ReactElement, useEffect, useState } from 'react'
+import { type ReactElement, useEffect, useMemo, useState } from 'react'
import { StyleSheet, View } from 'react-native'
import { GestureHandlerRootView } from 'react-native-gesture-handler'
import { KeyboardProvider } from 'react-native-keyboard-controller'
-import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context'
+import { ReservedRegionsProvider } from 'react-native-reserved-regions'
+import { SafeAreaProvider } from 'react-native-safe-area-context'
import { queryClient } from '@/api/queryClient'
import { installAuthProvider, useAuthStore } from '@/auth/authStore'
import { BootSplash } from '@/auth/BootSplash'
@@ -14,6 +15,7 @@ import { SPLASH_TIMEOUT_MS, shouldHideSplash, useBootGate } from '@/auth/bootGat
import { useAuthRedirect } from '@/auth/useAuthRedirect'
import { useDemoHydrated } from '@/demo/demoMode'
import { installOfflineCache } from '@/features/offlineCache'
+import { MobileScene } from '@/ui/MobileScene'
import '@/features/chat/draftPersistence'
import { AiApprovalDialog } from '@/features/ai/AiApprovalDialog'
import { useHedgehogWidgetSync } from '@/features/hedgehog/useHedgehogWidgetSync'
@@ -31,6 +33,10 @@ import { createStyles, useTheme } from '@/ui/theme'
export { RouteErrorBoundary as ErrorBoundary }
+function renderMobileScene({ children, route }: { children: ReactElement; route: { name: string } }): ReactElement {
+ return route.name === '(tabs)' ? children : <MobileScene>{children}</MobileScene>
+}
+
SplashScreen.preventAutoHideAsync().catch(() => undefined)
SplashScreen.setOptions({ fade: true, duration: 250 })
installAuthProvider()
@@ -52,6 +58,21 @@ export default function RootLayout(): ReactElement {
const firstScreenReady = useBootGate((state) => state.firstScreenReady)
const segments = useSegments()
const { colors, scheme } = useTheme()
+ const navigationTheme = useMemo(() => {
+ const base = scheme === 'dark' ? DarkTheme : DefaultTheme
+ return {
+ ...base,
+ colors: {
+ ...base.colors,
+ primary: colors.ink,
+ background: colors.background,
+ card: colors.background,
+ text: colors.ink,
+ border: colors.hairline,
+ notification: colors.orange,
+ },
+ }
+ }, [colors, scheme])
const styles = useStyles()
const [timedOut, setTimedOut] = useState(false)
const [splashHidden, setSplashHidden] = useState(false)
@@ -92,27 +113,30 @@ export default function RootLayout(): ReactElement {
return (
<GestureHandlerRootView style={styles.root}>
<SafeAreaProvider>
- <SafeAreaView style={styles.root} edges={['left', 'right']}>
+ <ReservedRegionsProvider style={styles.root}>
<SceneFrame>
<KeyboardProvider>
<QueryClientProvider client={queryClient}>
<StatusBar style={scheme === 'dark' ? 'light' : 'dark'} />
{/* Screens mount only after the session loads, so no query runs without a token. */}
{ready ? (
- <Stack
- screenOptions={{
- headerShown: false,
- contentStyle: { backgroundColor: colors.background },
- }}
- >
- <Stack.Screen
- name="chat"
- dangerouslySingular={(): string => 'chat'}
- options={{
- presentation: 'card',
+ <ThemeProvider value={navigationTheme}>
+ <Stack
+ screenLayout={renderMobileScene}
+ screenOptions={{
+ headerShown: false,
+ contentStyle: { backgroundColor: colors.background },
}}
- />
- </Stack>
+ >
+ <Stack.Screen
+ name="chat"
+ dangerouslySingular={(): string => 'chat'}
+ options={{
+ presentation: 'card',
+ }}
+ />
+ </Stack>
+ </ThemeProvider>
) : null}
{!splashHidden && (
<View style={StyleSheet.absoluteFill} onLayout={hideNativeSplash}>
@@ -123,7 +147,7 @@ export default function RootLayout(): ReactElement {
</QueryClientProvider>
</KeyboardProvider>
</SceneFrame>
- </SafeAreaView>
+ </ReservedRegionsProvider>
</SafeAreaProvider>
</GestureHandlerRootView>
)
diff --git a/products/mobile/docs/DECISIONS.md b/products/mobile/docs/DECISIONS.md
index d27cf4eae698..f700236c830d 100644
--- a/products/mobile/docs/DECISIONS.md
+++ b/products/mobile/docs/DECISIONS.md
@@ -289,8 +289,9 @@ See [DATA.md](DATA.md) for the endpoint map and every adapter rule.
- **Submissions only from production builds on `master`.** Preview builds use ad hoc signing, which App Store Connect does not take, so TestFlight gets production builds. The Mobile Build workflow uses `--auto-submit` with `--no-wait`, so EAS submits the build it just made, not the previous one.
- **eas-cli 24.8.0 is pinned in CI** instead of `latest`, so a new release does not change a release build without a review.
- **Mobile CI reads Node from `.node-version` and pnpm from this `package.json`**, not from the repo root, so CI, EAS and local runs use the same versions. The check is not required, so it can use trigger paths.
-- **Expo SDK 58 owns the iOS scene life cycle.** Its generated AppDelegate and scene delegate support Xcode 27 natively; the SDK 57 backport is removed. The version bump and native release request remain with the dependent Duo layout change.
+- **Expo SDK 58 owns the iOS scene life cycle.** Its generated AppDelegate and scene delegate support Xcode 27 and Duo natively; the SDK 57 scene-life-cycle backport is removed. The system vertical-bar signal enables native tabs and toolbars with the existing icons and Chat action. Outside that rail, the app retains its original floating navigation. The same iOS navigator stays mounted across pose changes. `react-native-reserved-regions` provides scene-local fold and occlusion frames for content and overlays. The existing list/detail tree stays mounted through resizing; Expo Router's alpha SplitView is not used.
- **Victory retains its gesture builder on RNGH 3.** The pinned `victory-native` patch names `LegacyComposedGesture` in the source and public declaration. It changes types only: RNGH 3's detector supports the existing gesture builder at runtime. Jest uses Reanimated's resolver for its JavaScript runtime.
+
- **`EXPO_PUBLIC_DEMO_MODE=1` sets the first value of the demo flag.** The saved value wins after that, so leaving demo mode in Settings sticks.
- **The demo walkthrough is an Argent flow** (`.argent/flows/demo-smoke.yaml`) that ends by tapping Exit demo, so it can run twice in a row. It uses `testID`s except for the hand-off scrim, which it taps by its "Close" label.
diff --git a/products/mobile/docs/DESIGN.md b/products/mobile/docs/DESIGN.md
index e4d8f6682bd6..2a0dbb1b59b6 100644
--- a/products/mobile/docs/DESIGN.md
+++ b/products/mobile/docs/DESIGN.md
@@ -112,11 +112,19 @@ The native build supports rotation; iOS builds use Xcode 27.1 for the full Duo d
It retries the reveal as rows are measured, and stops if the reader starts scrolling.
Both inbox lists prefetch reports as rows become visible, including rows beyond the initial prefetch window.
The report's inbox pane only prefetches while it is visible and its screen is focused.
-- Navigation uses a side rail in sufficiently tall, wide landscape windows, or when a side safe area signals side chrome.
- It requires at least 600pt of safe width; narrow cover displays keep the phone navigation and full reading width.
- The rail follows the side with the larger inset. Short windows keep horizontal tab navigation and the report's Back control,
- without adding a second navigation bar below its actions.
- Custom controls stay inside safe content; they do not occupy native reserved regions or infer a hinge angle.
+- iOS follows the system's vertical-bar signal. When the rail is active, native tabs and stack toolbar buttons occupy it.
+ Subscribe to Expo's initial edge event; its synchronous edge getter can deadlock React's event beat during startup.
+ They use raster copies of the existing app glyphs, icon-only tab labels, and a distinct Chat action.
+ Without a vertical rail, the native tab bar is hidden and the existing floating pill and Chat button remain.
+ Native header options reset when the vertical system rail disappears.
+ Navigation pin toasts and Undo live above the native tab host so tab visibility changes preserve them.
+ The iOS navigator stays mounted across these transitions. Android retains its existing custom navigation.
+ Page titles, the logomark, and header backgrounds keep the app's original styling in every pose.
+ Regenerate native glyph images from their SVG components with `node scripts/make-navigation-icons.mjs` (`rsvg-convert` required).
+- Active division regions determine the inbox and report boundary, including a horizontal fold. If the panes are too small for a pair, the report stays inside the detail pane. Each pane must have enough
+ reading space; a narrow window keeps one report instance. A flat display uses the normal width-based split.
+ Measure regions above navigator transitions and translate them into the scene's safe content coordinates; a provider inside an animating screen can retain a translated fold frame.
+- Paired reports keep their heading in the detail pane, leaving the inbox heading clear.
- Reports keep their contextual Chat action; their navigation bar does not add a second compose button.
The report action bar stays in the page layout when the keyboard opens or the window rotates.
With a navigation rail beside native side chrome, its bottom gutter is 16pt; phone layouts retain their bottom safe-area spacing.
@@ -128,11 +136,15 @@ The native build supports rotation; iOS builds use Xcode 27.1 for the full Duo d
The first visible pin anchors the list when its columns change; chart tooltips can close as their canvases resize.
The chosen pin stays anchored through deferred row measurements until the user scrolls.
- Sheets have a bounded width on expanded windows. Their height follows their current scene, including rotation and Split View.
- Their floating presentation uses the full safe window width, even when opened from a narrow report pane.
+ Sheet contents receive that pane’s dimensions and shrink their scroll areas to keep controls reachable.
+ Their floating presentation uses a safe pane, even when opened from a narrow report list. Active folds and occlusions keep sheets and picker cards on one side without resetting their form state.
Floating sheets subtract their bottom margin from the available height so their top stays below the safe area.
Resolve and Dismiss resize above the keyboard; their headings scroll with the form in short windows while Confirm stays visible.
Assignee and Project cards cap their width at 600pt; navigation menus cap at 400pt.
Android Back dismisses the top sheet or card on the focused screen before navigating away from that page.
+ Native rail actions switch to Close while an overlay is open, and native tabs are disabled.
+ Row menus convert window measurements into overlay coordinates
+ and close when their measured frame or reserved regions change, so a stale anchor cannot survive rotation.
- Full-screen charts use the space remaining below the title and above the safe bottom edge, including short landscape phones.
## Component inventory
diff --git a/products/mobile/docs/TESTING.md b/products/mobile/docs/TESTING.md
index e9da17ed18ee..a518d4266a7d 100644
--- a/products/mobile/docs/TESTING.md
+++ b/products/mobile/docs/TESTING.md
@@ -81,15 +81,14 @@ The dummy's normal development shortcut can choose the latest project; the expli
## Duo and resizable windows
-Use Xcode 27.1 or newer with an iPhone Duo runtime. Simulator checks supplement the required
-physical iOS and Android before-and-after screenshots.
+Use Xcode 27.1 or newer with an iPhone Duo runtime. Capture matching native before-and-after screens on iOS and Android; simulators and emulators qualify, as described in `../AGENTS.md`.
1. Open a report unfolded, scroll it, open Resolve and enter a note. Fold, unfold, rotate and
- enter Split View on either side. Verify the report, scroll position and note remain.
+ enter Split View on either side. Include a half-open pose with an active fold. Verify the report, scroll position and note remain, and sheets stay within one safe pane. In a short horizontal pane, open Model, scroll to its last option, and use Reset. When a fold leaves panes too small for an inbox/report pair, verify that the single report stays on one side.
2. Change filters in the expanded inbox pane and select another report. Verify its highlight,
data and actions. A confirmation sheet must block the inbox and navigation behind its scrim.
3. Tap Home from a report and switch Chats and Views through horizontal navigation and the rail.
- Check pinned Errors and Sessions slots, larger text and shorter windows too.
+ Check pinned Errors and Sessions slots, larger text and shorter windows too. On Duo with a vertical system rail, verify the original icons and Chat action occupy native tabs and toolbars, without tab labels or a second app rail. On a regular iPhone and on Android, verify the original floating pill and Chat button. Opening a sheet must block the header and navigation behind its scrim. Rotate back to horizontal bars from a report, Chat, and each tab; verify that no native header remains above the custom controls. Pin and unpin Errors or Sessions from Views and use Undo after the tab host remounts.
4. Enter a chat draft, queue a message and open Model. Resize with a streaming reply and the
keyboard visible. Keep the conversation, draft and queue without a duplicate send or stream.
5. Scroll Views to a later chart pin, expand and collapse the window, and verify the same pin
diff --git a/products/mobile/releases/requests/native-1100.json b/products/mobile/releases/requests/native-1100.json
new file mode 100644
index 000000000000..a94319b2c7f0
--- /dev/null
+++ b/products/mobile/releases/requests/native-1100.json
@@ -0,0 +1,8 @@
+{
+ "schemaVersion": 1,
+ "id": "native-1100",
+ "kind": "native",
+ "runtimeVersion": "1.10.0",
+ "previousRelease": "native-190",
+ "notes": "Upgrade to Expo SDK 58 with native iOS navigation and fold-aware content, sheets and menus. Verify Duo cover, open and half-open layouts, report and chat state through resizing, and navigation and charts on regular iPhone and Android."
+}
diff --git a/products/mobile/scripts/make-navigation-icons.mjs b/products/mobile/scripts/make-navigation-icons.mjs
new file mode 100644
index 000000000000..beddae4353c5
--- /dev/null
+++ b/products/mobile/scripts/make-navigation-icons.mjs
@@ -0,0 +1,47 @@
+import { execFileSync } from 'node:child_process'
+import { mkdirSync, readFileSync } from 'node:fs'
+import { fileURLToPath } from 'node:url'
+
+const root = new URL('../', import.meta.url)
+const icons = {
+ home: ['HomeIcon', 24, 2],
+ chats: ['SpacesIcon', 24, 2],
+ views: ['ViewsIcon', 24, 2],
+ errors: ['ErrorTriangleIcon', 24, 2],
+ replay: ['RecordingIcon', 24, 2],
+ compose: ['ComposeIcon', 24, 2],
+ filter: ['FilterIcon', 22, 2],
+ more: ['MoreIcon', 22, 0],
+ back: ['ChevronLeftIcon', 20, 2],
+ next: ['ChevronRightIcon', 20, 2],
+ external: ['ExternalLinkIcon', 20, 2],
+ close: ['CloseIcon', 20, 2.4],
+ done: ['CheckIcon', 20, 2],
+}
+const destination = new URL('src/ui/icons/native/', root)
+mkdirSync(destination, { recursive: true })
+for (const [name, [component, size, stroke]] of Object.entries(icons)) {
+ const source = readFileSync(new URL(`src/ui/icons/${component}.tsx`, root), 'utf8')
+ const shapes = source.match(/<(?:Path|Rect|Circle)\b[^>]*?\/>/g)
+ if (!shapes?.length) throw new Error(`No SVG geometry in ${component}`)
+ const geometry = shapes
+ .join('')
+ .replace(/<(Path|Rect|Circle)/g, (_, tag) => `<${tag.toLowerCase()}`)
+ .replace(/=\{([\d.]+)\}/g, '="$1"')
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="${size}" height="${size}" fill="${stroke ? 'none' : 'black'}" stroke="${stroke ? 'black' : 'none'}" stroke-width="${stroke}" stroke-linecap="round" stroke-linejoin="round">${geometry}</svg>`
+ for (const scale of [1, 2, 3]) {
+ const suffix = scale === 1 ? '' : `@${scale}x`
+ execFileSync(
+ 'rsvg-convert',
+ [
+ '-w',
+ String(size * scale),
+ '-h',
+ String(size * scale),
+ '-o',
+ fileURLToPath(new URL(`${name}${suffix}.png`, destination)),
+ ],
+ { input: svg }
+ )
+ }
+}
diff --git a/products/mobile/src/auth/BootSplash.test.tsx b/products/mobile/src/auth/BootSplash.test.tsx
index 5a090b3f3e22..fe05c1ffb5ea 100644
--- a/products/mobile/src/auth/BootSplash.test.tsx
+++ b/products/mobile/src/auth/BootSplash.test.tsx
@@ -12,6 +12,9 @@ jest.mock('expo-router', () => {
const { View } = jest.requireActual<typeof import('react-native')>('react-native')
const segments = ['(tabs)', 'inbox']
return {
+ DarkTheme: jest.requireActual('expo-router').DarkTheme,
+ DefaultTheme: jest.requireActual('expo-router').DefaultTheme,
+ ThemeProvider: jest.requireActual('expo-router').ThemeProvider,
Stack: Object.assign(() => createElement(View, { testID: 'app-screens' }), { Screen: () => null }),
useSegments: () => segments,
}
diff --git a/products/mobile/src/features/chat/ChatHeader.test.tsx b/products/mobile/src/features/chat/ChatHeader.test.tsx
index 3a7ed7615cf0..f960a2547d21 100644
--- a/products/mobile/src/features/chat/ChatHeader.test.tsx
+++ b/products/mobile/src/features/chat/ChatHeader.test.tsx
@@ -1,6 +1,7 @@
import { act, fireEvent, render, screen } from '@testing-library/react-native'
import * as Clipboard from 'expo-clipboard'
import type { ReactElement } from 'react'
+import { Platform } from 'react-native'
import { taskWebUrl } from '@/model/adapters/chats'
import { OverlayHost } from '@/ui/OverlayPortal'
@@ -132,3 +133,11 @@ describe('ChatHeader', () => {
expect(screen.getByTestId('chat-more').props.accessibilityState.expanded).toBe(false)
})
})
+
+const originalPlatform = Platform.OS
+beforeAll(() => {
+ Platform.OS = 'android'
+})
+afterAll(() => {
+ Platform.OS = originalPlatform
+})
diff --git a/products/mobile/src/features/chat/ChatHeader.tsx b/products/mobile/src/features/chat/ChatHeader.tsx
index 9ede2c1143aa..ada60600b959 100644
--- a/products/mobile/src/features/chat/ChatHeader.tsx
+++ b/products/mobile/src/features/chat/ChatHeader.tsx
@@ -1,6 +1,5 @@
import { type ReactElement, type RefObject, useState } from 'react'
-import type { ViewInstance } from 'react-native'
-import { View } from 'react-native'
+import { View, type ViewInstance } from 'react-native'
import { useToasts, ViewsToast } from '@/features/views/ViewsToast'
import { useAsyncAction } from '@/lib/useAsyncAction'
@@ -14,9 +13,10 @@ import { Pressable44 } from '@/ui/Pressable44'
import { screenLayout } from '@/ui/screenLayout'
import { createStyles, useTheme } from '@/ui/theme'
import { iconSizes, layout, radii } from '@/ui/tokens'
+import { useNativeRail } from '@/ui/useNativeRail'
import { useScreenInsets } from '@/ui/useScreenInsets'
-
import { ChatHeaderMenu } from './ChatHeaderMenu'
+import { NativeChatChrome } from './NativeChatChrome'
import { useCopyChatLink } from './useCopyChatLink'
const HEADER_TOP = screenLayout.top - layout.designStatusBar
@@ -47,6 +47,7 @@ export function ChatHeader({
const { colors, shadows } = useTheme()
const styles = useStyles()
const insets = useScreenInsets()
+ const nativeRail = useNativeRail()
const [menuOpen, setMenuOpen] = useState(false)
const toasts = useToasts()
const { copyLink, copying } = useCopyChatLink(toasts.show)
@@ -81,8 +82,18 @@ export function ChatHeader({
>
<BlurEdge solid={0.7} blurTarget={blurTarget} />
<FadeEdge direction="down" solid={0.7} opacity={layout.chromeTint} />
- <BackChip onPress={onBack} testID="chat-back" />
- {webUrl || onArchive ? (
+ {nativeRail ? (
+ <NativeChatChrome
+ onBack={onBack}
+ onNewChat={onNewChat}
+ onMore={() => setMenuOpen(true)}
+ hasActions={!!(webUrl || onArchive)}
+ disabledReason={newChatDisabledReason}
+ />
+ ) : (
+ <BackChip onPress={onBack} testID="chat-back" />
+ )}
+ {!nativeRail && (webUrl || onArchive) ? (
<PillControl height={ROW_HEIGHT} style={[styles.actions, shadows.chip]}>
<Pressable44
onPress={() => (newChatDisabledReason ? toasts.show(newChatDisabledReason) : onNewChat())}
diff --git a/products/mobile/src/features/chat/ChatHeaderMenu.tsx b/products/mobile/src/features/chat/ChatHeaderMenu.tsx
index 2d9017c5efcd..28d1ceb24dca 100644
--- a/products/mobile/src/features/chat/ChatHeaderMenu.tsx
+++ b/products/mobile/src/features/chat/ChatHeaderMenu.tsx
@@ -1,10 +1,11 @@
import type { ReactElement } from 'react'
-import { ActivityIndicator } from 'react-native'
+import { ActivityIndicator, ScrollView } from 'react-native'
import { MenuDivider, MenuItem } from '@/features/views/list/ViewsMenu'
import { FloatingCard } from '@/ui/FloatingCard'
import { ArchiveIcon } from '@/ui/icons/ArchiveIcon'
import { CopyIcon } from '@/ui/icons/CopyIcon'
import { createStyles, useColors } from '@/ui/theme'
+import { useFloatingMenuStyle } from '@/ui/useFloatingMenuStyle'
import { useSceneDimensions } from '@/ui/useSceneDimensions'
interface ChatHeaderMenuProps {
@@ -34,6 +35,7 @@ export function ChatHeaderMenu({
const styles = useStyles()
const { width } = useSceneDimensions()
const busy = copying || archiving
+ const cardStyle = useFloatingMenuStyle(top, Math.min(272, width - 32))
return (
<FloatingCard
visible={visible}
@@ -41,23 +43,27 @@ export function ChatHeaderMenu({
transformOrigin="top right"
accessibilityLabel="Chat options"
testID="chat-header-menu"
- style={[styles.menu, { top, width: Math.min(272, width - 32) }]}
+ style={[styles.menu, cardStyle]}
>
- <MenuItem
- label="Copy link to chat"
- onPress={onCopy}
- disabled={!canCopy || busy}
- trailing={copying ? <ActivityIndicator size="small" color={colors.ink} /> : <CopyIcon size={18} />}
- testID="chat-copy-link"
- />
- <MenuDivider />
- <MenuItem
- label="Archive chat"
- onPress={onArchive}
- disabled={!canArchive || busy}
- trailing={archiving ? <ActivityIndicator size="small" color={colors.ink} /> : <ArchiveIcon size={18} />}
- testID="chat-archive"
- />
+ <ScrollView>
+ <MenuItem
+ label="Copy link to chat"
+ onPress={onCopy}
+ disabled={!canCopy || busy}
+ trailing={copying ? <ActivityIndicator size="small" color={colors.ink} /> : <CopyIcon size={18} />}
+ testID="chat-copy-link"
+ />
+ <MenuDivider />
+ <MenuItem
+ label="Archive chat"
+ onPress={onArchive}
+ disabled={!canArchive || busy}
+ trailing={
+ archiving ? <ActivityIndicator size="small" color={colors.ink} /> : <ArchiveIcon size={18} />
+ }
+ testID="chat-archive"
+ />
+ </ScrollView>
</FloatingCard>
)
}
diff --git a/products/mobile/src/features/chat/ChatScreen.test.tsx b/products/mobile/src/features/chat/ChatScreen.test.tsx
index 0b7374cfaa40..8ac0333ae8cf 100644
--- a/products/mobile/src/features/chat/ChatScreen.test.tsx
+++ b/products/mobile/src/features/chat/ChatScreen.test.tsx
@@ -1,5 +1,5 @@
import { act, fireEvent, render, screen } from '@testing-library/react-native'
-import { TextInput } from 'react-native'
+import { Platform, TextInput } from 'react-native'
import { ChatScreen } from './ChatScreen'
import { queueActions, queueReducer } from './messageQueue'
import { useSession } from './session/useSession'
@@ -374,3 +374,11 @@ describe('chat send preparation', () => {
expect(screen.getByText('Keep this question')).toBeTruthy()
})
})
+
+const originalPlatform = Platform.OS
+beforeAll(() => {
+ Platform.OS = 'android'
+})
+afterAll(() => {
+ Platform.OS = originalPlatform
+})
diff --git a/products/mobile/src/features/chat/ChatScreen.tsx b/products/mobile/src/features/chat/ChatScreen.tsx
index 692531fcc7e9..18df8f9ec131 100644
--- a/products/mobile/src/features/chat/ChatScreen.tsx
+++ b/products/mobile/src/features/chat/ChatScreen.tsx
@@ -1,8 +1,8 @@
import { BlurTargetView } from 'expo-blur'
import { usePathname } from 'expo-router'
import { type ReactElement, useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react'
-import type { ViewInstance } from 'react-native'
-import { Keyboard, ScrollView, type TextInputInstance, View } from 'react-native'
+import type { TextInputInstance, ViewInstance } from 'react-native'
+import { Keyboard, ScrollView, View } from 'react-native'
import { useReanimatedKeyboardAnimation } from 'react-native-keyboard-controller'
import Animated, { useAnimatedStyle } from 'react-native-reanimated'
import { useAuthStore } from '@/auth/authStore'
@@ -21,7 +21,8 @@ import type { InboxItem, ReportView } from '@/model/types'
import { READING_WIDTH } from '@/ui/adaptiveLayout'
import { OverlayHost } from '@/ui/OverlayPortal'
import { createStyles } from '@/ui/theme'
-import { useSceneDimensions } from '@/ui/useSceneDimensions'
+import { useOverlayFrame } from '@/ui/useOverlayFrame'
+import { useOverlayPane } from '@/ui/useOverlayPane'
import { useScreenInsets } from '@/ui/useScreenInsets'
import { defaultModelSelection, isPermissionMode, modeLabel } from '../handoff/runOptions'
@@ -100,7 +101,9 @@ export function ChatScreen({
}: ChatScreenProps): ReactElement {
const styles = useStyles()
const insets = useScreenInsets()
- const { height: sceneHeight, width: sceneWidth } = useSceneDimensions()
+ const pane = useOverlayPane()
+ const frame = useOverlayFrame()
+ const { height: sceneHeight, width: sceneWidth } = pane
const compact = sceneHeight < 480 && sceneWidth >= 600
const headerHeight = compact ? CHAT_COMPACT_HEADER_HEIGHT : CHAT_HEADER_HEIGHT
const now = useNow()
@@ -109,7 +112,7 @@ export function ChatScreen({
const session = useSession(target)
const scope = useProjectScope()
const { aiIncident } = usePostHogStatus(scope?.host)
- const headerInset = insets.top + headerHeight
+ const headerInset = pane.y === 0 ? insets.top + headerHeight : 0
const contentInset = aiIncident ? 0 : headerInset
const demo = useDataMode() === 'demo'
const keyboard = useReanimatedKeyboardAnimation()
@@ -277,7 +280,12 @@ export function ChatScreen({
const mentionItems = useMemo(() => items.filter((item) => !attached.includes(item.reportId)), [items, attached])
const canMention = attachedObject === null && attached.length < MAX_ATTACHED_REPORTS && mentionItems.length > 0
const bottomInset = insets.bottom
- const keyboardStyle = useAnimatedStyle(() => ({ paddingBottom: Math.max(-keyboard.height.value, bottomInset) }))
+ const keyboardStyle = useAnimatedStyle(() => ({
+ paddingBottom: Math.max(
+ pane.y + pane.height - frame.height - keyboard.height.value,
+ pane.y + pane.height >= frame.height ? bottomInset : 0
+ ),
+ }))
// A message sent before the stored history loads would land in a thread the person cannot see yet.
const composerReady = composerDraft.ready && !composerDraft.queuePending && historyStatus === 'idle'
const ready = composerReady && !preparing && !session.isSending
@@ -621,7 +629,19 @@ export function ChatScreen({
<View style={styles.page} testID="chat-screen">
<OverlayHost>
<View style={styles.page}>
- <BlurTargetView ref={blurTarget} style={styles.body}>
+ <BlurTargetView
+ ref={blurTarget}
+ style={[
+ styles.body,
+ {
+ position: 'absolute',
+ left: pane.x + Math.max(0, (pane.width - READING_WIDTH) / 2),
+ top: pane.y,
+ width: Math.min(pane.width, READING_WIDTH),
+ height: pane.height,
+ },
+ ]}
+ >
<Animated.View style={[styles.keyboard, keyboardStyle]}>
{aiIncident ? (
<View style={{ paddingTop: headerInset }}>
diff --git a/products/mobile/src/features/chat/NativeChatChrome.test.tsx b/products/mobile/src/features/chat/NativeChatChrome.test.tsx
new file mode 100644
index 000000000000..651206986c56
--- /dev/null
+++ b/products/mobile/src/features/chat/NativeChatChrome.test.tsx
@@ -0,0 +1,38 @@
+import { Stack, useRouter } from 'expo-router'
+import { fireEvent, renderRouter, screen } from 'expo-router/testing-library'
+import { type ReactElement, useState } from 'react'
+import { Button, TextInput, View } from 'react-native'
+
+import { NativeChatChrome } from './NativeChatChrome'
+
+function Chat(): ReactElement {
+ const router = useRouter()
+ const [text, setText] = useState('Keep this draft')
+ const [revision, setRevision] = useState(0)
+ return (
+ <View>
+ <NativeChatChrome
+ onBack={() => router.back()}
+ onNewChat={() => setText('')}
+ onMore={() => undefined}
+ hasActions
+ disabledReason={revision % 2 ? 'Saving draft' : undefined}
+ />
+ <TextInput testID="draft" value={text} onChangeText={setText} />
+ <Button title="Update session" onPress={() => setRevision((value) => value + 1)} />
+ </View>
+ )
+}
+
+function Layout(): ReactElement {
+ return <Stack />
+}
+
+test('keeps the native chat and its draft mounted while session actions change', async () => {
+ const app = await renderRouter({ _layout: Layout, chat: Chat }, { initialUrl: '/chat' })
+ const input = screen.getByTestId('draft')
+ for (let index = 0; index < 4; index++) fireEvent.press(screen.getByText('Update session'))
+ expect(screen.getByTestId('draft')).toBe(input)
+ expect(input.props.value).toBe('Keep this draft')
+ expect(app.getPathname()).toBe('/chat')
+})
diff --git a/products/mobile/src/features/chat/NativeChatChrome.tsx b/products/mobile/src/features/chat/NativeChatChrome.tsx
new file mode 100644
index 000000000000..e504e8260b7a
--- /dev/null
+++ b/products/mobile/src/features/chat/NativeChatChrome.tsx
@@ -0,0 +1,86 @@
+import { Stack } from 'expo-router'
+import { type ReactElement, useCallback, useMemo, useRef } from 'react'
+import { nativeIcons } from '@/ui/icons/nativeIcons'
+import { useOverlayDismiss } from '@/ui/overlayDismiss'
+import { useColors } from '@/ui/theme'
+import { useNativeHeaderCleanup } from '@/ui/useNativeHeaderCleanup'
+
+export function NativeChatChrome({
+ onBack,
+ onNewChat,
+ onMore,
+ hasActions,
+ disabledReason,
+}: {
+ onBack: () => void
+ onNewChat: () => void
+ onMore: () => void
+ hasActions: boolean
+ disabledReason?: string
+}): ReactElement {
+ useNativeHeaderCleanup()
+ const colors = useColors()
+ const dismiss = useOverlayDismiss()
+ const latest = useRef({ onBack, onNewChat, onMore, dismiss })
+ latest.current = { onBack, onNewChat, onMore, dismiss }
+ const back = useCallback(() => (latest.current.dismiss ?? latest.current.onBack)(), [])
+ const compose = useCallback(() => latest.current.onNewChat(), [])
+ const more = useCallback(() => latest.current.onMore(), [])
+ const options = useMemo(
+ () => ({
+ headerShown: true,
+ headerTransparent: true,
+ headerStyle: { backgroundColor: colors.background },
+ headerLargeStyle: { backgroundColor: colors.background },
+ headerShadowVisible: false,
+ scrollEdgeEffects: { top: 'hidden' as const },
+ headerTitle: '',
+ headerTintColor: colors.ink,
+ headerBackVisible: false,
+ gestureEnabled: !dismiss,
+ }),
+ [colors.ink, colors.background, dismiss]
+ )
+ const leading = useMemo(
+ () => (
+ <Stack.Toolbar.Button
+ iconRenderingMode="template"
+ icon={dismiss ? nativeIcons.close : nativeIcons.back}
+ accessibilityLabel={dismiss ? 'Close' : 'Back'}
+ onPress={back}
+ />
+ ),
+ [back, dismiss]
+ )
+ const trailing = useMemo(
+ () =>
+ !dismiss && hasActions
+ ? [
+ <Stack.Toolbar.Button
+ iconRenderingMode="template"
+ key="new"
+ icon={nativeIcons.compose}
+ accessibilityLabel="New chat"
+ disabled={!!disabledReason}
+ accessibilityHint={disabledReason}
+ onPress={compose}
+ />,
+ <Stack.Toolbar.Button
+ iconRenderingMode="template"
+ key="more"
+ icon={nativeIcons.more}
+ accessibilityLabel="Chat options"
+ onPress={more}
+ />,
+ ]
+ : null,
+ [hasActions, disabledReason, compose, more, dismiss]
+ )
+ return (
+ <>
+ <Stack.Screen options={options} />
+ <Stack.Toolbar placement="left">{leading}</Stack.Toolbar>
+ <Stack.Toolbar placement="right">{trailing}</Stack.Toolbar>
+ </>
+ )
+}
diff --git a/products/mobile/src/features/chats/ChatsScreen.tsx b/products/mobile/src/features/chats/ChatsScreen.tsx
index 3ecb8dc648d6..004934f8712c 100644
--- a/products/mobile/src/features/chats/ChatsScreen.tsx
+++ b/products/mobile/src/features/chats/ChatsScreen.tsx
@@ -17,7 +17,7 @@ import { SearchField } from '@/ui/SearchField'
import { LoadingView, StateView } from '@/ui/StateView'
import { createStyles, useColors } from '@/ui/theme'
import { iconSizes, layout } from '@/ui/tokens'
-import { bottomOffset, topOffset, useScreenInsets } from '@/ui/useScreenInsets'
+import { topOffset, useScreenInsets, useTabBottomOffset } from '@/ui/useScreenInsets'
import { toChatError } from '../chat/chatErrors'
import type { ChatSheetEntry } from '../chat/chatSheetEvents'
@@ -59,6 +59,7 @@ export function ChatsScreen(): ReactElement {
const styles = useStyles()
const router = useRouter()
const insets = useScreenInsets()
+ const tabBottom = useTabBottomOffset()
const now = useNow()
const query = useChatList()
const scope = useProjectScope()
@@ -219,10 +220,7 @@ export function ChatsScreen(): ReactElement {
ListEmptyComponent={empty ?? undefined}
keyboardShouldPersistTaps="handled"
keyboardDismissMode="on-drag"
- contentContainerStyle={[
- styles.content,
- { paddingTop: contentTop, paddingBottom: bottomOffset(insets, 120) },
- ]}
+ contentContainerStyle={[styles.content, { paddingTop: contentTop, paddingBottom: tabBottom }]}
refreshControl={
<RefreshControl
refreshing={query.isRefetching}
diff --git a/products/mobile/src/features/errors/ErrorsListScreen.tsx b/products/mobile/src/features/errors/ErrorsListScreen.tsx
index 198a680731cc..cb78d1482cf7 100644
--- a/products/mobile/src/features/errors/ErrorsListScreen.tsx
+++ b/products/mobile/src/features/errors/ErrorsListScreen.tsx
@@ -28,7 +28,7 @@ import { StateView } from '@/ui/StateView'
import { SCREEN_CONTENT_TOP } from '@/ui/screenLayout'
import { createStyles, useColors } from '@/ui/theme'
import { iconSizes, layout, radii, type } from '@/ui/tokens'
-import { bottomOffset, topOffset, useScreenInsets } from '@/ui/useScreenInsets'
+import { bottomOffset, topOffset, useScreenInsets, useTabBottomOffset } from '@/ui/useScreenInsets'
import { useScrollTitle } from '@/ui/useScrollTitle'
import {
type ErrorsChrome,
@@ -49,7 +49,7 @@ const FILTERS: readonly { key: Exclude<IssueFilter, 'all'>; label: string }[] =
{ key: 'mine', label: 'Mine' },
]
/** The bottom bar's design inset on a tab; a pushed screen has none. */
-const TAB_BOTTOM = 120
+const _TAB_BOTTOM = 120
const STACK_BOTTOM = 40
const STACK_TOAST_BOTTOM = 48
@@ -73,6 +73,7 @@ function ErrorsListBody({ chrome }: { chrome: ErrorsChrome }): ReactElement {
const styles = useStyles()
const router = useRouter()
const insets = useScreenInsets()
+ const tabBottom = useTabBottomOffset()
const scrollTitle = useScrollTitle('Errors')
const access = useFeatureAccess('errors')
const context = useErrorsContext()
@@ -129,7 +130,7 @@ function ErrorsListBody({ chrome }: { chrome: ErrorsChrome }): ReactElement {
}
const contentTop = topOffset(insets, chrome === 'tab' ? TABS_HEADER_BOTTOM : SCREEN_CONTENT_TOP)
- const contentBottom = bottomOffset(insets, chrome === 'tab' ? TAB_BOTTOM : STACK_BOTTOM)
+ const contentBottom = chrome === 'tab' ? tabBottom : bottomOffset(insets, STACK_BOTTOM)
// A pushed screen draws its own title; on a tab the shared tabs header draws it.
const stackTitle =
@@ -246,7 +247,7 @@ function ErrorsListBody({ chrome }: { chrome: ErrorsChrome }): ReactElement {
data={rows}
keyExtractor={keyOf}
renderItem={({ item }) => <IssueListRow row={item} now={now} myName={viewer.name} onOpen={openIssue} />}
- ListHeaderComponent={header}
+ ListHeaderComponent={header ?? undefined}
ListFooterComponent={
<ListPaginationFooter
noun="errors"
diff --git a/products/mobile/src/features/handoff/ModelPage.tsx b/products/mobile/src/features/handoff/ModelPage.tsx
index 9fe28cecaff8..f8bb219c238b 100644
--- a/products/mobile/src/features/handoff/ModelPage.tsx
+++ b/products/mobile/src/features/handoff/ModelPage.tsx
@@ -91,7 +91,7 @@ export function ModelPage({
const showsCost = models.some((option) => option.cost_multiplier)
return (
- <View testID="handoff-model-page">
+ <View style={styles.page} testID="handoff-model-page">
<SheetPageHeader title="Model and reasoning" onBack={onBack} testID="handoff-model-page" />
{catalogue.loading ? (
<ActivityIndicator style={styles.loading} color={colors.ink} />
@@ -178,6 +178,10 @@ export function ModelPage({
}
const useStyles = createStyles(({ colors }) => ({
+ page: {
+ flexShrink: 1,
+ minHeight: 0,
+ },
loading: {
paddingVertical: 28,
},
@@ -222,6 +226,8 @@ const useStyles = createStyles(({ colors }) => ({
list: {
marginTop: 8,
flexGrow: 0,
+ flexShrink: 1,
+ minHeight: 0,
},
harness: {
paddingHorizontal: 4,
diff --git a/products/mobile/src/features/inbox/InboxScreen.tsx b/products/mobile/src/features/inbox/InboxScreen.tsx
index 0ea30de34b9b..600248aea932 100644
--- a/products/mobile/src/features/inbox/InboxScreen.tsx
+++ b/products/mobile/src/features/inbox/InboxScreen.tsx
@@ -5,7 +5,6 @@ import { useBootGate } from '@/auth/bootGate'
import { track } from '@/lib/analytics'
import { useNow } from '@/lib/useNow'
import type { InboxItem } from '@/model/types'
-import { INBOX_PANE_WIDTH } from '@/ui/adaptiveLayout'
import { FilterIcon } from '@/ui/icons/FilterIcon'
import { InboxIcon } from '@/ui/icons/InboxIcon'
import { WarningIcon } from '@/ui/icons/WarningIcon'
@@ -13,7 +12,7 @@ import { LoadingView, StateView } from '@/ui/StateView'
import { createStyles, useColors } from '@/ui/theme'
import { iconSizes, layout } from '@/ui/tokens'
import { useAppLayout } from '@/ui/useAppLayout'
-import { bottomOffset, topOffset, useScreenInsets } from '@/ui/useScreenInsets'
+import { topOffset, useScreenInsets, useTabBottomOffset } from '@/ui/useScreenInsets'
import { apiErrorKind } from '../report/reportAnalytics'
import { TABS_HEADER_BOTTOM } from '../tabs/TabsHeader'
import { useTabHeader } from '../tabs/tabHeaderStore'
@@ -36,10 +35,11 @@ function keyFor(item: InboxItem): string {
export function InboxScreen(): ReactElement {
const styles = useStyles()
- const { paired } = useAppLayout()
+ const { paired, inboxExtent, paneAxis, paneGap } = useAppLayout()
const colors = useColors()
const router = useRouter()
const insets = useScreenInsets()
+ const tabBottom = useTabBottomOffset()
const now = useNow()
const [focused, setFocused] = useState(false)
useFocusEffect(
@@ -181,12 +181,12 @@ export function InboxScreen(): ReactElement {
)
return (
- <View style={[styles.screen, { flexDirection: 'row' }]} testID="inbox-screen">
+ <View style={[styles.screen, { flexDirection: paneAxis, gap: paired ? paneGap : 0 }]} testID="inbox-screen">
<View
style={{
flexGrow: paired ? 0 : 1,
flexShrink: paired ? 0 : 1,
- width: paired ? INBOX_PANE_WIDTH : undefined,
+ ...(paired ? (paneAxis === 'row' ? { width: inboxExtent } : { height: inboxExtent }) : {}),
minWidth: 0,
}}
>
@@ -207,10 +207,7 @@ export function InboxScreen(): ReactElement {
onEndReachedThreshold={0.5}
onViewableItemsChanged={prefetch.onViewableItemsChanged}
viewabilityConfig={prefetch.viewabilityConfig}
- contentContainerStyle={[
- styles.content,
- { paddingTop: contentTop, paddingBottom: bottomOffset(insets, 120) },
- ]}
+ contentContainerStyle={[styles.content, { paddingTop: contentTop, paddingBottom: tabBottom }]}
refreshControl={
<RefreshControl
refreshing={query.isRefetching}
diff --git a/products/mobile/src/features/inbox/ReportContextMenu.tsx b/products/mobile/src/features/inbox/ReportContextMenu.tsx
index e6ef20c2c2ea..58069b7543ef 100644
--- a/products/mobile/src/features/inbox/ReportContextMenu.tsx
+++ b/products/mobile/src/features/inbox/ReportContextMenu.tsx
@@ -1,5 +1,5 @@
import { type ComponentType, type ReactElement, type ReactNode, useState } from 'react'
-import { ActivityIndicator, type LayoutChangeEvent, Text, View } from 'react-native'
+import { ActivityIndicator, type LayoutChangeEvent, ScrollView, Text, View } from 'react-native'
import { useSafeAreaFrame } from 'react-native-safe-area-context'
import type { InboxItem } from '@/model/types'
import { FloatingCard } from '@/ui/FloatingCard'
@@ -17,13 +17,10 @@ import { Pressable44 } from '@/ui/Pressable44'
import { createStyles, useColors } from '@/ui/theme'
import { iconSizes, layout, radii, type } from '@/ui/tokens'
import { useSceneDimensions } from '@/ui/useSceneDimensions'
-import { bottomOffset, topOffset, useScreenInsets } from '@/ui/useScreenInsets'
-import { TABS_HEADER_BOTTOM } from '../tabs/TabsHeader'
-import { placeContextMenu, type RowAnchor } from './contextMenuPlacement'
+import type { RowAnchor } from './contextMenuPlacement'
+import { useContextMenuLayout } from './useContextMenuLayout'
-/** The bottom bar's design inset, the same one the inbox list pads its content by. */
-const BOTTOM_BAR_ZONE = 120
const CARD_BORDER = 1
interface ReportContextMenuProps {
@@ -119,7 +116,6 @@ export function ReportContextMenu({
}: ReportContextMenuProps): ReactElement {
const styles = useStyles()
const colors = useColors()
- const insets = useScreenInsets()
const { width: windowWidth } = useSceneDimensions()
// The overlay covers the full screen, which on Android edge-to-edge includes the navigation bar that the window height leaves out.
const { height: screenHeight } = useSafeAreaFrame()
@@ -137,13 +133,7 @@ export function ReportContextMenu({
}
// The handoff's 75% width is the content box; padding and border add 22pt.
const width = Math.round(windowWidth * 0.75) + 22
- const placement = placeContextMenu({
- rowTop: anchor.y,
- rowBottom: anchor.y + anchor.height,
- menuHeight: height ?? 0,
- topLimit: topOffset(insets, TABS_HEADER_BOTTOM),
- bottomLimit: screenHeight - bottomOffset(insets, BOTTOM_BAR_ZONE),
- })
+ const placement = useContextMenuLayout(anchor, visible, onClose, Math.min(400, width), height ?? 0)
// Until the first layout the card sits off screen, so it never shows at a spot picked without its height.
const top = height === null ? -screenHeight : placement.top
const onLayout = (event: LayoutChangeEvent): void => {
@@ -156,94 +146,96 @@ export function ReportContextMenu({
transformOrigin={placement.side === 'below' ? 'top left' : 'bottom left'}
accessibilityLabel="Report actions"
testID="inbox-row-menu"
- style={[styles.card, { top, width }]}
+ style={[styles.card, { top, left: placement.left, width: placement.width, maxHeight: placement.maxHeight }]}
>
- <View key={opens} style={styles.content} onLayout={onLayout}>
- <View style={styles.header}>
- <Text style={styles.title} numberOfLines={2}>
- {item.title}
- </Text>
- <Text style={styles.source} numberOfLines={1}>
- {item.sourceLabel}
- </Text>
- </View>
- <View style={styles.divider} />
- {showPullRequest ? (
+ <ScrollView bounces={false}>
+ <View key={opens} style={styles.content} onLayout={onLayout}>
+ <View style={styles.header}>
+ <Text style={styles.title} numberOfLines={2}>
+ {item.title}
+ </Text>
+ <Text style={styles.source} numberOfLines={1}>
+ {item.sourceLabel}
+ </Text>
+ </View>
+ <View style={styles.divider} />
+ {showPullRequest ? (
+ <ContextMenuRow
+ label="View PR"
+ Icon={GitBranchIcon}
+ disabled={pullRequestDisabled}
+ trailing={
+ <ExternalLinkIcon
+ size={16}
+ color={pullRequestDisabled ? colors.disabled : colors.tertiary}
+ />
+ }
+ onPress={onViewPullRequest}
+ testID="inbox-row-menu-view-pr"
+ />
+ ) : null}
+ {showHandoff ? (
+ <ContextMenuRow
+ label={handoffLabel}
+ Icon={PlayIcon}
+ disabled={handoffDisabled || handoffPending}
+ pending={handoffPending}
+ onPress={onHandOff}
+ testID="inbox-row-menu-handoff"
+ />
+ ) : null}
+ {handoffError ? (
+ <Text style={styles.error} accessibilityRole="alert" testID="inbox-row-menu-handoff-error">
+ {handoffError}
+ </Text>
+ ) : null}
<ContextMenuRow
- label="View PR"
- Icon={GitBranchIcon}
- disabled={pullRequestDisabled}
- trailing={
- <ExternalLinkIcon
- size={16}
- color={pullRequestDisabled ? colors.disabled : colors.tertiary}
- />
- }
- onPress={onViewPullRequest}
- testID="inbox-row-menu-view-pr"
+ label="Reassign"
+ Icon={ReassignIcon}
+ disabled={reassignDisabled || handoffPending}
+ onPress={onReassign}
+ testID="inbox-row-menu-reassign"
/>
- ) : null}
- {showHandoff ? (
<ContextMenuRow
- label={handoffLabel}
- Icon={PlayIcon}
- disabled={handoffDisabled || handoffPending}
- pending={handoffPending}
- onPress={onHandOff}
- testID="inbox-row-menu-handoff"
+ label="Resolve"
+ disabled={handoffPending}
+ Icon={CheckCircleIcon}
+ onPress={onResolve}
+ testID="inbox-row-menu-resolve"
/>
- ) : null}
- {handoffError ? (
- <Text style={styles.error} accessibilityRole="alert" testID="inbox-row-menu-handoff-error">
- {handoffError}
- </Text>
- ) : null}
- <ContextMenuRow
- label="Reassign"
- Icon={ReassignIcon}
- disabled={reassignDisabled || handoffPending}
- onPress={onReassign}
- testID="inbox-row-menu-reassign"
- />
- <ContextMenuRow
- label="Resolve"
- disabled={handoffPending}
- Icon={CheckCircleIcon}
- onPress={onResolve}
- testID="inbox-row-menu-resolve"
- />
- <ContextMenuRow
- label="Dismiss"
- disabled={handoffPending}
- Icon={EyeOffIcon}
- onPress={onDismiss}
- testID="inbox-row-menu-dismiss"
- />
- <ContextMenuRow
- label="Chat"
- disabled={handoffPending}
- Icon={ChatBubbleIcon}
- onPress={onChat}
- testID="inbox-row-menu-chat"
- />
- {item.read ? (
<ContextMenuRow
- label="Mark as unread"
+ label="Dismiss"
disabled={handoffPending}
- Icon={MailUnreadIcon}
- onPress={onMarkUnread}
- testID="inbox-row-menu-mark-unread"
+ Icon={EyeOffIcon}
+ onPress={onDismiss}
+ testID="inbox-row-menu-dismiss"
/>
- ) : (
<ContextMenuRow
- label="Mark as read"
+ label="Chat"
disabled={handoffPending}
- Icon={MailOpenIcon}
- onPress={onMarkRead}
- testID="inbox-row-menu-mark-read"
+ Icon={ChatBubbleIcon}
+ onPress={onChat}
+ testID="inbox-row-menu-chat"
/>
- )}
- </View>
+ {item.read ? (
+ <ContextMenuRow
+ label="Mark as unread"
+ disabled={handoffPending}
+ Icon={MailUnreadIcon}
+ onPress={onMarkUnread}
+ testID="inbox-row-menu-mark-unread"
+ />
+ ) : (
+ <ContextMenuRow
+ label="Mark as read"
+ disabled={handoffPending}
+ Icon={MailOpenIcon}
+ onPress={onMarkRead}
+ testID="inbox-row-menu-mark-read"
+ />
+ )}
+ </View>
+ </ScrollView>
</FloatingCard>
)
}
diff --git a/products/mobile/src/features/inbox/contextMenuPlacement.test.ts b/products/mobile/src/features/inbox/contextMenuPlacement.test.ts
index 30efd0deda1a..ef8144f649be 100644
--- a/products/mobile/src/features/inbox/contextMenuPlacement.test.ts
+++ b/products/mobile/src/features/inbox/contextMenuPlacement.test.ts
@@ -1,4 +1,9 @@
-import { type ContextMenuPlacement, type ContextMenuPlacementInput, placeContextMenu } from './contextMenuPlacement'
+import {
+ type ContextMenuPlacement,
+ type ContextMenuPlacementInput,
+ placeAnchoredMenu,
+ placeContextMenu,
+} from './contextMenuPlacement'
const limits = { topLimit: 100, bottomLimit: 700 }
@@ -38,3 +43,28 @@ describe('placeContextMenu', () => {
expect(placeContextMenu(input)).toEqual(expected)
})
})
+
+test.each([0, 84])('keeps a row menu aligned inside a host shifted %s points', (x) => {
+ expect(
+ placeAnchoredMenu({
+ anchor: { x: x + 24, y: 220, width: 300, height: 50 },
+ frame: { x, y: 20, width: 400, height: 700 },
+ pane: { x: 0, y: 0, width: 400, height: 700 },
+ width: 272,
+ height: 300,
+ })
+ ).toMatchObject({ left: 24, top: 258, width: 272 })
+})
+
+test('constrains a tall menu to the anchored side of a fold', () => {
+ const menu = placeAnchoredMenu({
+ anchor: { x: 540, y: 300, width: 300, height: 50 },
+ frame: { x: 84, y: 0, width: 867, height: 669 },
+ pane: { x: 450, y: 0, width: 417, height: 320 },
+ width: 500,
+ height: 600,
+ })
+ expect(menu.left).toBeGreaterThanOrEqual(464)
+ expect(menu.left + menu.width).toBeLessThanOrEqual(853)
+ expect(menu.top + menu.maxHeight).toBeLessThanOrEqual(306)
+})
diff --git a/products/mobile/src/features/inbox/contextMenuPlacement.ts b/products/mobile/src/features/inbox/contextMenuPlacement.ts
index 1ad2cdbbad60..c065a852620f 100644
--- a/products/mobile/src/features/inbox/contextMenuPlacement.ts
+++ b/products/mobile/src/features/inbox/contextMenuPlacement.ts
@@ -1,3 +1,4 @@
+import type { DisplayRect } from '@/ui/displayRegions'
/** A row's frame in window coordinates, from `measureInWindow`. */
export interface RowAnchor {
x: number
@@ -28,6 +29,38 @@ export interface ContextMenuPlacement {
export const CONTEXT_MENU_GAP = 8
+export function placeAnchoredMenu({
+ anchor,
+ frame,
+ pane,
+ width,
+ height,
+ gutter = 14,
+}: {
+ anchor: RowAnchor
+ frame: DisplayRect
+ pane: DisplayRect
+ width: number
+ height: number
+ gutter?: number
+}): { left: number; top: number; width: number; maxHeight: number; side: ContextMenuSide } {
+ const fittedWidth = Math.min(width, Math.max(0, pane.width - gutter * 2))
+ const maxHeight = Math.max(0, pane.height - gutter * 2)
+ const placement = placeContextMenu({
+ rowTop: anchor.y - frame.y,
+ rowBottom: anchor.y - frame.y + anchor.height,
+ menuHeight: Math.min(height, maxHeight),
+ topLimit: pane.y + gutter,
+ bottomLimit: pane.y + pane.height - gutter,
+ })
+ return {
+ ...placement,
+ left: Math.max(pane.x + gutter, Math.min(anchor.x - frame.x, pane.x + pane.width - gutter - fittedWidth)),
+ width: fittedWidth,
+ maxHeight,
+ }
+}
+
export function placeContextMenu({
rowTop,
rowBottom,
diff --git a/products/mobile/src/features/inbox/useContextMenuLayout.ts b/products/mobile/src/features/inbox/useContextMenuLayout.ts
new file mode 100644
index 000000000000..ff26e03b77f5
--- /dev/null
+++ b/products/mobile/src/features/inbox/useContextMenuLayout.ts
@@ -0,0 +1,40 @@
+import { useContext, useLayoutEffect, useRef } from 'react'
+import { useDisplayRegions } from '@/ui/displayRegionContext'
+
+import { overlayPane } from '@/ui/displayRegions'
+import { OverlayFrameContext } from '@/ui/overlayFrame'
+import { useSceneDimensions } from '@/ui/useSceneDimensions'
+import { useScreenInsets } from '@/ui/useScreenInsets'
+
+import { placeAnchoredMenu, type RowAnchor } from './contextMenuPlacement'
+
+export function useContextMenuLayout(
+ anchor: RowAnchor,
+ visible: boolean,
+ onClose: () => void,
+ width: number,
+ height: number
+): ReturnType<typeof placeAnchoredMenu> {
+ const scene = useSceneDimensions()
+ const host = useContext(OverlayFrameContext)
+ const frame = host ?? { x: 0, y: 0, width: scene.width, height: scene.height }
+ const regions = useDisplayRegions()
+ const insets = useScreenInsets()
+ const close = useRef(onClose)
+ close.current = onClose
+ const layoutKey = JSON.stringify([frame.width, frame.height, regions, insets])
+ const previous = useRef(layoutKey)
+ useLayoutEffect(() => {
+ if (previous.current !== layoutKey && visible) close.current()
+ previous.current = layoutKey
+ }, [layoutKey, visible])
+ const bounds = {
+ x: 0,
+ y: insets.top,
+ width: frame.width,
+ height: Math.max(0, frame.height - insets.top - insets.bottom),
+ }
+ const localAnchor = { ...anchor, x: anchor.x - frame.x, y: anchor.y - frame.y }
+ const pane = overlayPane(bounds, regions, localAnchor)
+ return placeAnchoredMenu({ anchor, frame, pane, width, height })
+}
diff --git a/products/mobile/src/features/projects/ProjectSheet.tsx b/products/mobile/src/features/projects/ProjectSheet.tsx
index a3a90755b059..36d153928dbf 100644
--- a/products/mobile/src/features/projects/ProjectSheet.tsx
+++ b/products/mobile/src/features/projects/ProjectSheet.tsx
@@ -1,5 +1,5 @@
import { type ReactElement, type ReactNode, useEffect, useMemo, useState } from 'react'
-import { ActivityIndicator, ScrollView, Text, TextInput, useWindowDimensions, View } from 'react-native'
+import { ActivityIndicator, ScrollView, Text, TextInput, View } from 'react-native'
import { type AuthProject, useAuthStore } from '@/auth/authStore'
import { DEMO_PROJECT_NAME } from '@/demo/briefings'
import { useDemoMode } from '@/demo/demoMode'
@@ -59,8 +59,6 @@ export function ProjectSheet({ visible, onClose, onSelect }: ProjectSheetProps):
const { colors, scheme } = useTheme()
const insets = useScreenInsets()
const { height: windowHeight } = useSceneDimensions()
- const { width: windowWidth } = useWindowDimensions()
- const side = Math.max(14, (windowWidth - insets.left - insets.right - 600) / 2)
const compact = windowHeight < 480
const top = topOffset(insets, 120)
const cardHeight = Math.max(320, Math.round((windowHeight - top) * 0.52))
@@ -179,7 +177,7 @@ export function ProjectSheet({ visible, onClose, onSelect }: ProjectSheetProps):
onClose={onClose}
accessibilityLabel="Project"
testID="project-sheet"
- style={[styles.card, compact && styles.cardCompact, { left: side, right: side }, cardStyle]}
+ style={[styles.card, compact && styles.cardCompact, cardStyle]}
>
<View style={compact ? styles.controlsCompact : undefined}>
<View style={[styles.header, compact && styles.headerCompact]}>
diff --git a/products/mobile/src/features/replay/ReplayListScreen.tsx b/products/mobile/src/features/replay/ReplayListScreen.tsx
index 4a568fa78bce..ffe715309294 100644
--- a/products/mobile/src/features/replay/ReplayListScreen.tsx
+++ b/products/mobile/src/features/replay/ReplayListScreen.tsx
@@ -23,7 +23,7 @@ import { StateView } from '@/ui/StateView'
import { SCREEN_CONTENT_TOP } from '@/ui/screenLayout'
import { createStyles, useColors } from '@/ui/theme'
import { iconSizes, layout, type } from '@/ui/tokens'
-import { bottomOffset, topOffset, useScreenInsets } from '@/ui/useScreenInsets'
+import { bottomOffset, topOffset, useScreenInsets, useTabBottomOffset } from '@/ui/useScreenInsets'
import { useScrollTitle } from '@/ui/useScrollTitle'
import { useReplayContext, useSessionList } from './hooks'
@@ -38,7 +38,7 @@ import { SessionListRow } from './SessionListRow'
import { SessionRowSkeleton } from './SessionSkeleton'
/** The bottom bar's design inset on a tab; a pushed screen has none. */
-const TAB_BOTTOM = 120
+const _TAB_BOTTOM = 120
const STACK_BOTTOM = 40
const STACK_TOAST_BOTTOM = 48
@@ -62,6 +62,7 @@ function ReplayListBody({ chrome }: { chrome: 'tab' | 'stack' }): ReactElement {
const styles = useStyles()
const router = useRouter()
const insets = useScreenInsets()
+ const tabBottom = useTabBottomOffset()
const scrollTitle = useScrollTitle('Sessions')
const back = useViewBack()
const now = useNow()
@@ -105,7 +106,7 @@ function ReplayListBody({ chrome }: { chrome: 'tab' | 'stack' }): ReactElement {
const safeWebUrl = webUrl ? safeHttpsUrl(webUrl) : undefined
const contentTop = topOffset(insets, chrome === 'tab' ? TABS_HEADER_BOTTOM : SCREEN_CONTENT_TOP)
- const contentBottom = bottomOffset(insets, chrome === 'tab' ? TAB_BOTTOM : STACK_BOTTOM)
+ const contentBottom = chrome === 'tab' ? tabBottom : bottomOffset(insets, STACK_BOTTOM)
const header =
chrome === 'stack' ? (
<View style={styles.titleBlock}>
diff --git a/products/mobile/src/features/replay/SessionChrome.tsx b/products/mobile/src/features/replay/SessionChrome.tsx
index 74018e0b58fb..1492f2bfeba4 100644
--- a/products/mobile/src/features/replay/SessionChrome.tsx
+++ b/products/mobile/src/features/replay/SessionChrome.tsx
@@ -1,7 +1,9 @@
+import { Stack } from 'expo-router'
import type { ReactElement } from 'react'
-import { View } from 'react-native'
+import { Platform, View } from 'react-native'
import { ExternalLinkIcon } from '@/ui/icons/ExternalLinkIcon'
import { MoreIcon } from '@/ui/icons/MoreIcon'
+import { nativeIcons } from '@/ui/icons/nativeIcons'
import { PillControl } from '@/ui/PillControl'
import { Pressable44 } from '@/ui/Pressable44'
import { ScreenChrome } from '@/ui/ScreenChrome'
@@ -26,6 +28,28 @@ export function SessionChrome({ onBack, onOpenFull, onMore, title }: SessionChro
onBack={onBack}
backTestID="replay-back"
title={title}
+ nativeActions={
+ Platform.OS === 'ios' ? (
+ <>
+ {onOpenFull !== undefined ? (
+ <Stack.Toolbar.Button
+ iconRenderingMode="template"
+ icon={nativeIcons.external}
+ accessibilityLabel="Open full replay"
+ disabled={!onOpenFull}
+ onPress={() => onOpenFull?.()}
+ />
+ ) : null}
+ <Stack.Toolbar.Button
+ iconRenderingMode="template"
+ icon={nativeIcons.more}
+ accessibilityLabel="More"
+ disabled={!onMore}
+ onPress={() => onMore?.()}
+ />
+ </>
+ ) : null
+ }
right={
<PillControl height={screenLayout.rowHeight}>
{onOpenFull !== undefined ? (
diff --git a/products/mobile/src/features/report/ReportScreen.test.tsx b/products/mobile/src/features/report/ReportScreen.test.tsx
index cd2a717d4533..22fcf53d2820 100644
--- a/products/mobile/src/features/report/ReportScreen.test.tsx
+++ b/products/mobile/src/features/report/ReportScreen.test.tsx
@@ -1,7 +1,7 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react-native'
import type { ReactElement, ReactNode } from 'react'
-import { AppState, Dimensions } from 'react-native'
+import { AppState, Dimensions, Platform } from 'react-native'
import { setAuthProvider } from '@/api/client'
import { useDemoMode } from '@/demo/demoMode'
@@ -44,6 +44,13 @@ const EXISTING = { uuid: 'existing-user', first_name: 'Existing', last_name: 'Re
const ADDED = { uuid: 'added-user', first_name: 'Added', last_name: 'Reviewer', email: '[email protected]' }
describe('ReportScreen', () => {
+ const originalPlatform = Platform.OS
+ beforeAll(() => {
+ Platform.OS = 'android'
+ })
+ afterAll(() => {
+ Platform.OS = originalPlatform
+ })
test.each([
{ width: 951, height: 669, navigation: true },
{ width: 874, height: 402, navigation: false },
diff --git a/products/mobile/src/features/report/ReportScreen.tsx b/products/mobile/src/features/report/ReportScreen.tsx
index 1cc340614905..4dccff7e492d 100644
--- a/products/mobile/src/features/report/ReportScreen.tsx
+++ b/products/mobile/src/features/report/ReportScreen.tsx
@@ -16,7 +16,7 @@ import {
RESOLVE_REASON_OPTIONS,
type ResolveReason,
} from '@/model/verdictReasons'
-import { INBOX_PANE_WIDTH, NAV_RAIL_WIDTH, READING_WIDTH } from '@/ui/adaptiveLayout'
+import { NAV_RAIL_WIDTH, READING_WIDTH } from '@/ui/adaptiveLayout'
import { ChartCanvasBudget } from '@/ui/chart/budget/ChartCanvasBudget'
import { FloatingCard } from '@/ui/FloatingCard'
import { WarningIcon } from '@/ui/icons/WarningIcon'
@@ -79,7 +79,16 @@ function goBackOrInbox(router: ReturnType<typeof useRouter>): void {
export function ReportScreen({ reportId, from }: ReportScreenProps): ReactElement {
const demo = useDataMode() === 'demo'
const focused = useIsFocused()
- const { rail, railSide, paired, reportNavigation: navigation } = useAppLayout()
+ const {
+ rail,
+ railSide,
+ paired,
+ inboxExtent,
+ paneAxis,
+ paneGap,
+ reportPane,
+ reportNavigation: navigation,
+ } = useAppLayout()
return (
<OverlayHost>
<View
@@ -90,19 +99,31 @@ export function ReportScreen({ reportId, from }: ReportScreenProps): ReactElemen
paddingRight: rail && railSide === 'right' ? NAV_RAIL_WIDTH : 0,
}}
>
- <View style={{ flex: 1, flexDirection: 'row' }}>
+ <View style={{ flex: 1, flexDirection: paneAxis, gap: paired ? paneGap : 0 }}>
<SceneFrame
style={{
flexGrow: 0,
flexShrink: 0,
- flexBasis: INBOX_PANE_WIDTH,
- width: INBOX_PANE_WIDTH,
+ flexBasis: inboxExtent,
+ ...(paneAxis === 'row' ? { width: inboxExtent } : { height: inboxExtent }),
display: paired ? 'flex' : 'none',
}}
>
<ReportInbox selectedReportId={reportId} active={paired && focused} />
</SceneFrame>
- <SceneFrame>
+ <SceneFrame
+ style={
+ reportPane
+ ? {
+ position: 'absolute',
+ left: reportPane.x,
+ top: reportPane.y,
+ width: reportPane.width,
+ height: reportPane.height,
+ }
+ : undefined
+ }
+ >
<ChartCanvasBudget active={focused}>
{isReportId(reportId, demo) ? (
<ReportContent reportId={reportId} from={from} />
diff --git a/products/mobile/src/features/report/TopChrome.tsx b/products/mobile/src/features/report/TopChrome.tsx
index c5f6d0ad9c15..7a8fff58ba85 100644
--- a/products/mobile/src/features/report/TopChrome.tsx
+++ b/products/mobile/src/features/report/TopChrome.tsx
@@ -1,13 +1,16 @@
-import type { ReactElement } from 'react'
-import { ActivityIndicator, View } from 'react-native'
+import { Stack, useRouter } from 'expo-router'
+import { type ReactElement, useMemo } from 'react'
+import { ActivityIndicator, Platform, useWindowDimensions, View } from 'react-native'
import Animated, { FadeIn, FadeOut } from 'react-native-reanimated'
import { ChevronLeftIcon } from '@/ui/icons/ChevronLeftIcon'
import { ChevronRightIcon } from '@/ui/icons/ChevronRightIcon'
+import { nativeIcons } from '@/ui/icons/nativeIcons'
import { ScreenChrome } from '@/ui/ScreenChrome'
import { SegmentedPill } from '@/ui/SegmentedPill'
import { SCREEN_CHROME_BOTTOM, SCREEN_CONTENT_TOP, screenLayout } from '@/ui/screenLayout'
import { createStyles, useColors } from '@/ui/theme'
import { iconSizes, motion } from '@/ui/tokens'
+import { useAppLayout } from '@/ui/useAppLayout'
import type { ScrollTitle } from '@/ui/useScrollTitle'
export const HEADLINE_GAP = SCREEN_CONTENT_TOP - SCREEN_CHROME_BOTTOM
@@ -30,6 +33,38 @@ export function TopChrome({
refreshing = false,
withPager = true,
}: TopChromeProps): ReactElement {
+ const router = useRouter()
+ const { contentWidth, paired } = useAppLayout()
+ const { height } = useWindowDimensions()
+ const navigation = useMemo(
+ () =>
+ Platform.OS === 'ios' && contentWidth >= 600 && height >= 480 ? (
+ <Stack.Toolbar.Menu iconRenderingMode="template" icon={nativeIcons.views} accessibilityLabel="Navigate">
+ <Stack.Toolbar.MenuAction
+ iconRenderingMode="template"
+ icon={nativeIcons.home}
+ onPress={() => router.navigate('/inbox')}
+ >
+ Home
+ </Stack.Toolbar.MenuAction>
+ <Stack.Toolbar.MenuAction
+ iconRenderingMode="template"
+ icon={nativeIcons.chats}
+ onPress={() => router.navigate('/chats')}
+ >
+ Chats
+ </Stack.Toolbar.MenuAction>
+ <Stack.Toolbar.MenuAction
+ iconRenderingMode="template"
+ icon={nativeIcons.views}
+ onPress={() => router.navigate('/views')}
+ >
+ Views
+ </Stack.Toolbar.MenuAction>
+ </Stack.Toolbar.Menu>
+ ) : null,
+ [contentWidth, height, router]
+ )
const styles = useStyles()
const colors = useColors()
return (
@@ -37,6 +72,28 @@ export function TopChrome({
onBack={onBack}
backTestID="report-back"
title={title}
+ hideNativeTitle={withPager && paired}
+ nativeActions={
+ Platform.OS === 'ios' && withPager ? (
+ <>
+ {navigation}
+ <Stack.Toolbar.Button
+ iconRenderingMode="template"
+ icon={nativeIcons.back}
+ accessibilityLabel="Previous report"
+ disabled={!onPrevious}
+ onPress={onPrevious}
+ />
+ <Stack.Toolbar.Button
+ iconRenderingMode="template"
+ icon={nativeIcons.next}
+ accessibilityLabel="Next report"
+ disabled={!onNext}
+ onPress={onNext}
+ />
+ </>
+ ) : null
+ }
right={
<View style={styles.actions}>
<View style={styles.refreshSlot}>
diff --git a/products/mobile/src/features/reviewers/AssigneeSheet.tsx b/products/mobile/src/features/reviewers/AssigneeSheet.tsx
index 6aacef09cfb7..73a405851b35 100644
--- a/products/mobile/src/features/reviewers/AssigneeSheet.tsx
+++ b/products/mobile/src/features/reviewers/AssigneeSheet.tsx
@@ -1,5 +1,5 @@
import { type ReactElement, useEffect, useMemo, useRef, useState } from 'react'
-import { ActivityIndicator, ScrollView, Text, TextInput, useWindowDimensions, View } from 'react-native'
+import { ActivityIndicator, ScrollView, Text, TextInput, View } from 'react-native'
import { actionErrorMessage } from '@/lib/errors'
import type { Person, Reviewer } from '@/model/types'
import { Avatar } from '@/ui/Avatar'
@@ -81,8 +81,6 @@ export function AssigneeSheet({
const { colors, scheme } = useTheme()
const insets = useScreenInsets()
const { height: windowHeight } = useSceneDimensions()
- const { width: windowWidth } = useWindowDimensions()
- const side = Math.max(14, (windowWidth - insets.left - insets.right - 600) / 2)
const compact = windowHeight < 480
const top = topOffset(insets, 120)
const cardHeight = Math.max(320, Math.round((windowHeight - top) * 0.52))
@@ -147,7 +145,7 @@ export function AssigneeSheet({
onClose={onClose}
accessibilityLabel="Assignee"
testID="assignee-sheet"
- style={[styles.card, compact && styles.cardCompact, { left: side, right: side }, cardStyle]}
+ style={[styles.card, compact && styles.cardCompact, cardStyle]}
>
<View style={compact ? styles.controlsCompact : undefined}>
<View style={[styles.header, compact && styles.headerCompact]}>
diff --git a/products/mobile/src/features/tabs/MobileProductGate.test.tsx b/products/mobile/src/features/tabs/MobileProductGate.test.tsx
index d99d576f8be7..817c0001f080 100644
--- a/products/mobile/src/features/tabs/MobileProductGate.test.tsx
+++ b/products/mobile/src/features/tabs/MobileProductGate.test.tsx
@@ -2,13 +2,15 @@ import { renderRouter } from 'expo-router/testing-library'
import type { ComponentType, ReactElement } from 'react'
import { View } from 'react-native'
import { FEATURE_FLAGS, type FeatureFlagKey, setFeatureFlags } from '@/lib/featureFlags'
-import ErrorsTab from '../../../app/(tabs)/errors'
-import ReplayTab from '../../../app/(tabs)/replay'
+import ErrorsTab from '../../../app/(tabs)/errors/index'
+import ReplayTab from '../../../app/(tabs)/replay/index'
import IssueRoute from '../../../app/errors/[id]'
import ErrorsRoute from '../../../app/errors/index'
import SessionRoute from '../../../app/replay/[sessionId]'
import ReplayRoute from '../../../app/replay/index'
+jest.mock('./TabScene', () => ({ TabScene: ({ children }: { children: React.ReactNode }) => children }))
+
jest.mock('@/features/errors/ErrorsListScreen', () => ({ ErrorsListScreen: () => null }))
jest.mock('@/features/errors/IssueScreen', () => ({ IssueScreen: () => null }))
jest.mock('@/features/replay/ReplayListScreen', () => ({ ReplayListScreen: () => null }))
diff --git a/products/mobile/src/features/tabs/NativeTabChrome.tsx b/products/mobile/src/features/tabs/NativeTabChrome.tsx
new file mode 100644
index 000000000000..3e6083abb0c7
--- /dev/null
+++ b/products/mobile/src/features/tabs/NativeTabChrome.tsx
@@ -0,0 +1,107 @@
+import { Stack, useRouter } from 'expo-router'
+import { type ReactElement, useCallback, useMemo, useRef } from 'react'
+import type { ChatSheetEntry } from '@/features/chat/chatSheetEvents'
+import { nativeIcons } from '@/ui/icons/nativeIcons'
+import { useOverlayDismiss } from '@/ui/overlayDismiss'
+import { useColors } from '@/ui/theme'
+import { useNativeHeaderCleanup } from '@/ui/useNativeHeaderCleanup'
+import type { TabHeaderSlot } from './tabHeaderStore'
+
+export function NativeTabChrome({ slot, onMore }: { slot: TabHeaderSlot | null; onMore: () => void }): ReactElement {
+ useNativeHeaderCleanup()
+ const colors = useColors()
+ const router = useRouter()
+ const dismiss = useOverlayDismiss()
+ const latest = useRef({ slot, onMore, dismiss })
+ latest.current = { slot, onMore, dismiss }
+ const close = useCallback(() => latest.current.dismiss?.(), [])
+ const filter = useCallback(() => latest.current.slot?.filter?.onPress(), [])
+ const more = useCallback(() => latest.current.onMore(), [])
+ const done = useCallback(() => latest.current.slot?.editing?.onDone(), [])
+ const compose = useCallback(
+ () => router.push({ pathname: '/chat', params: { entry: 'compose' satisfies ChatSheetEntry } }),
+ [router]
+ )
+ const options = useMemo(
+ () => ({
+ headerShown: true,
+ headerTransparent: true,
+ headerTitle: '',
+ headerBackVisible: false,
+ headerShadowVisible: false,
+ headerStyle: { backgroundColor: colors.background },
+ headerTintColor: colors.ink,
+ gestureEnabled: !dismiss,
+ scrollEdgeEffects: { top: 'hidden' as const },
+ }),
+ [colors.background, colors.ink, dismiss]
+ )
+ const editing = !!slot?.editing
+ const hasFilter = !!slot?.filter
+ const activeFilter = slot?.filter?.active ?? false
+ const leading = useMemo(
+ () =>
+ dismiss ? (
+ <Stack.Toolbar.Button
+ iconRenderingMode="template"
+ icon={nativeIcons.close}
+ accessibilityLabel="Close"
+ onPress={close}
+ />
+ ) : null,
+ [dismiss, close]
+ )
+ const trailing = useMemo(
+ () =>
+ dismiss
+ ? null
+ : editing
+ ? [
+ <Stack.Toolbar.Button
+ iconRenderingMode="template"
+ key="done"
+ icon={nativeIcons.done}
+ accessibilityLabel="Done"
+ onPress={done}
+ />,
+ ]
+ : [
+ ...(hasFilter
+ ? [
+ <Stack.Toolbar.Button
+ iconRenderingMode="template"
+ key="filter"
+ icon={nativeIcons.filter}
+ accessibilityLabel="Filter and sort"
+ selected={activeFilter}
+ onPress={filter}
+ />,
+ ]
+ : []),
+ <Stack.Toolbar.Button
+ iconRenderingMode="template"
+ key="compose"
+ icon={nativeIcons.compose}
+ accessibilityLabel="Chat"
+ variant="prominent"
+ separateBackground
+ onPress={compose}
+ />,
+ <Stack.Toolbar.Button
+ iconRenderingMode="template"
+ key="more"
+ icon={nativeIcons.more}
+ accessibilityLabel="More"
+ onPress={more}
+ />,
+ ],
+ [dismiss, editing, hasFilter, activeFilter, done, filter, compose, more]
+ )
+ return (
+ <>
+ <Stack.Screen options={options} />
+ <Stack.Toolbar placement="left">{leading}</Stack.Toolbar>
+ <Stack.Toolbar placement="right">{trailing}</Stack.Toolbar>
+ </>
+ )
+}
diff --git a/products/mobile/src/features/tabs/NativeTabsLayout.tsx b/products/mobile/src/features/tabs/NativeTabsLayout.tsx
new file mode 100644
index 000000000000..f4ad38c3919a
--- /dev/null
+++ b/products/mobile/src/features/tabs/NativeTabsLayout.tsx
@@ -0,0 +1,82 @@
+import { NativeTabs } from 'expo-router/native-tabs'
+import { type ReactElement, useRef } from 'react'
+import { useViewsOpenedEvent } from '@/features/views/list/useViewsOpenedEvent'
+import { track } from '@/lib/analytics'
+import { useMobileProductFlags } from '@/lib/featureFlags'
+import { nativeIcons } from '@/ui/icons/nativeIcons'
+import { useNavigationOverlayStore } from '@/ui/overlayDismiss'
+import { useColors } from '@/ui/theme'
+import { useNativeRail } from '@/ui/useNativeRail'
+import { useNavPins } from './navPinStore'
+import { type TabKey, useTabHeaderStore } from './tabHeaderStore'
+import { visibleNavPins } from './visibleNavPins'
+
+const LABELS: Record<TabKey, string> = {
+ inbox: 'Home',
+ chats: 'Chats',
+ views: 'Views',
+ errors: 'Errors',
+ replay: 'Sessions',
+}
+const ICONS = {
+ inbox: nativeIcons.home,
+ chats: nativeIcons.chats,
+ views: nativeIcons.views,
+ errors: nativeIcons.errors,
+ replay: nativeIcons.replay,
+}
+const TEST_IDS = {
+ inbox: 'inbox-nav-home',
+ chats: 'inbox-nav-chat',
+ views: 'inbox-nav-views',
+ errors: 'nav-pin-errors',
+ replay: 'nav-pin-replay',
+}
+
+export function NativeTabsLayout(): ReactElement {
+ const colors = useColors()
+ const nativeRail = useNativeRail()
+ const blocked = useNavigationOverlayStore((state) => state.keys.length > 0)
+ const lastFocused = useRef<TabKey | null>(null)
+ const focused = useTabHeaderStore((state) => state.focused)
+ const pins = useNavPins()
+ const flags = useMobileProductFlags()
+ const shownPins = visibleNavPins(pins, focused, flags)
+ const tabs: TabKey[] = ['inbox', 'chats', 'views', ...new Set([...shownPins, 'errors', 'replay'] as const)]
+ useViewsOpenedEvent(focused === 'views')
+ return (
+ <NativeTabs
+ hidden={!nativeRail}
+ disableHiddenAnimation
+ tintColor={colors.ink}
+ iconColor={colors.ink}
+ preferredPlacement="tabBar"
+ screenListeners={({ route }) => ({
+ focus: () => {
+ const tab = route.name as TabKey
+ useTabHeaderStore.getState().setFocused(tab)
+ if (lastFocused.current === tab) return
+ lastFocused.current = tab
+ if (tab === 'inbox') track('mobile_inbox_opened')
+ if (tab === 'chats') track('mobile_chats_opened')
+ },
+ })}
+ >
+ {tabs.map((tab) => (
+ <NativeTabs.Trigger
+ key={tab}
+ name={tab}
+ disabled={blocked}
+ hidden={(tab === 'errors' || tab === 'replay') && !shownPins.includes(tab)}
+ testID={TEST_IDS[tab]}
+ accessibilityLabel={LABELS[tab]}
+ disableAutomaticContentInsets
+ disablePopToTop
+ >
+ <NativeTabs.Trigger.Icon src={ICONS[tab]} renderingMode="template" />
+ <NativeTabs.Trigger.Label hidden>{LABELS[tab]}</NativeTabs.Trigger.Label>
+ </NativeTabs.Trigger>
+ ))}
+ </NativeTabs>
+ )
+}
diff --git a/products/mobile/src/features/tabs/NavMenu.tsx b/products/mobile/src/features/tabs/NavMenu.tsx
index c747f3b2ba4f..73c7e4881d19 100644
--- a/products/mobile/src/features/tabs/NavMenu.tsx
+++ b/products/mobile/src/features/tabs/NavMenu.tsx
@@ -1,5 +1,5 @@
import { type ComponentType, type ReactElement, useEffect, useState } from 'react'
-import { Text, View } from 'react-native'
+import { ScrollView, Text, View } from 'react-native'
import { useAuthStore } from '@/auth/authStore'
import { ProjectSheet } from '@/features/projects/ProjectSheet'
import type { PostHogStatus } from '@/features/status/usePostHogStatus'
@@ -16,6 +16,7 @@ import type { IconProps } from '@/ui/icons/types'
import { Pressable44 } from '@/ui/Pressable44'
import { createStyles, useColors } from '@/ui/theme'
import { iconSizes, radii, type } from '@/ui/tokens'
+import { useFloatingMenuStyle } from '@/ui/useFloatingMenuStyle'
import { useSceneDimensions } from '@/ui/useSceneDimensions'
import { topOffset, useScreenInsets } from '@/ui/useScreenInsets'
@@ -91,6 +92,7 @@ export function NavMenu({
const { width: windowWidth } = useSceneDimensions()
// The handoff's 75% width is the content box; padding and border add 22pt.
const width = Math.min(400, Math.round(windowWidth * 0.75) + 22)
+ const cardStyle = useFloatingMenuStyle(topOffset(insets, 60), width)
const [pickingProject, setPickingProject] = useState(false)
useEffect(() => {
@@ -120,102 +122,109 @@ export function NavMenu({
transformOrigin="top right"
accessibilityLabel="Menu"
testID="nav-menu"
- style={[styles.card, { top: topOffset(insets, 60), width }]}
+ style={[styles.card, cardStyle]}
>
- <Pressable44
- onPress={openPicker}
- disabled={signOutPending}
- accessibilityLabel={projectName}
- accessibilityHint="Switch project"
- pressedBackground={colors.sunken}
- style={styles.header}
- testID="nav-project"
- >
- <Text style={styles.project} numberOfLines={1}>
- {projectName}
- </Text>
- <ChevronUpDownIcon size={iconSizes.small} color={colors.tertiary} />
- </Pressable44>
- <View style={styles.divider} />
- {confirmingSignOut ? (
- <SignOutConfirm
- from="nav_menu"
- pending={signOutPending}
- error={signOutError}
- onCancel={onCancelSignOut}
- onConfirm={onConfirmSignOut}
- style={styles.confirm}
- testIDPrefix="nav"
- />
- ) : (
- <>
- <Pressable44
- accessibilityRole="link"
- accessibilityLabel={
- statusUpdate
- ? `PostHog status: ${statusUpdate}`
- : indicatorColor
- ? 'PostHog status: All systems operational'
- : 'PostHog status'
- }
- pressedBackground={colors.sunken}
- style={styles.row}
- onPress={onOpenStatus}
- testID="nav-status"
- >
- {indicatorColor ? (
- <View style={styles.statusIcon}>
- <View style={[styles.statusDot, { backgroundColor: colors[indicatorColor] }]} />
+ <ScrollView keyboardShouldPersistTaps="handled">
+ <Pressable44
+ onPress={openPicker}
+ disabled={signOutPending}
+ accessibilityLabel={projectName}
+ accessibilityHint="Switch project"
+ pressedBackground={colors.sunken}
+ style={styles.header}
+ testID="nav-project"
+ >
+ <Text style={styles.project} numberOfLines={1}>
+ {projectName}
+ </Text>
+ <ChevronUpDownIcon size={iconSizes.small} color={colors.tertiary} />
+ </Pressable44>
+ <View style={styles.divider} />
+ {confirmingSignOut ? (
+ <SignOutConfirm
+ from="nav_menu"
+ pending={signOutPending}
+ error={signOutError}
+ onCancel={onCancelSignOut}
+ onConfirm={onConfirmSignOut}
+ style={styles.confirm}
+ testIDPrefix="nav"
+ />
+ ) : (
+ <>
+ <Pressable44
+ accessibilityRole="link"
+ accessibilityLabel={
+ statusUpdate
+ ? `PostHog status: ${statusUpdate}`
+ : indicatorColor
+ ? 'PostHog status: All systems operational'
+ : 'PostHog status'
+ }
+ pressedBackground={colors.sunken}
+ style={styles.row}
+ onPress={onOpenStatus}
+ testID="nav-status"
+ >
+ {indicatorColor ? (
+ <View style={styles.statusIcon}>
+ <View style={[styles.statusDot, { backgroundColor: colors[indicatorColor] }]} />
+ </View>
+ ) : (
+ <GlobeIcon size={iconSizes.control} />
+ )}
+ <View style={styles.statusBody}>
+ <Text style={styles.statusTitle}>PostHog status</Text>
+ {statusUpdate ? (
+ <Text style={styles.statusSummary} numberOfLines={2}>
+ {statusUpdate}
+ </Text>
+ ) : null}
</View>
- ) : (
- <GlobeIcon size={iconSizes.control} />
- )}
- <View style={styles.statusBody}>
- <Text style={styles.statusTitle}>PostHog status</Text>
- {statusUpdate ? (
- <Text style={styles.statusSummary} numberOfLines={2}>
- {statusUpdate}
- </Text>
- ) : null}
- </View>
- <ExternalLinkIcon size={iconSizes.small} color={colors.tertiary} />
- </Pressable44>
- <View style={[styles.divider, styles.sectionDivider]} />
- {navList ? (
- <>
- <MenuRow
- label="Unpin from navigation"
- Icon={PinIcon}
- onPress={navList.onUnpin}
- testID="nav-list-unpin"
- />
- {navList.onOpenWeb ? (
+ <ExternalLinkIcon size={iconSizes.small} color={colors.tertiary} />
+ </Pressable44>
+ <View style={[styles.divider, styles.sectionDivider]} />
+ {navList ? (
+ <>
<MenuRow
- label="Open on web"
- Icon={ExternalLinkIcon}
- onPress={navList.onOpenWeb}
- testID="nav-list-open-web"
+ label="Unpin from navigation"
+ Icon={PinIcon}
+ onPress={navList.onUnpin}
+ testID="nav-list-unpin"
/>
- ) : null}
- <View style={[styles.divider, styles.sectionDivider]} />
- </>
- ) : null}
- {editPins ? (
- <>
- <MenuRow
- label="Edit pins"
- Icon={GripIcon}
- onPress={editPins.onPress}
- disabled={editPins.disabled}
- testID="views-edit-pins"
- />
- <View style={[styles.divider, styles.sectionDivider]} />
- </>
- ) : null}
- <MenuRow label="Settings" Icon={SettingsIcon} onPress={openSettings} testID="nav-settings" />
- <MenuRow label="Sign out" Icon={SignOutIcon} onPress={onSignOut} testID="nav-sign-out" />
- </>
- )}
+ {navList.onOpenWeb ? (
+ <MenuRow
+ label="Open on web"
+ Icon={ExternalLinkIcon}
+ onPress={navList.onOpenWeb}
+ testID="nav-list-open-web"
+ />
+ ) : null}
+ <View style={[styles.divider, styles.sectionDivider]} />
+ </>
+ ) : null}
+ {editPins ? (
+ <>
+ <MenuRow
+ label="Edit pins"
+ Icon={GripIcon}
+ onPress={editPins.onPress}
+ disabled={editPins.disabled}
+ testID="views-edit-pins"
+ />
+ <View style={[styles.divider, styles.sectionDivider]} />
+ </>
+ ) : null}
+ <MenuRow
+ label="Settings"
+ Icon={SettingsIcon}
+ onPress={openSettings}
+ testID="nav-settings"
+ />
+ <MenuRow label="Sign out" Icon={SignOutIcon} onPress={onSignOut} testID="nav-sign-out" />
+ </>
+ )}
+ </ScrollView>
</FloatingCard>
<ProjectSheet visible={visible && pickingProject} onClose={onClose} onSelect={switchProject} />
</>
diff --git a/products/mobile/src/features/tabs/TabScene.tsx b/products/mobile/src/features/tabs/TabScene.tsx
new file mode 100644
index 000000000000..2425ba09a3a3
--- /dev/null
+++ b/products/mobile/src/features/tabs/TabScene.tsx
@@ -0,0 +1,28 @@
+import { useIsFocused } from 'expo-router'
+import type { ReactElement, ReactNode } from 'react'
+import { Platform } from 'react-native'
+import { MobileScene } from '@/ui/MobileScene'
+import { OverlayPortal } from '@/ui/OverlayPortal'
+import { useNativeRail } from '@/ui/useNativeRail'
+import { TabsChrome } from './TabsChrome'
+import { TabsNavigation } from './TabsNavigation'
+import { type TabKey, useTabHeaderStore } from './tabHeaderStore'
+
+export function TabScene({ children, tab }: { children: ReactNode; tab: TabKey }): ReactElement {
+ const routeFocused = useIsFocused()
+ const nativeRail = useNativeRail()
+ const selectedTab = useTabHeaderStore((state) => state.focused)
+ const focused = routeFocused && selectedTab === tab
+ if (Platform.OS !== 'ios') return <>{children}</>
+ return (
+ <MobileScene>
+ {children}
+ {focused ? <TabsChrome /> : null}
+ {focused && !nativeRail ? (
+ <OverlayPortal>
+ <TabsNavigation tab={tab} />
+ </OverlayPortal>
+ ) : null}
+ </MobileScene>
+ )
+}
diff --git a/products/mobile/src/features/tabs/TabsChrome.tsx b/products/mobile/src/features/tabs/TabsChrome.tsx
new file mode 100644
index 000000000000..61a7badba29e
--- /dev/null
+++ b/products/mobile/src/features/tabs/TabsChrome.tsx
@@ -0,0 +1,121 @@
+import { useRouter } from 'expo-router'
+import { type ReactElement, useState } from 'react'
+import { Linking } from 'react-native'
+import { useAuthStore } from '@/auth/authStore'
+import { useProjectScope } from '@/auth/useProjectScope'
+import { useViewer } from '@/auth/useViewer'
+import { usePostHogStatus } from '@/features/status/usePostHogStatus'
+import { ViewsToast } from '@/features/views/ViewsToast'
+import { navListWebUrl } from '@/features/views/webLinks'
+import { track } from '@/lib/analytics'
+import { useMobileProductFlags } from '@/lib/featureFlags'
+import { safeHttpsUrl } from '@/lib/urls'
+import { useNativeRail } from '@/ui/useNativeRail'
+import { useExitDemo, useSignOutAction } from '../settings/useSignOut'
+import { NativeTabChrome } from './NativeTabChrome'
+import { NavMenu } from './NavMenu'
+import { changeNavPin } from './navPinActions'
+import { useNavPins } from './navPinStore'
+import { useNavToasts } from './navToasts'
+import { TabsHeader } from './TabsHeader'
+import { useFocusedTabHeader } from './tabHeaderStore'
+
+export function TabsChrome(): ReactElement {
+ const nativeRail = useNativeRail()
+ const router = useRouter()
+ const viewer = useViewer()
+ const { tab, slot } = useFocusedTabHeader()
+ const signedIn = useAuthStore((state) => state.signedIn)
+ const exitDemo = useExitDemo()
+ const signOut = useSignOutAction()
+ const [menuOpen, setMenuOpen] = useState(false)
+ const [confirmingSignOut, setConfirmingSignOut] = useState(false)
+ const scope = useProjectScope()
+ const status = usePostHogStatus(scope?.host)
+ // The pinned list's tab has no menu of its own, so its Unpin toast draws from here, inside the tabs' overlay host.
+ const toasts = useNavToasts()
+
+ const closeMenu = (): void => {
+ if (signOut.pending) {
+ return
+ }
+ setMenuOpen(false)
+ setConfirmingSignOut(false)
+ }
+ const startSignOut = (): void => {
+ if (signedIn) {
+ setConfirmingSignOut(true)
+ return
+ }
+ setMenuOpen(false)
+ exitDemo()
+ }
+ const editPins = slot?.editPins ?? null
+ const pins = useNavPins()
+ const productFlags = useMobileProductFlags()
+ // A list unpinned from its own tab keeps its slot until the person leaves, but no longer offers Unpin.
+ const list = (tab === 'errors' || tab === 'replay') && productFlags[tab] && pins.includes(tab) ? tab : null
+ const listUrl = list ? navListWebUrl(scope, list) : undefined
+ const webUrl = listUrl ? safeHttpsUrl(listUrl) : undefined
+ const navList = list && {
+ onUnpin: () => {
+ setMenuOpen(false)
+ changeNavPin(list, false, 'list_menu', toasts.show)
+ },
+ onOpenWeb: webUrl
+ ? () => {
+ setMenuOpen(false)
+ track('mobile_nav_tab_web_opened', { tab: list })
+ Linking.openURL(webUrl).catch(() => undefined)
+ }
+ : null,
+ }
+
+ return (
+ <>
+ {nativeRail ? <NativeTabChrome slot={slot} onMore={() => setMenuOpen(true)} /> : null}
+ <TabsHeader
+ tab={tab}
+ slot={slot}
+ status={status}
+ nativeRail={nativeRail}
+ onMore={() => setMenuOpen(true)}
+ />
+ <NavMenu
+ visible={menuOpen}
+ projectName={viewer.projectName}
+ status={status}
+ onOpenStatus={() => {
+ closeMenu()
+ track('mobile_status_opened', { source: 'tabs_menu' })
+ Linking.openURL(status.pageUrl).catch(() => toasts.show("Couldn't open PostHog status."))
+ }}
+ navList={navList}
+ editPins={
+ editPins && {
+ disabled: editPins.disabled,
+ onPress: () => {
+ setMenuOpen(false)
+ editPins.onPress()
+ },
+ }
+ }
+ onClose={closeMenu}
+ onSettings={() => {
+ setMenuOpen(false)
+ router.push('/settings')
+ }}
+ onSignOut={startSignOut}
+ confirmingSignOut={confirmingSignOut}
+ signOutPending={signOut.pending}
+ signOutError={signOut.error}
+ onCancelSignOut={() => {
+ signOut.clearError()
+ setConfirmingSignOut(false)
+ }}
+ onConfirmSignOut={() => void signOut.run()}
+ />
+ {tab !== 'views' ? <ViewsToast toast={toasts.toast} onHide={toasts.hide} /> : null}
+ </>
+ )
+}
diff --git a/products/mobile/src/features/tabs/TabsHeader.tsx b/products/mobile/src/features/tabs/TabsHeader.tsx
index 97dc4341c662..733aff7890dd 100644
--- a/products/mobile/src/features/tabs/TabsHeader.tsx
+++ b/products/mobile/src/features/tabs/TabsHeader.tsx
@@ -1,7 +1,6 @@
import type { ReactElement } from 'react'
import { Text, View } from 'react-native'
import type { PostHogStatus } from '@/features/status/usePostHogStatus'
-import { INBOX_PANE_WIDTH } from '@/ui/adaptiveLayout'
import { BlurEdge } from '@/ui/BlurEdge'
import { FadeEdge } from '@/ui/FadeEdge'
import { AnimatedLogomark } from '@/ui/icons/AnimatedLogomark'
@@ -50,6 +49,7 @@ interface TabsHeaderProps {
slot: TabHeaderSlot | null
status: PostHogStatus
onMore: () => void
+ nativeRail?: boolean
}
/**
@@ -62,11 +62,12 @@ export function TabsHeader({
slot,
status: { summary: statusUpdate, indicatorColor },
onMore,
+ nativeRail = false,
}: TabsHeaderProps): ReactElement {
const colors = useColors()
const styles = useStyles()
const insets = useScreenInsets()
- const { paired } = useAppLayout()
+ const { paired, inboxExtent, paneAxis } = useAppLayout()
const editing = slot?.editing ?? null
const status = slot?.status ?? null
const hint = editing ? null : (slot?.hint ?? null)
@@ -80,7 +81,7 @@ export function TabsHeader({
{
paddingTop: topOffset(insets, HEADER_TOP),
paddingBottom: withStatus ? STATUS_PADDING : HEADER_FADE,
- maxWidth: tab === 'inbox' && paired ? INBOX_PANE_WIDTH : undefined,
+ maxWidth: tab === 'inbox' && paired && paneAxis === 'row' ? inboxExtent : undefined,
},
]}
>
@@ -109,7 +110,7 @@ export function TabsHeader({
</Text>
) : null}
</View>
- {editing ? (
+ {nativeRail ? null : editing ? (
<Pressable44
onPress={editing.onDone}
accessibilityLabel="Done"
diff --git a/products/mobile/src/features/tabs/TabsLayout.test.tsx b/products/mobile/src/features/tabs/TabsLayout.test.tsx
index 11afe138d8f7..1f2f8413d84a 100644
--- a/products/mobile/src/features/tabs/TabsLayout.test.tsx
+++ b/products/mobile/src/features/tabs/TabsLayout.test.tsx
@@ -1,12 +1,17 @@
+import { router as navigation, Stack } from 'expo-router'
import { act, fireEvent, renderRouter, screen, within } from 'expo-router/testing-library'
import { type ReactElement, useState } from 'react'
-import { Button, Dimensions, Text, View } from 'react-native'
+import { Button, Dimensions, Platform, Text, View } from 'react-native'
+import { ViewsToast } from '@/features/views/ViewsToast'
import { setAnalyticsClient } from '@/lib/analytics'
import { FEATURE_FLAGS, setFeatureFlags } from '@/lib/featureFlags'
import { OverlayPortal } from '@/ui/OverlayPortal'
+import { changeNavPin } from './navPinActions'
import { restoreNavPins, setNavPinned, useNavPinStore } from './navPinStore'
+import { useNavToasts } from './navToasts'
+import { TabScene } from './TabScene'
import { TabsLayout } from './TabsLayout'
import { type TabHeaderSlot, type TabKey, useTabHeader, useTabHeaderStore } from './tabHeaderStore'
@@ -35,23 +40,48 @@ jest.mock('@/features/status/usePostHogStatus', () => ({
jest.mock('@/auth/useProjectScope', () => ({ useProjectScope: () => null }))
function InboxStub(): ReactElement {
- return <View testID="inbox-screen" />
+ return (
+ <TabScene tab="inbox">
+ <View testID="inbox-screen" />
+ </TabScene>
+ )
}
function ChatsStub(): ReactElement {
- return <View testID="chats-screen" />
+ return (
+ <TabScene tab="chats">
+ <View testID="chats-screen" />
+ </TabScene>
+ )
}
function ViewsStub(): ReactElement {
- return <View testID="views-screen" />
+ const toasts = useNavToasts()
+ const focused = useTabHeaderStore((state) => state.focused === 'views')
+ return (
+ <TabScene tab="views">
+ <View testID="views-screen">
+ <Button title="Pin errors" onPress={() => changeNavPin('errors', true, 'views_row', toasts.show)} />
+ </View>
+ {focused ? <ViewsToast toast={toasts.toast} onHide={toasts.hide} /> : null}
+ </TabScene>
+ )
}
function ErrorsStub(): ReactElement {
- return <View testID="errors-screen" />
+ return (
+ <TabScene tab="errors">
+ <View testID="errors-screen" />
+ </TabScene>
+ )
}
function ReplayStub(): ReactElement {
- return <View testID="replay-screen" />
+ return (
+ <TabScene tab="replay">
+ <View testID="replay-screen" />
+ </TabScene>
+ )
}
// The layout always registers the pinnable lists' tabs.
@@ -69,21 +99,31 @@ function RefreshingTabStub({ tab }: { tab: TabKey }): ReactElement {
const [refreshing, setRefreshing] = useState(false)
useTabHeader(tab, { ...LIST_SLOT, refreshing })
return (
- <View testID={`${tab}-screen`}>
- <Button title="Start refresh" testID="start-refresh" onPress={() => setRefreshing(true)} />
- <Button title="Finish refresh" testID="finish-refresh" onPress={() => setRefreshing(false)} />
- </View>
+ <TabScene tab={tab}>
+ <View testID={`${tab}-screen`}>
+ <Button title="Start refresh" testID="start-refresh" onPress={() => setRefreshing(true)} />
+ <Button title="Finish refresh" testID="finish-refresh" onPress={() => setRefreshing(false)} />
+ </View>
+ </TabScene>
)
}
function PublishingInboxStub(): ReactElement {
useTabHeader('inbox', { ...LIST_SLOT, filter: { active: true, onPress: () => undefined } })
- return <View testID="inbox-screen" />
+ return (
+ <TabScene tab="inbox">
+ <View testID="inbox-screen" />
+ </TabScene>
+ )
}
function PublishingChatsStub(): ReactElement {
useTabHeader('chats', LIST_SLOT)
- return <View testID="chats-screen" />
+ return (
+ <TabScene tab="chats">
+ <View testID="chats-screen" />
+ </TabScene>
+ )
}
function PublishingViewsStub(): ReactElement {
@@ -92,22 +132,35 @@ function PublishingViewsStub(): ReactElement {
status: 'Updated 2 min ago',
editPins: { disabled: false, onPress: () => undefined },
})
- return <View testID="views-screen" />
+ return (
+ <TabScene tab="views">
+ <View testID="views-screen" />
+ </TabScene>
+ )
}
function InboxWithMenuStub(): ReactElement {
return (
- <View testID="inbox-screen">
- <OverlayPortal>
- <Text testID="scene-menu">Menu</Text>
- </OverlayPortal>
- </View>
+ <TabScene tab="inbox">
+ <View testID="inbox-screen">
+ <OverlayPortal>
+ <Text testID="scene-menu">Menu</Text>
+ </OverlayPortal>
+ </View>
+ </TabScene>
)
}
const ORIGINAL_WINDOW = Dimensions.get('window')
-describe('TabsLayout', () => {
+describe.each(['ios', 'android'] as const)('TabsLayout (%s)', (platform) => {
+ const originalPlatform = Platform.OS
+ beforeAll(() => {
+ Platform.OS = platform
+ })
+ afterAll(() => {
+ Platform.OS = originalPlatform
+ })
beforeEach(() => {
restoreNavPins([])
setFeatureFlags({ [FEATURE_FLAGS.errorTracking]: true, [FEATURE_FLAGS.sessionReplay]: true })
@@ -156,12 +209,12 @@ describe('TabsLayout', () => {
act(() => useTabHeaderStore.getState().setSlot(otherTab, { ...LIST_SLOT, refreshing: true }))
expect(screen.getByTestId('tabs-logomark').props.accessibilityState.busy).toBe(false)
- fireEvent.press(screen.getByTestId('start-refresh'))
+ fireEvent.press(within(screen.getByTestId(`${tab}-screen`)).getByTestId('start-refresh'))
expect(screen.getByTestId('tabs-logomark').props.accessibilityState.busy).toBe(true)
expect(screen.queryByTestId(`${tab}-refresh`)).toBeNull()
expect(screen.getByTestId('tabs-more')).toBeTruthy()
- fireEvent.press(screen.getByTestId('finish-refresh'))
+ fireEvent.press(within(screen.getByTestId(`${tab}-screen`)).getByTestId('finish-refresh'))
expect(screen.getByTestId('tabs-logomark').props.accessibilityState.busy).toBe(false)
}
)
@@ -206,11 +259,12 @@ describe('TabsLayout', () => {
'(tabs)/chats': ChatsStub,
'(tabs)/views': ViewsStub,
...LIST_TABS,
+ settings: () => <View testID="settings-screen" />,
+ _layout: () => <Stack screenOptions={{ headerShown: false }} />,
},
{ initialUrl: '/inbox' }
)
expect(router.getSegments()).toEqual(['(tabs)', 'inbox'])
- const bar = screen.getByTestId('inbox-nav-views')
fireEvent.press(screen.getByTestId('inbox-nav-chat'))
@@ -218,7 +272,7 @@ describe('TabsLayout', () => {
expect(router.getSegments()).toEqual(['(tabs)', 'chats'])
expect(screen.getByTestId('chats-screen')).toBeTruthy()
expect(screen.getByTestId('inbox-nav-chat').props.accessibilityState).toEqual({ selected: true })
- expect(screen.getByTestId('inbox-nav-views')).toBe(bar)
+ expect(screen.getAllByTestId('inbox-nav-views')).toHaveLength(1)
fireEvent.press(screen.getByTestId('inbox-nav-views'))
@@ -227,6 +281,8 @@ describe('TabsLayout', () => {
expect(screen.getByTestId('inbox-nav-views').props.accessibilityState).toEqual({ selected: true })
fireEvent.press(screen.getByTestId('inbox-nav-home'))
+ act(() => navigation.push('/settings'))
+ act(() => navigation.back())
expect(capture.mock.calls).toEqual([
['mobile_inbox_opened', undefined],
@@ -246,7 +302,6 @@ describe('TabsLayout', () => {
},
{ initialUrl: '/inbox' }
)
- const more = screen.getByTestId('tabs-more')
const menuItems = (): { editPins: boolean; inbox: boolean } => {
fireEvent.press(screen.getByTestId('tabs-more'))
const menu = screen.getByTestId('nav-menu')
@@ -267,14 +322,14 @@ describe('TabsLayout', () => {
fireEvent.press(screen.getByTestId('inbox-nav-views'))
expect(screen.getByTestId('tabs-title').props.children).toBe('Views')
- expect(screen.getByTestId('tabs-more')).toBe(more)
+ expect(screen.getAllByTestId('tabs-more')).toHaveLength(1)
expect(menuItems()).toEqual({ editPins: true, inbox: false })
expect(screen.queryByTestId('inbox-filter')).toBeNull()
fireEvent.press(screen.getByTestId('inbox-nav-chat'))
expect(screen.getByTestId('tabs-title').props.children).toBe('Chats')
- expect(screen.getByTestId('tabs-more')).toBe(more)
+ expect(screen.getAllByTestId('tabs-more')).toHaveLength(1)
expect(menuItems()).toEqual({ editPins: false, inbox: false })
expect(screen.queryByTestId('inbox-filter')).toBeNull()
})
@@ -310,12 +365,34 @@ describe('TabsLayout', () => {
fireEvent.press(screen.getByTestId('inbox-nav-views'))
expect(screen.queryByTestId('nav-pin-errors')).toBeNull()
+ fireEvent.press(screen.getByTestId('views-toast-undo'))
+ expect(useNavPinStore.getState().pins).toEqual(['errors'])
expect(capture.mock.calls).toEqual([
['mobile_inbox_opened', undefined],
['mobile_nav_pin_changed', { pin: 'errors', pinned: false, source: 'list_menu', replaced: false }],
+ ['mobile_nav_pin_changed', { pin: 'errors', pinned: true, source: 'undo', replaced: false }],
])
})
+ test('keeps the separate Chat button opening compose from the inbox', async () => {
+ const router = await renderRouter(
+ {
+ '(tabs)/_layout': TabsLayout,
+ '(tabs)/inbox': InboxStub,
+ '(tabs)/chats': ChatsStub,
+ '(tabs)/views': ViewsStub,
+ chat: ChatsStub,
+ ...LIST_TABS,
+ },
+ { initialUrl: '/inbox' }
+ )
+
+ fireEvent.press(screen.getByTestId('inbox-chat'))
+
+ expect(router.getPathname()).toBe('/chat')
+ expect(router.getSearchParams()).toMatchObject({ entry: 'compose' })
+ })
+
test('draws a screen overlay outside the tab scene, so it covers the bar', async () => {
await renderRouter(
{
diff --git a/products/mobile/src/features/tabs/TabsLayout.tsx b/products/mobile/src/features/tabs/TabsLayout.tsx
index f165740701e0..8952be007127 100644
--- a/products/mobile/src/features/tabs/TabsLayout.tsx
+++ b/products/mobile/src/features/tabs/TabsLayout.tsx
@@ -1,50 +1,26 @@
-import { useRouter } from 'expo-router'
import { type BottomTabBarProps, Tabs } from 'expo-router/js-tabs'
-import { type ReactElement, useEffect, useLayoutEffect, useMemo, useState } from 'react'
-import { Linking, View } from 'react-native'
-import { useAuthStore } from '@/auth/authStore'
-import { useProjectScope } from '@/auth/useProjectScope'
-import { useViewer } from '@/auth/useViewer'
-import type { ChatSheetEntry } from '@/features/chat/chatSheetEvents'
-import { usePostHogStatus } from '@/features/status/usePostHogStatus'
+import { type ReactElement, useEffect, useLayoutEffect } from 'react'
+import { Platform, View } from 'react-native'
import { useViewsOpenedEvent } from '@/features/views/list/useViewsOpenedEvent'
-import { useToasts, ViewsToast } from '@/features/views/ViewsToast'
-import { navListWebUrl } from '@/features/views/webLinks'
+import { useToasts } from '@/features/views/ViewsToast'
import { track } from '@/lib/analytics'
-import { useMobileProductFlags } from '@/lib/featureFlags'
-import { safeHttpsUrl } from '@/lib/urls'
import { NAV_RAIL_WIDTH } from '@/ui/adaptiveLayout'
+import { MobileScene } from '@/ui/MobileScene'
import { OverlayHost, OverlayPortal } from '@/ui/OverlayPortal'
import { SceneFrame } from '@/ui/SceneFrame'
import { useColors } from '@/ui/theme'
import { useAppLayout } from '@/ui/useAppLayout'
-
-import { useExitDemo, useSignOutAction } from '../settings/useSignOut'
-import { BottomBar, type BottomBarSlot } from './BottomBar'
-import { NavMenu } from './NavMenu'
-import { changeNavPin } from './navPinActions'
-import { MAX_NAV_PINS, type NavPin, useNavPins } from './navPinStore'
-import { TabsHeader } from './TabsHeader'
-import { type TabKey, useFocusedTabHeader, useTabHeaderStore } from './tabHeaderStore'
+import { NativeTabsLayout } from './NativeTabsLayout'
+import { NavToastsContext } from './navToasts'
+import { TabsChrome } from './TabsChrome'
+import { TabsNavigation } from './TabsNavigation'
+import { type TabKey, useTabHeaderStore } from './tabHeaderStore'
function tabFor(route: string | undefined): TabKey {
return route === 'chats' || route === 'views' || route === 'errors' || route === 'replay' ? route : 'inbox'
}
-function selectedSlot(tab: TabKey): BottomBarSlot {
- return tab === 'inbox' ? 'home' : tab
-}
-
-/**
- * The pinned lists, plus the focused one when it was unpinned from its own screen, so its slot stays until the person
- * leaves it and the toast's Undo has something to come back to.
- */
-function visiblePins(pins: readonly NavPin[], tab: TabKey): readonly NavPin[] {
- return (tab === 'errors' || tab === 'replay') && !pins.includes(tab) ? [...pins, tab].slice(-MAX_NAV_PINS) : pins
-}
-
function TabBar({ state, navigateToTab }: BottomTabBarProps): ReactElement {
- const router = useRouter()
const focused = state.routes[state.index]?.name
const goTo = (route: TabKey): void => {
const key = state.routes.find((item) => item.name === route)?.key
@@ -53,12 +29,6 @@ function TabBar({ state, navigateToTab }: BottomTabBarProps): ReactElement {
// A layout effect, so the header shows the new tab's title in the same frame as the new scene.
const tab = tabFor(focused)
- const pins = useNavPins()
- const { errors, replay } = useMobileProductFlags()
- const shownPins = useMemo(
- () => visiblePins(pins, tab).filter((pin) => (pin === 'errors' ? errors : replay)),
- [pins, tab, errors, replay]
- )
useLayoutEffect(() => {
useTabHeaderStore.getState().setFocused(tab)
}, [tab])
@@ -77,17 +47,7 @@ function TabBar({ state, navigateToTab }: BottomTabBarProps): ReactElement {
return (
<OverlayPortal>
- <BottomBar
- selected={selectedSlot(tab)}
- pins={shownPins}
- onHome={() => goTo('inbox')}
- onChats={() => goTo('chats')}
- onViews={() => goTo('views')}
- onPin={goTo}
- onNewChat={() =>
- router.push({ pathname: '/chat', params: { entry: 'compose' satisfies ChatSheetEntry } })
- }
- />
+ <TabsNavigation tab={tab} onNavigate={goTo} />
</OverlayPortal>
)
}
@@ -96,101 +56,10 @@ function renderTabBar(props: BottomTabBarProps): ReactElement {
return <TabBar {...props} />
}
-function TabsChrome(): ReactElement {
- const router = useRouter()
- const viewer = useViewer()
- const { tab, slot } = useFocusedTabHeader()
- const signedIn = useAuthStore((state) => state.signedIn)
- const exitDemo = useExitDemo()
- const signOut = useSignOutAction()
- const [menuOpen, setMenuOpen] = useState(false)
- const [confirmingSignOut, setConfirmingSignOut] = useState(false)
- const scope = useProjectScope()
- const status = usePostHogStatus(scope?.host)
- // The pinned list's tab has no menu of its own, so its Unpin toast draws from here, inside the tabs' overlay host.
- const toasts = useToasts()
-
- const closeMenu = (): void => {
- if (signOut.pending) {
- return
- }
- setMenuOpen(false)
- setConfirmingSignOut(false)
- }
- const startSignOut = (): void => {
- if (signedIn) {
- setConfirmingSignOut(true)
- return
- }
- setMenuOpen(false)
- exitDemo()
- }
- const editPins = slot?.editPins ?? null
- const pins = useNavPins()
- const productFlags = useMobileProductFlags()
- // A list unpinned from its own tab keeps its slot until the person leaves, but no longer offers Unpin.
- const list = (tab === 'errors' || tab === 'replay') && productFlags[tab] && pins.includes(tab) ? tab : null
- const listUrl = list ? navListWebUrl(scope, list) : undefined
- const webUrl = listUrl ? safeHttpsUrl(listUrl) : undefined
- const navList = list && {
- onUnpin: () => {
- setMenuOpen(false)
- changeNavPin(list, false, 'list_menu', toasts.show)
- },
- onOpenWeb: webUrl
- ? () => {
- setMenuOpen(false)
- track('mobile_nav_tab_web_opened', { tab: list })
- Linking.openURL(webUrl).catch(() => undefined)
- }
- : null,
- }
-
- return (
- <>
- <TabsHeader tab={tab} slot={slot} status={status} onMore={() => setMenuOpen(true)} />
- <NavMenu
- visible={menuOpen}
- projectName={viewer.projectName}
- status={status}
- onOpenStatus={() => {
- closeMenu()
- Linking.openURL(status.pageUrl).catch(() => toasts.show("Couldn't open PostHog status."))
- }}
- navList={navList}
- editPins={
- editPins && {
- disabled: editPins.disabled,
- onPress: () => {
- setMenuOpen(false)
- editPins.onPress()
- },
- }
- }
- onClose={closeMenu}
- onSettings={() => {
- setMenuOpen(false)
- router.push('/settings')
- }}
- onSignOut={startSignOut}
- confirmingSignOut={confirmingSignOut}
- signOutPending={signOut.pending}
- signOutError={signOut.error}
- onCancelSignOut={() => {
- signOut.clearError()
- setConfirmingSignOut(false)
- }}
- onConfirmSignOut={() => void signOut.run()}
- />
- <ViewsToast toast={toasts.toast} onHide={toasts.hide} />
- </>
- )
-}
-
// BottomBar and TabsHeader are absolutely positioned, so the navigator lays the scenes out full height and the lists
// pad under both. The bar and the header draw after the scenes, so screen menus and sheets go through the host to draw
// above them. The header has no zIndex for the same reason: drawing order alone puts it between the two.
-export function TabsLayout(): ReactElement {
+function CustomTabsLayout(): ReactElement {
const colors = useColors()
const { rail, railSide } = useAppLayout()
return (
@@ -224,3 +93,18 @@ export function TabsLayout(): ReactElement {
</OverlayHost>
)
}
+
+export function TabsLayout(): ReactElement {
+ const toasts = useToasts()
+ return (
+ <NavToastsContext.Provider value={toasts}>
+ {Platform.OS === 'ios' ? (
+ <NativeTabsLayout />
+ ) : (
+ <MobileScene>
+ <CustomTabsLayout />
+ </MobileScene>
+ )}
+ </NavToastsContext.Provider>
+ )
+}
diff --git a/products/mobile/src/features/tabs/TabsNavigation.tsx b/products/mobile/src/features/tabs/TabsNavigation.tsx
new file mode 100644
index 000000000000..a209aa0c3b33
--- /dev/null
+++ b/products/mobile/src/features/tabs/TabsNavigation.tsx
@@ -0,0 +1,26 @@
+import { useRouter } from 'expo-router'
+import type { ReactElement } from 'react'
+import type { ChatSheetEntry } from '@/features/chat/chatSheetEvents'
+import { useMobileProductFlags } from '@/lib/featureFlags'
+import { BottomBar } from './BottomBar'
+import { useNavPins } from './navPinStore'
+import type { TabKey } from './tabHeaderStore'
+import { visibleNavPins } from './visibleNavPins'
+
+export function TabsNavigation({ tab, onNavigate }: { tab: TabKey; onNavigate?: (tab: TabKey) => void }): ReactElement {
+ const router = useRouter()
+ const pins = useNavPins()
+ const flags = useMobileProductFlags()
+ const goTo = onNavigate ?? ((tab: TabKey): void => router.navigate(`/(tabs)/${tab}`))
+ return (
+ <BottomBar
+ selected={tab === 'inbox' ? 'home' : tab}
+ pins={visibleNavPins(pins, tab, flags)}
+ onHome={() => goTo('inbox')}
+ onChats={() => goTo('chats')}
+ onViews={() => goTo('views')}
+ onPin={goTo}
+ onNewChat={() => router.push({ pathname: '/chat', params: { entry: 'compose' satisfies ChatSheetEntry } })}
+ />
+ )
+}
diff --git a/products/mobile/src/features/tabs/navToasts.ts b/products/mobile/src/features/tabs/navToasts.ts
new file mode 100644
index 000000000000..7b3138e1b036
--- /dev/null
+++ b/products/mobile/src/features/tabs/navToasts.ts
@@ -0,0 +1,10 @@
+import { createContext, useContext } from 'react'
+import type { Toasts } from '@/features/views/ViewsToast'
+
+export const NavToastsContext = createContext<Toasts | null>(null)
+
+export function useNavToasts(): Toasts {
+ const toasts = useContext(NavToastsContext)
+ if (!toasts) throw new Error('Navigation toasts require TabsLayout')
+ return toasts
+}
diff --git a/products/mobile/src/features/tabs/visibleNavPins.ts b/products/mobile/src/features/tabs/visibleNavPins.ts
new file mode 100644
index 000000000000..8508b947784a
--- /dev/null
+++ b/products/mobile/src/features/tabs/visibleNavPins.ts
@@ -0,0 +1,12 @@
+import { MAX_NAV_PINS, type NavPin } from './navPinStore'
+import type { TabKey } from './tabHeaderStore'
+
+export function visibleNavPins(
+ pins: readonly NavPin[],
+ tab: TabKey,
+ flags: Record<NavPin, boolean>
+): readonly NavPin[] {
+ const visible =
+ (tab === 'errors' || tab === 'replay') && !pins.includes(tab) ? [...pins, tab].slice(-MAX_NAV_PINS) : pins
+ return visible.filter((pin) => flags[pin])
+}
diff --git a/products/mobile/src/features/verdict/VerdictSheet.tsx b/products/mobile/src/features/verdict/VerdictSheet.tsx
index a333952cc9c2..c54193493a76 100644
--- a/products/mobile/src/features/verdict/VerdictSheet.tsx
+++ b/products/mobile/src/features/verdict/VerdictSheet.tsx
@@ -1,6 +1,6 @@
import { type ReactElement, useEffect, useMemo, useRef, useState } from 'react'
-import type { TextInputInstance } from 'react-native'
-import { ActivityIndicator, type ScrollViewInstance, Text, TextInput, View } from 'react-native'
+import type { ScrollViewInstance, TextInputInstance } from 'react-native'
+import { ActivityIndicator, Text, TextInput, View } from 'react-native'
import { Gesture, GestureDetector } from 'react-native-gesture-handler'
import { useReanimatedKeyboardAnimation } from 'react-native-keyboard-controller'
import Animated from 'react-native-reanimated'
diff --git a/products/mobile/src/features/views/ViewsToast.tsx b/products/mobile/src/features/views/ViewsToast.tsx
index d97ae3062509..6f8914564e06 100644
--- a/products/mobile/src/features/views/ViewsToast.tsx
+++ b/products/mobile/src/features/views/ViewsToast.tsx
@@ -1,11 +1,11 @@
import { type ReactElement, useCallback, useEffect, useRef, useState } from 'react'
-import { AccessibilityInfo, Text } from 'react-native'
+import { AccessibilityInfo, Platform, Text, View } from 'react-native'
import Animated, { FadeIn, FadeOut } from 'react-native-reanimated'
-
import { OverlayPortal } from '@/ui/OverlayPortal'
import { Pressable44 } from '@/ui/Pressable44'
import { createStyles, useTheme } from '@/ui/theme'
import { radii } from '@/ui/tokens'
+import { useOverlayPane } from '@/ui/useOverlayPane'
import { bottomOffset, useScreenInsets } from '@/ui/useScreenInsets'
const SHOW_MS = 2600
@@ -55,47 +55,57 @@ interface ViewsToastProps {
* A dark pill that confirms a pin change and can undo it. It draws through the nearest `OverlayHost`, so a toast from
* a view's header still sits at the bottom of the screen, above the tab bar and any open sheet.
*/
-export function ViewsToast({ toast, onHide, bottom = 114 }: ViewsToastProps): ReactElement | null {
+export function ViewsToast({
+ toast,
+ onHide,
+ bottom = Platform.OS === 'ios' ? 50 : 114,
+}: ViewsToastProps): ReactElement | null {
const { colors, shadows } = useTheme()
const styles = useStyles()
const insets = useScreenInsets()
+ const pane = useOverlayPane()
if (!toast) {
return null
}
const { undo } = toast
return (
<OverlayPortal>
- <Animated.View
- key={toast.id}
- entering={FadeIn.duration(180)}
- exiting={FadeOut.duration(180)}
- style={[
- styles.toast,
- shadows.card,
- { bottom: bottomOffset(insets, bottom) },
- undo ? null : styles.solo,
- ]}
- accessibilityLiveRegion="polite"
- testID="views-toast"
+ <View
+ pointerEvents="box-none"
+ style={{ position: 'absolute', left: pane.x, top: pane.y, width: pane.width, height: pane.height }}
>
- <Text style={styles.text} numberOfLines={1}>
- {toast.text}
- </Text>
- {undo ? (
- <Pressable44
- onPress={() => {
- onHide()
- undo()
- }}
- accessibilityLabel="Undo"
- pressedBackground={colors.inkHover}
- style={styles.undo}
- testID="views-toast-undo"
- >
- <Text style={styles.undoText}>Undo</Text>
- </Pressable44>
- ) : null}
- </Animated.View>
+ <Animated.View
+ key={toast.id}
+ entering={FadeIn.duration(180)}
+ exiting={FadeOut.duration(180)}
+ style={[
+ styles.toast,
+ shadows.card,
+ { bottom: bottomOffset(insets, bottom) },
+ undo ? null : styles.solo,
+ ]}
+ accessibilityLiveRegion="polite"
+ testID="views-toast"
+ >
+ <Text style={styles.text} numberOfLines={1}>
+ {toast.text}
+ </Text>
+ {undo ? (
+ <Pressable44
+ onPress={() => {
+ onHide()
+ undo()
+ }}
+ accessibilityLabel="Undo"
+ pressedBackground={colors.inkHover}
+ style={styles.undo}
+ testID="views-toast-undo"
+ >
+ <Text style={styles.undoText}>Undo</Text>
+ </Pressable44>
+ ) : null}
+ </Animated.View>
+ </View>
</OverlayPortal>
)
}
diff --git a/products/mobile/src/features/views/list/ViewsMenu.tsx b/products/mobile/src/features/views/list/ViewsMenu.tsx
index 647791796b7b..38cb63076b53 100644
--- a/products/mobile/src/features/views/list/ViewsMenu.tsx
+++ b/products/mobile/src/features/views/list/ViewsMenu.tsx
@@ -1,7 +1,8 @@
import { type ReactElement, type ReactNode, useState } from 'react'
-import { type LayoutChangeEvent, Text, View } from 'react-native'
+import { type LayoutChangeEvent, ScrollView, Text, View } from 'react-native'
import { useSafeAreaFrame } from 'react-native-safe-area-context'
-import { placeContextMenu, type RowAnchor } from '@/features/inbox/contextMenuPlacement'
+import type { RowAnchor } from '@/features/inbox/contextMenuPlacement'
+import { useContextMenuLayout } from '@/features/inbox/useContextMenuLayout'
import type { PinDisplayMode, PinView, ViewRef } from '@/model/views'
import { FloatingCard } from '@/ui/FloatingCard'
import { ArrowDownIcon } from '@/ui/icons/ArrowDownIcon'
@@ -10,15 +11,10 @@ import { ChevronRightIcon } from '@/ui/icons/ChevronRightIcon'
import { PinIcon } from '@/ui/icons/PinIcon'
import { Pressable44 } from '@/ui/Pressable44'
import { createStyles, useColors } from '@/ui/theme'
-import { layout, type } from '@/ui/tokens'
-import { useSceneDimensions } from '@/ui/useSceneDimensions'
-import { bottomOffset, topOffset, useScreenInsets } from '@/ui/useScreenInsets'
+import { type } from '@/ui/tokens'
-import { TABS_HEADER_BOTTOM } from '../../tabs/TabsHeader'
import { ModeSegment } from './ModeSegment'
-/** The bottom bar's design inset, the same one the list pads its content by. */
-const BOTTOM_BAR_ZONE = 120
const CARD_BORDER = 1
const MENU_WIDTH = 268
@@ -41,8 +37,6 @@ export function MenuCard({
children,
}: MenuCardProps): ReactElement {
const styles = useStyles()
- const insets = useScreenInsets()
- const { width: windowWidth } = useSceneDimensions()
// The overlay covers the full screen, which on Android edge-to-edge includes the navigation bar.
const { height: screenHeight } = useSafeAreaFrame()
const [height, setHeight] = useState<number | null>(null)
@@ -57,15 +51,9 @@ export function MenuCard({
setOpens(opens + 1)
}
}
- const placement = placeContextMenu({
- rowTop: anchor.y,
- rowBottom: anchor.y + anchor.height,
- menuHeight: height ?? 0,
- topLimit: topOffset(insets, TABS_HEADER_BOTTOM),
- bottomLimit: screenHeight - bottomOffset(insets, BOTTOM_BAR_ZONE),
- })
+ const placement = useContextMenuLayout(anchor, visible, onClose, MENU_WIDTH, height ?? 0)
const top = height === null ? -screenHeight : placement.top
- const left = Math.max(layout.inboxGutter, Math.min(anchor.x, windowWidth - layout.inboxGutter - MENU_WIDTH))
+ const left = placement.left
const onLayout = (event: LayoutChangeEvent): void => {
setHeight(event.nativeEvent.layout.height + CARD_BORDER * 2)
}
@@ -77,11 +65,13 @@ export function MenuCard({
transformOrigin={origin}
accessibilityLabel={accessibilityLabel}
testID={testID}
- style={[styles.card, { left, top }]}
+ style={[styles.card, { left, top, width: placement.width, maxHeight: placement.maxHeight }]}
>
- <View key={opens} style={styles.content} onLayout={onLayout}>
- {children}
- </View>
+ <ScrollView bounces={false}>
+ <View key={opens} style={styles.content} onLayout={onLayout}>
+ {children}
+ </View>
+ </ScrollView>
</FloatingCard>
)
}
diff --git a/products/mobile/src/features/views/list/ViewsScreen.tsx b/products/mobile/src/features/views/list/ViewsScreen.tsx
index 840d4f142037..965389e203af 100644
--- a/products/mobile/src/features/views/list/ViewsScreen.tsx
+++ b/products/mobile/src/features/views/list/ViewsScreen.tsx
@@ -10,6 +10,7 @@ import type { BrowseRow, InsightSnapshot, PinDisplayMode, PinView, RecentView, V
import { ChartCanvasBudget, useCanvasBudgetViewport } from '@/ui/chart/budget/ChartCanvasBudget'
import { ChartSelectionProvider, useChartListMotion } from '@/ui/chart/selection/ChartSelectionProvider'
import type { ChartTooltipPoint } from '@/ui/chart/types'
+import { useDisplayRegions } from '@/ui/displayRegionContext'
import { Eyebrow } from '@/ui/Eyebrow'
import { WarningIcon } from '@/ui/icons/WarningIcon'
import { Pressable44 } from '@/ui/Pressable44'
@@ -18,11 +19,12 @@ import { StateView } from '@/ui/StateView'
import { createStyles, useColors } from '@/ui/theme'
import { layout, type } from '@/ui/tokens'
import { useSceneDimensions } from '@/ui/useSceneDimensions'
-import { bottomOffset, topOffset, useScreenInsets } from '@/ui/useScreenInsets'
+import { bottomOffset, topOffset, useScreenInsets, useTabBottomOffset } from '@/ui/useScreenInsets'
import { NavPinMenu } from '../../tabs/NavPinMenu'
import { changeNavPin } from '../../tabs/navPinActions'
import { openNavTarget } from '../../tabs/navPinRoutes'
import { type NavPin, useNavPinStore } from '../../tabs/navPinStore'
+import { useNavToasts } from '../../tabs/navToasts'
import { TABS_HEADER_BOTTOM } from '../../tabs/TabsHeader'
import { useTabHeader } from '../../tabs/tabHeaderStore'
import {
@@ -43,7 +45,7 @@ import { INITIAL_VISIBLE_ROWS } from '../useViewRefresh'
import { useViewsAccess, type ViewsAccess } from '../useViewsAccess'
import { useViewsContext } from '../useViewsContext'
import { ViewsReauthState } from '../ViewsReauthState'
-import { useToasts, ViewsToast } from '../ViewsToast'
+import { ViewsToast } from '../ViewsToast'
import { viewHref } from '../viewRoutes'
import { useSnapshot } from '../viewsCache'
import { BROWSE_ENTRIES, type BrowseEntry, BrowseEntryRow, browseEntryLabel, browseEntryPin } from './BrowseEntryRow'
@@ -126,6 +128,7 @@ export function ViewsScreen(): ReactElement {
function ViewsReauth({ access }: { access: ViewsAccess }): ReactElement {
const styles = useStyles()
const insets = useScreenInsets()
+ const tabBottom = useTabBottomOffset()
useTabHeader('views', {
hint: null,
status: null,
@@ -136,10 +139,7 @@ function ViewsReauth({ access }: { access: ViewsAccess }): ReactElement {
return (
<View style={styles.screen} testID="views-screen">
<View
- style={[
- styles.fill,
- { paddingTop: topOffset(insets, TABS_HEADER_BOTTOM), paddingBottom: bottomOffset(insets, 120) },
- ]}
+ style={[styles.fill, { paddingTop: topOffset(insets, TABS_HEADER_BOTTOM), paddingBottom: tabBottom }]}
>
<ViewsReauthState access={access} />
</View>
@@ -155,12 +155,15 @@ function ViewsBody(): ReactElement {
const router = useRouter()
const focused = useIsFocused()
const insets = useScreenInsets()
+ const tabBottom = useTabBottomOffset()
const now = useNow()
const context = useViewsContext()
const contentTop = topOffset(insets, TABS_HEADER_BOTTOM)
const list = useViewsList()
const { width } = useSceneDimensions()
- const grid = width >= 740
+ const regions = useDisplayRegions()
+ const fold = regions.find((region) => region.kind === 'division' && region.frame.height > region.frame.width)?.frame
+ const grid = fold ? fold.x >= 300 && width - fold.x - fold.width >= 300 : width >= 740
const pinAnchor = useRef({
grid,
visible: null as string | null,
@@ -180,7 +183,7 @@ function ViewsBody(): ReactElement {
const viewport = useCanvasBudgetViewport()
const sheets = useChartSheets()
const flows = usePinFlows(actions)
- const navToasts = useToasts()
+ const navToasts = useNavToasts()
const { hideToast: hidePinToast } = flows
const { show: showToast } = navToasts
const navPins = useNavPinStore((state) => state.pins)
@@ -684,7 +687,7 @@ function ViewsBody(): ReactElement {
case 'pin-pair':
return (
<View
- style={{ flexDirection: 'row', gap: 16 }}
+ style={{ flexDirection: 'row', gap: fold ? fold.width + 16 : 16 }}
collapsable={false}
ref={(node) =>
setPinRow(
@@ -694,8 +697,20 @@ function ViewsBody(): ReactElement {
}
onLayout={() => onPinLayout(item.items.map((pin) => pin.shortcutId))}
>
- {item.items.map((pin) => (
- <View key={pin.key} style={[{ flex: 1, minWidth: 0 }, !pin.last && styles.pinGap]}>
+ {item.items.map((pin, column) => (
+ <View
+ key={pin.key}
+ style={[
+ { flex: 1, minWidth: 0 },
+ fold &&
+ column === 0 && {
+ flexGrow: 0,
+ flexShrink: 0,
+ flexBasis: fold.x - layout.inboxGutter - 16,
+ },
+ !pin.last && styles.pinGap,
+ ]}
+ >
<PinDragTile id={pin.shortcutId} drag={drag}>
<PinCard
pin={pin.pin}
@@ -787,6 +802,7 @@ function ViewsBody(): ReactElement {
openBrowseMenu,
context.mode,
styles,
+ fold,
]
)
@@ -810,7 +826,7 @@ function ViewsBody(): ReactElement {
[startEditing, styles, colors]
)
- const contentBottom = bottomOffset(insets, 120)
+ const contentBottom = tabBottom
const { refresh } = list
const loading = list.pins.data === undefined && !list.pins.isError
const status = loading ? 'Loading…' : null
diff --git a/products/mobile/src/features/views/screen/HeaderMenu.tsx b/products/mobile/src/features/views/screen/HeaderMenu.tsx
index d7404280b97f..a37564c4bb55 100644
--- a/products/mobile/src/features/views/screen/HeaderMenu.tsx
+++ b/products/mobile/src/features/views/screen/HeaderMenu.tsx
@@ -1,11 +1,11 @@
import type { ComponentType, ReactElement } from 'react'
-import { View } from 'react-native'
-
+import { ScrollView } from 'react-native'
import { MenuItem } from '@/features/views/list/ViewsMenu'
import { FloatingCard } from '@/ui/FloatingCard'
import type { IconProps } from '@/ui/icons/types'
import { createStyles, useColors } from '@/ui/theme'
import { iconSizes } from '@/ui/tokens'
+import { useFloatingMenuStyle } from '@/ui/useFloatingMenuStyle'
import { topOffset, useScreenInsets } from '@/ui/useScreenInsets'
/** Design-frame top of the menu: just under the chrome's 54pt More pill. */
@@ -32,6 +32,7 @@ export function HeaderMenu({ visible, items, onClose, testID }: HeaderMenuProps)
const colors = useColors()
const styles = useStyles()
const insets = useScreenInsets()
+ const cardStyle = useFloatingMenuStyle(topOffset(insets, MENU_TOP), MENU_WIDTH)
return (
<FloatingCard
visible={visible}
@@ -39,9 +40,9 @@ export function HeaderMenu({ visible, items, onClose, testID }: HeaderMenuProps)
transformOrigin="top right"
accessibilityLabel="More"
testID={testID}
- style={[styles.card, { top: topOffset(insets, MENU_TOP) }]}
+ style={[styles.card, cardStyle]}
>
- <View style={styles.content}>
+ <ScrollView style={styles.content}>
{items.map(({ key, label, Icon, onPress, disabled = false, meta }) => (
<MenuItem
key={key}
@@ -56,7 +57,7 @@ export function HeaderMenu({ visible, items, onClose, testID }: HeaderMenuProps)
testID={`${testID}-${key}`}
/>
))}
- </View>
+ </ScrollView>
</FloatingCard>
)
}
diff --git a/products/mobile/src/features/views/screen/ViewChrome.tsx b/products/mobile/src/features/views/screen/ViewChrome.tsx
index 708995113356..102e8090862e 100644
--- a/products/mobile/src/features/views/screen/ViewChrome.tsx
+++ b/products/mobile/src/features/views/screen/ViewChrome.tsx
@@ -1,6 +1,9 @@
+import { Stack } from 'expo-router'
import type { ReactElement } from 'react'
+import { Platform } from 'react-native'
import { MoreIcon } from '@/ui/icons/MoreIcon'
+import { nativeIcons } from '@/ui/icons/nativeIcons'
import { PillControl } from '@/ui/PillControl'
import { Pressable44 } from '@/ui/Pressable44'
import { ScreenChrome } from '@/ui/ScreenChrome'
@@ -22,6 +25,17 @@ export function ViewChrome({ onBack, onMore, title }: ViewChromeProps): ReactEle
onBack={onBack}
backTestID="view-back"
title={title}
+ nativeActions={
+ Platform.OS === 'ios' ? (
+ <Stack.Toolbar.Button
+ iconRenderingMode="template"
+ icon={nativeIcons.more}
+ accessibilityLabel="More"
+ disabled={!onMore}
+ onPress={onMore}
+ />
+ ) : null
+ }
right={
<PillControl height={screenLayout.rowHeight}>
<Pressable44
diff --git a/products/mobile/src/lib/analytics.ts b/products/mobile/src/lib/analytics.ts
index e0335f30685c..48af9de53a6a 100644
--- a/products/mobile/src/lib/analytics.ts
+++ b/products/mobile/src/lib/analytics.ts
@@ -24,6 +24,7 @@ export type AnalyticsEvent =
| 'mobile_splash_hidden'
| 'mobile_create_account_opened'
| 'mobile_legal_link_opened'
+ | 'mobile_status_opened'
| 'mobile_inbox_opened'
| 'mobile_inbox_report_menu_opened'
| 'mobile_inbox_report_menu_action'
diff --git a/products/mobile/src/lib/useScreenTracking.test.tsx b/products/mobile/src/lib/useScreenTracking.test.tsx
index 932227c654c4..833c4c4bdcf9 100644
--- a/products/mobile/src/lib/useScreenTracking.test.tsx
+++ b/products/mobile/src/lib/useScreenTracking.test.tsx
@@ -20,14 +20,14 @@ describe('useScreenTracking', () => {
setAnalyticsClient(null)
})
- test('sends one $screen per route, named by pattern, with a new report id counting as a new screen', () => {
+ test('sends one $screen per route, named by pattern, with a new report id counting as a new screen', async () => {
const screen = jest.fn()
setAnalyticsClient({ capture: jest.fn(), screen, identify: jest.fn(), reset: jest.fn() })
- renderRouter(
+ await renderRouter(
{
_layout: TrackedLayout,
index: Stub,
- '(tabs)/inbox': Stub,
+ '(tabs)/inbox/index': Stub,
'report/[id]/index': Stub,
'report/[id]/details': Stub,
},
diff --git a/products/mobile/src/ui/BottomSheet.test.tsx b/products/mobile/src/ui/BottomSheet.test.tsx
new file mode 100644
index 000000000000..dd282c56ff99
--- /dev/null
+++ b/products/mobile/src/ui/BottomSheet.test.tsx
@@ -0,0 +1,45 @@
+import { render, screen } from '@testing-library/react-native'
+import { Text } from 'react-native'
+import { BottomSheet } from './BottomSheet'
+import { DisplayRegionContext } from './displayRegionContext'
+import { SceneDimensionsContext } from './sceneDimensions'
+import { useSceneDimensions } from './useSceneDimensions'
+
+jest.mock(
+ 'react-native-safe-area-context',
+ () => jest.requireActual('react-native-safe-area-context/jest/mock').default
+)
+
+jest.mock('react-native-worklets', () => jest.requireActual('react-native-worklets/src/mock'))
+jest.mock('react-native-reanimated', () => ({
+ ...jest.requireActual('react-native-reanimated/mock'),
+ useReducedMotion: () => true,
+}))
+
+function Contents(): React.JSX.Element {
+ const { width, height } = useSceneDimensions()
+ return (
+ <Text testID="available-size">
+ {width}x{height}
+ </Text>
+ )
+}
+
+describe('BottomSheet', () => {
+ test('gives its contents the selected horizontal pane height instead of the full scene', () => {
+ render(
+ <SceneDimensionsContext.Provider value={{ width: 669, height: 951 }}>
+ <DisplayRegionContext.Provider
+ value={[
+ { kind: 'division', occludesContent: false, frame: { x: 0, y: 440, width: 669, height: 20 } },
+ ]}
+ >
+ <BottomSheet visible onClose={() => undefined}>
+ <Contents />
+ </BottomSheet>
+ </DisplayRegionContext.Provider>
+ </SceneDimensionsContext.Provider>
+ )
+ expect(screen.getByTestId('available-size')).toHaveTextContent('600x491')
+ })
+})
diff --git a/products/mobile/src/ui/BottomSheet.tsx b/products/mobile/src/ui/BottomSheet.tsx
index 42fc08ea8da8..1fe3c4d70d21 100644
--- a/products/mobile/src/ui/BottomSheet.tsx
+++ b/products/mobile/src/ui/BottomSheet.tsx
@@ -1,16 +1,18 @@
import { type ReactElement, type ReactNode, useState } from 'react'
-import { type LayoutChangeEvent, useWindowDimensions, View } from 'react-native'
+import { type LayoutChangeEvent, View } from 'react-native'
import { GestureDetector } from 'react-native-gesture-handler'
import Animated, { type SharedValue, useAnimatedStyle } from 'react-native-reanimated'
import type { NativeGesture } from '@/ui/gestureTypes'
import { OverlayPortal } from './OverlayPortal'
import { Scrim } from './Scrim'
+import { SceneDimensionsContext } from './sceneDimensions'
import { createStyles, useTheme } from './theme'
import { layout, motion, radii } from './tokens'
import { useOverlayBack } from './useOverlayBack'
+import { useOverlayFrame } from './useOverlayFrame'
+import { useOverlayPane } from './useOverlayPane'
import { usePresence } from './usePresence'
-import { useSceneDimensions } from './useSceneDimensions'
import { bottomOffset, useScreenInsets } from './useScreenInsets'
import { useSheetDrag } from './useSheetDrag'
@@ -41,9 +43,11 @@ export function BottomSheet({
const { colors, shadows } = useTheme()
const styles = useStyles()
const insets = useScreenInsets()
- const { height: sceneHeight } = useSceneDimensions()
- const { width: windowWidth } = useWindowDimensions()
- const width = windowWidth - insets.left - insets.right
+ const pane = useOverlayPane()
+ const frame = useOverlayFrame()
+ const sceneHeight = pane.height
+ const width = pane.width
+ const topInset = pane.y === 0 ? insets.top : 0
const bottomMargin = width >= 600 ? insets.bottom + 16 : 0
const bottomPadding = bottomOffset(insets, 40)
const { mounted, progress } = usePresence(visible, motion.sheet)
@@ -52,13 +56,13 @@ export function BottomSheet({
useOverlayBack(visible, onClose)
const sheetStyle = useAnimatedStyle(() => {
- const keyboard = Math.max(-(keyboardHeight?.value ?? 0), 0)
+ const keyboard = Math.max(pane.y + pane.height - frame.height - (keyboardHeight?.value ?? 0), 0)
const compactKeyboard = keyboard > 0 && sceneHeight < 480
const marginBottom = keyboard > 0 ? Math.max(bottomMargin, keyboard + (compactKeyboard ? 4 : 8)) : bottomMargin
return {
transform: [{ translateY: (1 - progress.value) * height + drag.value }],
marginBottom,
- maxHeight: Math.max(120, sceneHeight - insets.top - (compactKeyboard ? 4 : 12) - marginBottom),
+ maxHeight: Math.max(0, sceneHeight - topInset - (compactKeyboard ? 4 : 12) - marginBottom),
paddingBottom: compactKeyboard ? 8 : keyboard > 0 ? layout.minBottomPadding : bottomPadding,
}
})
@@ -73,34 +77,50 @@ export function BottomSheet({
<OverlayPortal>
<View style={styles.overlay} testID={testID}>
<Scrim color={colors.scrimDark} progress={progress} onPress={onClose} />
- <GestureDetector gesture={pan}>
- <Animated.View
- accessibilityViewIsModal
- accessibilityLabel={accessibilityLabel}
- onLayout={onLayout}
- style={[
- styles.sheet,
- shadows.bottomSheet,
- {
- paddingHorizontal,
- width: '100%',
- maxWidth: 600,
- alignSelf: 'center',
- ...(width >= 600
- ? {
- borderBottomLeftRadius: radii.sheet,
- borderBottomRightRadius: radii.sheet,
- }
- : {}),
- backgroundColor: backgroundColor ?? colors.surface,
- },
- sheetStyle,
- ]}
- >
- <View style={styles.grabber} />
- {children}
- </Animated.View>
- </GestureDetector>
+ <View
+ style={{
+ position: 'absolute',
+ left: pane.x,
+ top: pane.y,
+ width: pane.width,
+ height: pane.height,
+ justifyContent: 'flex-end',
+ }}
+ pointerEvents="box-none"
+ >
+ <GestureDetector gesture={pan}>
+ <Animated.View
+ accessibilityViewIsModal
+ accessibilityLabel={accessibilityLabel}
+ onLayout={onLayout}
+ style={[
+ styles.sheet,
+ shadows.bottomSheet,
+ {
+ paddingHorizontal,
+ width: '100%',
+ maxWidth: 600,
+ alignSelf: 'center',
+ ...(width >= 600
+ ? {
+ borderBottomLeftRadius: radii.sheet,
+ borderBottomRightRadius: radii.sheet,
+ }
+ : {}),
+ backgroundColor: backgroundColor ?? colors.surface,
+ },
+ sheetStyle,
+ ]}
+ >
+ <View style={styles.grabber} />
+ <SceneDimensionsContext.Provider
+ value={{ width: Math.min(width, 600), height: sceneHeight }}
+ >
+ {children}
+ </SceneDimensionsContext.Provider>
+ </Animated.View>
+ </GestureDetector>
+ </View>
</View>
</OverlayPortal>
)
diff --git a/products/mobile/src/ui/MobileScene.test.tsx b/products/mobile/src/ui/MobileScene.test.tsx
new file mode 100644
index 000000000000..60f09de19426
--- /dev/null
+++ b/products/mobile/src/ui/MobileScene.test.tsx
@@ -0,0 +1,50 @@
+import { fireEvent, render, screen } from '@testing-library/react-native'
+import { type ReactElement, useState } from 'react'
+import { Text, TextInput, View } from 'react-native'
+import { useReservedRegions } from 'react-native-reserved-regions'
+
+import { useDisplayRegions } from './displayRegionContext'
+import { MobileScene } from './MobileScene'
+
+let mockLeft = 0
+jest.mock('react-native-safe-area-context', () => ({
+ ...jest.requireActual('react-native-safe-area-context/jest/mock').default,
+ useSafeAreaInsets: () => ({ left: mockLeft, right: 84 - mockLeft, top: 0, bottom: 0 }),
+}))
+
+function Draft(): ReactElement {
+ const [note, setNote] = useState('')
+ const regions = useDisplayRegions()
+ return (
+ <View>
+ <Text testID="fold">{regions[0]?.frame.x}</Text>
+ <TextInput testID="note" value={note} onChangeText={setNote} />
+ </View>
+ )
+}
+
+test('keeps a draft while translating a window fold to either safe edge', () => {
+ jest.mocked(useReservedRegions).mockReturnValue([
+ { kind: 'division', occludesContent: false, frame: { x: 455.5, y: 0, width: 40, height: 669 } },
+ ])
+ const view = render(
+ <MobileScene>
+ <Draft />
+ </MobileScene>
+ )
+ const input = screen.getByTestId('note')
+ fireEvent.changeText(input, 'Keep this note')
+ expect(screen.getByTestId('fold').props.children).toBe(455.5)
+ mockLeft = 84
+ view.rerender(
+ <MobileScene>
+ <Draft />
+ </MobileScene>
+ )
+ expect(screen.getByTestId('fold').props.children).toBe(371.5)
+ expect(screen.getByTestId('note')).toBe(input)
+ expect(input.props.value).toBe('Keep this note')
+ view.unmount()
+ mockLeft = 0
+ jest.mocked(useReservedRegions).mockReturnValue([])
+})
diff --git a/products/mobile/src/ui/MobileScene.tsx b/products/mobile/src/ui/MobileScene.tsx
new file mode 100644
index 000000000000..ca3ecb3f5e46
--- /dev/null
+++ b/products/mobile/src/ui/MobileScene.tsx
@@ -0,0 +1,26 @@
+import { type ReactElement, type ReactNode, useMemo } from 'react'
+import { useReservedRegions } from 'react-native-reserved-regions'
+import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
+
+import { DisplayRegionContext } from './displayRegionContext'
+import { OverlayHost } from './OverlayPortal'
+import { SceneFrame } from './SceneFrame'
+
+export function MobileScene({ children }: { children: ReactNode }): ReactElement {
+ const regions = useReservedRegions()
+ const { left } = useSafeAreaInsets()
+ // Measure outside navigator transitions; a translated scene can otherwise retain an offset fold frame.
+ const localRegions = useMemo(
+ () => regions.map((region) => ({ ...region, frame: { ...region.frame, x: region.frame.x - left } })),
+ [regions, left]
+ )
+ return (
+ <SafeAreaView edges={['left', 'right']} style={{ flex: 1 }}>
+ <DisplayRegionContext.Provider value={localRegions}>
+ <SceneFrame>
+ <OverlayHost>{children}</OverlayHost>
+ </SceneFrame>
+ </DisplayRegionContext.Provider>
+ </SafeAreaView>
+ )
+}
diff --git a/products/mobile/src/ui/NativeScreenChrome.tsx b/products/mobile/src/ui/NativeScreenChrome.tsx
new file mode 100644
index 000000000000..6e3a0e2603ed
--- /dev/null
+++ b/products/mobile/src/ui/NativeScreenChrome.tsx
@@ -0,0 +1,48 @@
+import { Stack } from 'expo-router'
+import { Children, Fragment, isValidElement, type ReactElement, type ReactNode } from 'react'
+import { useNativeHeaderCleanup } from '@/ui/useNativeHeaderCleanup'
+import { nativeIcons } from './icons/nativeIcons'
+import { useOverlayDismiss } from './overlayDismiss'
+import type { ScreenChromeProps } from './ScreenChrome'
+import { useColors } from './theme'
+
+function toolbarItems(children: ReactNode): ReactNode[] {
+ return Children.toArray(children).flatMap((child) =>
+ isValidElement<{ children?: ReactNode }>(child) && child.type === Fragment
+ ? toolbarItems(child.props.children)
+ : [child]
+ )
+}
+
+export function NativeScreenChrome({ onBack, nativeActions }: ScreenChromeProps): ReactElement {
+ useNativeHeaderCleanup()
+ const colors = useColors()
+ const dismiss = useOverlayDismiss()
+ return (
+ <>
+ <Stack.Screen
+ options={{
+ headerShown: true,
+ gestureEnabled: !dismiss,
+ headerTransparent: true,
+ headerStyle: { backgroundColor: colors.background },
+ headerLargeStyle: { backgroundColor: colors.background },
+ headerShadowVisible: false,
+ scrollEdgeEffects: { top: 'hidden' },
+ headerTitle: '',
+ headerTintColor: colors.ink,
+ headerBackVisible: false,
+ }}
+ />
+ <Stack.Toolbar placement="left">
+ <Stack.Toolbar.Button
+ iconRenderingMode="template"
+ icon={dismiss ? nativeIcons.close : nativeIcons.back}
+ accessibilityLabel={dismiss ? 'Close' : 'Back'}
+ onPress={dismiss ?? onBack}
+ />
+ </Stack.Toolbar>
+ <Stack.Toolbar placement="right">{dismiss ? null : toolbarItems(nativeActions)}</Stack.Toolbar>
+ </>
+ )
+}
diff --git a/products/mobile/src/ui/OverlayPortal.tsx b/products/mobile/src/ui/OverlayPortal.tsx
index 218c0d92a273..3d0509b4ddbd 100644
--- a/products/mobile/src/ui/OverlayPortal.tsx
+++ b/products/mobile/src/ui/OverlayPortal.tsx
@@ -7,9 +7,17 @@ import {
useContext,
useId,
useLayoutEffect,
+ useMemo,
+ useRef,
useState,
} from 'react'
-import { StyleSheet, View } from 'react-native'
+import type { ViewInstance } from 'react-native'
+import { StyleSheet, useWindowDimensions, View } from 'react-native'
+import { useSafeAreaInsets } from 'react-native-safe-area-context'
+
+import type { DisplayRect } from './displayRegions'
+import { OverlayDismissContext } from './overlayDismiss'
+import { OverlayFrameContext } from './overlayFrame'
type SetOverlay = (key: string, node: ReactNode | null) => void
@@ -24,6 +32,33 @@ interface OverlayHostProps {
* after its scenes, such as a tab bar.
*/
export function OverlayHost({ children }: OverlayHostProps): ReactElement {
+ const ref = useRef<ViewInstance>(null)
+ const { width, height } = useWindowDimensions()
+ const { left, right, top, bottom } = useSafeAreaInsets()
+ const [frame, setFrame] = useState<DisplayRect | null>(null)
+ const measure = useCallback(() => {
+ ref.current?.measureInWindow((x, y, width, height) => {
+ setFrame((previous) =>
+ previous?.x === x && previous.y === y && previous.width === width && previous.height === height
+ ? previous
+ : { x, y, width, height }
+ )
+ })
+ }, [])
+ const [dismissals, setDismissals] = useState<ReadonlyMap<string, () => void>>(() => new Map())
+ const setDismissal = useCallback((key: string, close: (() => void) | null): void => {
+ setDismissals((previous) => {
+ if (close === null && !previous.has(key)) return previous
+ const next = new Map(previous)
+ if (close) next.set(key, close)
+ else next.delete(key)
+ return next
+ })
+ }, [])
+ const dismissalContext = useMemo(
+ () => ({ set: setDismissal, close: [...dismissals.values()].at(-1) ?? null }),
+ [setDismissal, dismissals]
+ )
const [nodes, setNodes] = useState<ReadonlyMap<string, ReactNode>>(() => new Map())
const setOverlay = useCallback<SetOverlay>((key, node) => {
setNodes((previous) => {
@@ -41,16 +76,23 @@ export function OverlayHost({ children }: OverlayHostProps): ReactElement {
})
}, [])
+ // biome-ignore lint/correctness/useExhaustiveDependencies: measure again when an overlay opens after a navigator transition.
+ useLayoutEffect(measure, [measure, width, height, left, right, top, bottom, nodes.size])
+
return (
<OverlayContext.Provider value={setOverlay}>
- <View style={styles.root}>
- {children}
- <View style={StyleSheet.absoluteFill} pointerEvents="box-none">
- {[...nodes].map(([key, node]) => (
- <Fragment key={key}>{node}</Fragment>
- ))}
- </View>
- </View>
+ <OverlayDismissContext.Provider value={dismissalContext}>
+ <OverlayFrameContext.Provider value={frame}>
+ <View ref={ref} onLayout={measure} collapsable={false} style={styles.root}>
+ {children}
+ <View style={StyleSheet.absoluteFill} pointerEvents="box-none">
+ {[...nodes].map(([key, node]) => (
+ <Fragment key={key}>{node}</Fragment>
+ ))}
+ </View>
+ </View>
+ </OverlayFrameContext.Provider>
+ </OverlayDismissContext.Provider>
</OverlayContext.Provider>
)
}
diff --git a/products/mobile/src/ui/ScreenChrome.tsx b/products/mobile/src/ui/ScreenChrome.tsx
index 5cc1b6d6b0f1..c89bfe5ef83e 100644
--- a/products/mobile/src/ui/ScreenChrome.tsx
+++ b/products/mobile/src/ui/ScreenChrome.tsx
@@ -5,21 +5,41 @@ import Animated, { useAnimatedStyle } from 'react-native-reanimated'
import { BackChip } from './BackChip'
import { BlurEdge } from './BlurEdge'
import { FadeEdge } from './FadeEdge'
+import { NativeScreenChrome } from './NativeScreenChrome'
import { screenLayout } from './screenLayout'
import { scrollTitleOpacity } from './scrollTitleOpacity'
import { createStyles } from './theme'
import { layout, type } from './tokens'
+import { useNativeRail } from './useNativeRail'
import { topOffset, useScreenInsets } from './useScreenInsets'
import type { ScrollTitle } from './useScrollTitle'
-interface ScreenChromeProps {
+export interface ScreenChromeProps {
onBack: () => void
backTestID: string
title?: ScrollTitle
right?: ReactNode
+ nativeActions?: ReactNode
+ hideNativeTitle?: boolean
}
-export function ScreenChrome({ onBack, backTestID, title, right }: ScreenChromeProps): ReactElement {
+export function ScreenChrome(props: ScreenChromeProps): ReactElement {
+ const nativeRail = useNativeRail()
+ return (
+ <>
+ {nativeRail ? <NativeScreenChrome {...props} /> : null}
+ <CustomScreenChrome {...props} nativeRail={nativeRail} />
+ </>
+ )
+}
+
+function CustomScreenChrome({
+ onBack,
+ backTestID,
+ title,
+ right,
+ nativeRail,
+}: ScreenChromeProps & { nativeRail: boolean }): ReactElement {
const styles = useStyles()
const insets = useScreenInsets()
const [leftWidth, setLeftWidth] = useState(0)
@@ -35,9 +55,9 @@ export function ScreenChrome({ onBack, backTestID, title, right }: ScreenChromeP
<BlurEdge solid={solid} />
<FadeEdge direction="down" solid={solid} opacity={layout.chromeTint} />
<View onLayout={(event) => setLeftWidth(event.nativeEvent.layout.width)}>
- <BackChip onPress={onBack} testID={backTestID} />
+ {nativeRail ? null : <BackChip onPress={onBack} testID={backTestID} />}
</View>
- <View onLayout={(event) => setRightWidth(event.nativeEvent.layout.width)}>{right}</View>
+ <View onLayout={(event) => setRightWidth(event.nativeEvent.layout.width)}>{nativeRail ? null : right}</View>
<Animated.View
style={[styles.titleSlot, { top, left: sideInset, right: sideInset }, titleStyle]}
pointerEvents="none"
diff --git a/products/mobile/src/ui/adaptiveLayout.test.ts b/products/mobile/src/ui/adaptiveLayout.test.ts
index 5a5e8884a609..96f5e26ad31d 100644
--- a/products/mobile/src/ui/adaptiveLayout.test.ts
+++ b/products/mobile/src/ui/adaptiveLayout.test.ts
@@ -1,6 +1,9 @@
import { adaptiveLayout } from './adaptiveLayout'
test.each([
+ { width: 951, height: 669, left: 0, right: 84, rail: true, paired: true, side: 'right' },
+ { width: 951, height: 669, left: 84, right: 0, rail: true, paired: true, side: 'left' },
+ { width: 469, height: 669, left: 84, right: 0, rail: false, paired: false, side: 'left' },
{ width: 402, height: 874, left: 0, right: 0, rail: false, paired: false, side: 'right' },
{ width: 951, height: 669, left: 0, right: 70, rail: true, paired: true, side: 'right' },
{ width: 951, height: 669, left: 70, right: 0, rail: true, paired: true, side: 'left' },
@@ -26,3 +29,51 @@ test.each([
])('preserves report reading space at $width × $height', ({ width, height, navigation }) => {
expect(adaptiveLayout(width, height, 0, 0).reportNavigation).toBe(navigation)
})
+
+test.each([
+ { frame: { x: 440, y: 0, width: 20, height: 669 }, width: 951, height: 669, axis: 'row', extent: 440 },
+ { frame: { x: 0, y: 440, width: 669, height: 20 }, width: 669, height: 951, axis: 'column', extent: 440 },
+])('aligns both panes to an active fold ($axis)', ({ frame, width, height, axis, extent }) => {
+ expect(adaptiveLayout(width, height, 0, 0, [{ kind: 'division', occludesContent: false, frame }])).toMatchObject({
+ paired: true,
+ paneAxis: axis,
+ inboxExtent: extent,
+ paneGap: 20,
+ })
+})
+
+test('accounts for a leading navigation rail when positioning the fold', () => {
+ expect(
+ adaptiveLayout(951, 669, 84, 0, [
+ { kind: 'division', occludesContent: false, frame: { x: 400, y: 0, width: 20, height: 669 } },
+ ])
+ ).toMatchObject({ rail: true, railSide: 'left', paired: true, inboxExtent: 320, paneGap: 20 })
+})
+
+test.each([0, 84])('leaves the rail to native navigation with a %spt leading safe area', (left) => {
+ expect(adaptiveLayout(951, 669, left, 84 - left, [], true)).toMatchObject({
+ rail: false,
+ contentWidth: 867,
+ reportNavigation: false,
+ paired: true,
+ })
+})
+
+test.each([
+ {
+ width: 600,
+ height: 669,
+ frame: { x: 290, y: 0, width: 20, height: 669 },
+ pane: { x: 310, y: 0, width: 290, height: 669 },
+ },
+ {
+ width: 669,
+ height: 500,
+ frame: { x: 0, y: 230, width: 669, height: 20 },
+ pane: { x: 0, y: 250, width: 669, height: 250 },
+ },
+])('keeps a single report within the detail pane at $width × $height', ({ width, height, frame, pane }) => {
+ expect(
+ adaptiveLayout(width, height, 0, 0, [{ kind: 'division', occludesContent: false, frame }], true)
+ ).toMatchObject({ paired: false, reportPane: pane })
+})
diff --git a/products/mobile/src/ui/adaptiveLayout.ts b/products/mobile/src/ui/adaptiveLayout.ts
index d7f7500822b9..14c2f5c07131 100644
--- a/products/mobile/src/ui/adaptiveLayout.ts
+++ b/products/mobile/src/ui/adaptiveLayout.ts
@@ -1,3 +1,5 @@
+import type { ReservedRegion } from 'react-native-reserved-regions'
+import { type DisplayRect, displayPanes } from './displayRegions'
export const NAV_RAIL_WIDTH = 80
export const INBOX_PANE_WIDTH = 300
export const REPORT_MIN_WIDTH = 440
@@ -7,24 +9,59 @@ export function adaptiveLayout(
width: number,
height: number,
left: number,
- right: number
+ right: number,
+ regions: readonly ReservedRegion[] = [],
+ nativeRail = false
): {
rail: boolean
railSide: 'left' | 'right'
contentWidth: number
paired: boolean
reportNavigation: boolean
+ inboxExtent: number
+ paneGap: number
+ paneAxis: 'row' | 'column'
+ reportPane: DisplayRect | null
} {
const safeWidth = Math.max(0, width - left - right)
const enoughHeight = height >= 480
const rail =
- enoughHeight && safeWidth >= 600 && (Math.max(left, right) >= 44 || (safeWidth >= 840 && safeWidth > height))
+ !nativeRail &&
+ enoughHeight &&
+ safeWidth >= 600 &&
+ (Math.max(left, right) >= 44 || (safeWidth >= 840 && safeWidth > height))
const contentWidth = Math.max(0, safeWidth - (rail ? NAV_RAIL_WIDTH : 0))
+ const railSide = left > right ? 'left' : 'right'
+ const panes = displayPanes(
+ { x: 0, y: 0, width: contentWidth, height },
+ regions
+ .filter((region) => region.kind === 'division')
+ .map((region) => ({
+ ...region,
+ frame: {
+ ...region.frame,
+ x: region.frame.x - (rail && railSide === 'left' ? NAV_RAIL_WIDTH : 0),
+ },
+ }))
+ )
+ const primary = panes[0]
+ const detail = panes[1]
+ const vertical = !!detail && detail.x > (primary?.x ?? 0)
+ const foldPair =
+ !!primary &&
+ !!detail &&
+ (vertical
+ ? primary.width >= 280 && detail.width >= 320 && enoughHeight
+ : contentWidth >= 320 && primary.height >= 240 && detail.height >= 300)
return {
+ reportPane: detail && !foldPair ? detail : null,
rail,
- railSide: left > right ? 'left' : 'right',
+ railSide,
contentWidth,
- paired: enoughHeight && contentWidth >= INBOX_PANE_WIDTH + REPORT_MIN_WIDTH,
- reportNavigation: enoughHeight && (rail || contentWidth >= 600),
+ paired: detail ? foldPair : enoughHeight && contentWidth >= INBOX_PANE_WIDTH + REPORT_MIN_WIDTH,
+ reportNavigation: !nativeRail && enoughHeight && (rail || contentWidth >= 600),
+ inboxExtent: foldPair && primary ? (vertical ? primary.width : primary.height) : INBOX_PANE_WIDTH,
+ paneGap: foldPair && primary && detail ? (vertical ? detail.x - primary.width : detail.y - primary.height) : 0,
+ paneAxis: foldPair && !vertical ? 'column' : 'row',
}
}
diff --git a/products/mobile/src/ui/displayRegionContext.ts b/products/mobile/src/ui/displayRegionContext.ts
new file mode 100644
index 000000000000..c4f9424d839f
--- /dev/null
+++ b/products/mobile/src/ui/displayRegionContext.ts
@@ -0,0 +1,9 @@
+import { createContext, useContext } from 'react'
+import { type ReservedRegion, useReservedRegions } from 'react-native-reserved-regions'
+
+export const DisplayRegionContext = createContext<readonly ReservedRegion[] | null>(null)
+
+export function useDisplayRegions(): readonly ReservedRegion[] {
+ const regions = useReservedRegions()
+ return useContext(DisplayRegionContext) ?? regions
+}
diff --git a/products/mobile/src/ui/displayRegions.test.ts b/products/mobile/src/ui/displayRegions.test.ts
new file mode 100644
index 000000000000..0130f043088f
--- /dev/null
+++ b/products/mobile/src/ui/displayRegions.test.ts
@@ -0,0 +1,54 @@
+import type { ReservedRegion } from 'react-native-reserved-regions'
+
+import { displayPanes, overlayPane } from './displayRegions'
+
+const BOUNDS = { x: 0, y: 0, width: 867, height: 669 }
+
+describe('display regions', () => {
+ test.each([
+ {
+ frame: { x: 465, y: 0, width: 16, height: 669 },
+ expected: [
+ { x: 0, y: 0, width: 465, height: 669 },
+ { x: 481, y: 0, width: 386, height: 669 },
+ ],
+ },
+ {
+ frame: { x: 465, y: 0, width: 0, height: 669 },
+ expected: [
+ { x: 0, y: 0, width: 465, height: 669 },
+ { x: 465, y: 0, width: 402, height: 669 },
+ ],
+ },
+ {
+ frame: { x: 0, y: 320, width: 867, height: 16 },
+ expected: [
+ { x: 0, y: 0, width: 867, height: 320 },
+ { x: 0, y: 336, width: 867, height: 333 },
+ ],
+ },
+ { frame: { x: 950, y: 0, width: 16, height: 669 }, expected: [BOUNDS] },
+ ])('keeps content on each side of the active fold ($frame)', ({ frame, expected }) => {
+ expect(displayPanes(BOUNDS, [{ kind: 'division', frame, occludesContent: false }])).toEqual(expected)
+ })
+
+ test.each([
+ { anchor: undefined, x: 481 },
+ { anchor: { x: 20, y: 40, width: 200, height: 60 }, x: 0 },
+ { anchor: { x: 600, y: 40, width: 200, height: 60 }, x: 481 },
+ ])('places an overlay beside its anchor, or over the detail pane ($x)', ({ anchor, x }) => {
+ const regions: ReservedRegion[] = [
+ { kind: 'division', frame: { x: 465, y: 0, width: 16, height: 669 }, occludesContent: false },
+ ]
+ expect(overlayPane(BOUNDS, regions, anchor).x).toBe(x)
+ })
+
+ test('keeps a floating surface below an interior camera region', () => {
+ expect(overlayPane(BOUNDS, [{ kind: 'occlusion', frame: { x: 400, y: 0, width: 60, height: 80 } }])).toEqual({
+ x: 0,
+ y: 80,
+ width: 867,
+ height: 589,
+ })
+ })
+})
diff --git a/products/mobile/src/ui/displayRegions.ts b/products/mobile/src/ui/displayRegions.ts
new file mode 100644
index 000000000000..1c7de01000e5
--- /dev/null
+++ b/products/mobile/src/ui/displayRegions.ts
@@ -0,0 +1,66 @@
+import type { ReservedRegion } from 'react-native-reserved-regions'
+
+export interface DisplayRect {
+ x: number
+ y: number
+ width: number
+ height: number
+}
+
+export function displayPanes(bounds: DisplayRect, regions: readonly ReservedRegion[]): DisplayRect[] {
+ let panes = [bounds]
+ for (const region of regions) {
+ const frame = region.frame
+ panes = panes.flatMap((pane) => {
+ const left = Math.max(pane.x, frame.x)
+ const right = Math.min(pane.x + pane.width, frame.x + frame.width)
+ const top = Math.max(pane.y, frame.y)
+ const bottom = Math.min(pane.y + pane.height, frame.y + frame.height)
+ if (left > right || top > bottom || (region.kind !== 'division' && (left === right || top === bottom)))
+ return [pane]
+ const candidates =
+ region.kind === 'division'
+ ? frame.height > frame.width
+ ? [
+ { ...pane, width: left - pane.x },
+ { ...pane, x: right, width: pane.x + pane.width - right },
+ ]
+ : [
+ { ...pane, height: top - pane.y },
+ { ...pane, y: bottom, height: pane.y + pane.height - bottom },
+ ]
+ : [
+ { ...pane, width: left - pane.x },
+ { ...pane, x: right, width: pane.x + pane.width - right },
+ { ...pane, height: top - pane.y },
+ { ...pane, y: bottom, height: pane.y + pane.height - bottom },
+ ]
+ const available = candidates.filter((candidate) => candidate.width > 0 && candidate.height > 0)
+ return region.kind === 'division'
+ ? available
+ : available.sort((a, b) => b.width * b.height - a.width * a.height).slice(0, 1)
+ })
+ }
+ return panes
+}
+
+export function overlayPane(
+ bounds: DisplayRect,
+ regions: readonly ReservedRegion[],
+ anchor?: DisplayRect
+): DisplayRect {
+ const panes = displayPanes(bounds, regions)
+ const center = anchor && { x: anchor.x + anchor.width / 2, y: anchor.y + anchor.height / 2 }
+ return (
+ (center &&
+ panes.find(
+ (pane) =>
+ center.x >= pane.x &&
+ center.x <= pane.x + pane.width &&
+ center.y >= pane.y &&
+ center.y <= pane.y + pane.height
+ )) ||
+ panes.at(-1) ||
+ bounds
+ )
+}
diff --git a/products/mobile/src/ui/icons/native/back.png b/products/mobile/src/ui/icons/native/back.png
new file mode 100644
index 000000000000..b613c63bec3a
Binary files /dev/null and b/products/mobile/src/ui/icons/native/back.png differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..16bb58e866d6
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..79ce34adbf51
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/chats.png b/products/mobile/src/ui/icons/native/chats.png
new file mode 100644
index 000000000000..0bb16b1166ee
Binary files /dev/null and b/products/mobile/src/ui/icons/native/chats.png differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..a2312d8faa1c
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..ebb7812fa7ca
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/close.png b/products/mobile/src/ui/icons/native/close.png
new file mode 100644
index 000000000000..a6abf149f8a5
Binary files /dev/null and b/products/mobile/src/ui/icons/native/close.png differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..6be14a85a348
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..50b63b84331f
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/compose.png b/products/mobile/src/ui/icons/native/compose.png
new file mode 100644
index 000000000000..a1d2bcf492b7
Binary files /dev/null and b/products/mobile/src/ui/icons/native/compose.png differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..93f2f5d52542
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..1d99e38a7d41
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/done.png b/products/mobile/src/ui/icons/native/done.png
new file mode 100644
index 000000000000..e7db580044ab
Binary files /dev/null and b/products/mobile/src/ui/icons/native/done.png differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..2c6a98261273
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..ff967fe45527
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/errors.png b/products/mobile/src/ui/icons/native/errors.png
new file mode 100644
index 000000000000..fb7a02c5309d
Binary files /dev/null and b/products/mobile/src/ui/icons/native/errors.png differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..248dd6e0aa18
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..2da72ec07982
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/external.png b/products/mobile/src/ui/icons/native/external.png
new file mode 100644
index 000000000000..019c6e003f1b
Binary files /dev/null and b/products/mobile/src/ui/icons/native/external.png differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..0b56496a2bef
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..541982b34591
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/filter.png b/products/mobile/src/ui/icons/native/filter.png
new file mode 100644
index 000000000000..483b170fd27b
Binary files /dev/null and b/products/mobile/src/ui/icons/native/filter.png differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..a7fcabac0e35
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..24f4f148d033
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/home.png b/products/mobile/src/ui/icons/native/home.png
new file mode 100644
index 000000000000..0552a3b9fc32
Binary files /dev/null and b/products/mobile/src/ui/icons/native/home.png differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..dab97f02237d
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..debe45d70732
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/more.png b/products/mobile/src/ui/icons/native/more.png
new file mode 100644
index 000000000000..6ba995817632
Binary files /dev/null and b/products/mobile/src/ui/icons/native/more.png differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..d894447cf80f
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..31cd8a981e0f
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/next.png b/products/mobile/src/ui/icons/native/next.png
new file mode 100644
index 000000000000..33f8173e91af
Binary files /dev/null and b/products/mobile/src/ui/icons/native/next.png differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..81c442fdae91
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..5b3a48454fc5
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/replay.png b/products/mobile/src/ui/icons/native/replay.png
new file mode 100644
index 000000000000..3d8f7f50dbef
Binary files /dev/null and b/products/mobile/src/ui/icons/native/replay.png differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..41a18753ce31
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..3fd78323fa96
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/views.png b/products/mobile/src/ui/icons/native/views.png
new file mode 100644
index 000000000000..9ed98489db35
Binary files /dev/null and b/products/mobile/src/ui/icons/native/views.png differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..299200a23bcd
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/native/[email protected] b/products/mobile/src/ui/icons/native/[email protected]
new file mode 100644
index 000000000000..9cfc73b0755c
Binary files /dev/null and b/products/mobile/src/ui/icons/native/[email protected] differ
diff --git a/products/mobile/src/ui/icons/nativeIcons.ts b/products/mobile/src/ui/icons/nativeIcons.ts
new file mode 100644
index 000000000000..4b4a043135a2
--- /dev/null
+++ b/products/mobile/src/ui/icons/nativeIcons.ts
@@ -0,0 +1,15 @@
+export const nativeIcons = {
+ home: require('./native/home.png'),
+ chats: require('./native/chats.png'),
+ views: require('./native/views.png'),
+ errors: require('./native/errors.png'),
+ replay: require('./native/replay.png'),
+ compose: require('./native/compose.png'),
+ filter: require('./native/filter.png'),
+ more: require('./native/more.png'),
+ back: require('./native/back.png'),
+ next: require('./native/next.png'),
+ external: require('./native/external.png'),
+ close: require('./native/close.png'),
+ done: require('./native/done.png'),
+}
diff --git a/products/mobile/src/ui/nativeHeaderCleanup.test.tsx b/products/mobile/src/ui/nativeHeaderCleanup.test.tsx
new file mode 100644
index 000000000000..ea840aa7c9a9
--- /dev/null
+++ b/products/mobile/src/ui/nativeHeaderCleanup.test.tsx
@@ -0,0 +1,40 @@
+import { render } from '@testing-library/react-native'
+import type { ReactElement } from 'react'
+import { View } from 'react-native'
+import { NativeChatChrome } from '@/features/chat/NativeChatChrome'
+import { NativeTabChrome } from '@/features/tabs/NativeTabChrome'
+import { NativeScreenChrome } from './NativeScreenChrome'
+
+let mockOptions: Record<string, unknown> = {}
+const mockNavigation = { setOptions: (options: Record<string, unknown>) => Object.assign(mockOptions, options) }
+
+jest.mock('expo-router', () => {
+ const { useLayoutEffect } = jest.requireActual<typeof import('react')>('react')
+ const Screen = ({ options }: { options: Record<string, unknown> }): null => {
+ useLayoutEffect(() => {
+ mockNavigation.setOptions(options)
+ }, [options])
+ return null
+ }
+ const Toolbar = Object.assign(() => null, { Button: () => null })
+ return { Stack: { Screen, Toolbar }, useNavigation: () => mockNavigation, useRouter: () => ({ push: jest.fn() }) }
+})
+
+const noop = (): void => undefined
+const chromes: [string, ReactElement][] = [
+ ['screen', <NativeScreenChrome key="screen" onBack={noop} backTestID="back" />],
+ ['chat', <NativeChatChrome key="chat" onBack={noop} onMore={noop} onNewChat={noop} hasActions />],
+ ['tab', <NativeTabChrome key="tab" slot={null} onMore={noop} />],
+]
+
+describe('native header lifecycle', () => {
+ test.each(chromes)('hides the %s header and restores back gestures when the rail disappears', (_name, chrome) => {
+ mockOptions = {}
+ const view = render(chrome)
+ expect(mockOptions.headerShown).toBe(true)
+ view.rerender(<View />)
+ expect(mockOptions).toMatchObject({ headerShown: false, gestureEnabled: true })
+ view.rerender(chrome)
+ expect(mockOptions.headerShown).toBe(true)
+ })
+})
diff --git a/products/mobile/src/ui/overlayDismiss.ts b/products/mobile/src/ui/overlayDismiss.ts
new file mode 100644
index 000000000000..383be9f19781
--- /dev/null
+++ b/products/mobile/src/ui/overlayDismiss.ts
@@ -0,0 +1,24 @@
+import { createContext, useContext } from 'react'
+import { create } from 'zustand'
+
+export const OverlayDismissContext = createContext<{
+ set: (key: string, close: (() => void) | null) => void
+ close: (() => void) | null
+} | null>(null)
+
+export function useOverlayDismiss(): (() => void) | null {
+ return useContext(OverlayDismissContext)?.close ?? null
+}
+
+export const useNavigationOverlayStore = create<{
+ keys: string[]
+ set: (key: string, visible: boolean) => void
+}>()((set) => ({
+ keys: [],
+ set: (key, visible) =>
+ set((state) => ({
+ keys: visible
+ ? [...state.keys.filter((item) => item !== key), key]
+ : state.keys.filter((item) => item !== key),
+ })),
+}))
diff --git a/products/mobile/src/ui/overlayFrame.ts b/products/mobile/src/ui/overlayFrame.ts
new file mode 100644
index 000000000000..dd8653263215
--- /dev/null
+++ b/products/mobile/src/ui/overlayFrame.ts
@@ -0,0 +1,5 @@
+import { createContext } from 'react'
+
+import type { DisplayRect } from './displayRegions'
+
+export const OverlayFrameContext = createContext<DisplayRect | null>(null)
diff --git a/products/mobile/src/ui/useAppLayout.ts b/products/mobile/src/ui/useAppLayout.ts
index 0f91ea08c345..cbfa867766e1 100644
--- a/products/mobile/src/ui/useAppLayout.ts
+++ b/products/mobile/src/ui/useAppLayout.ts
@@ -1,10 +1,13 @@
import { useWindowDimensions } from 'react-native'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
-
+import { useDisplayRegions } from '@/ui/displayRegionContext'
import { adaptiveLayout } from './adaptiveLayout'
+import { useNativeRail } from './useNativeRail'
export function useAppLayout(): ReturnType<typeof adaptiveLayout> {
const { width, height } = useWindowDimensions()
const { left, right } = useSafeAreaInsets()
- return adaptiveLayout(width, height, left, right)
+ const regions = useDisplayRegions()
+ const nativeRail = useNativeRail()
+ return adaptiveLayout(width, height, left, right, regions, nativeRail)
}
diff --git a/products/mobile/src/ui/useFloatingMenuStyle.ts b/products/mobile/src/ui/useFloatingMenuStyle.ts
new file mode 100644
index 000000000000..2adb6f592552
--- /dev/null
+++ b/products/mobile/src/ui/useFloatingMenuStyle.ts
@@ -0,0 +1,19 @@
+import type { ViewStyle } from 'react-native'
+
+import { useOverlayPane } from './useOverlayPane'
+import { useScreenInsets } from './useScreenInsets'
+
+export function useFloatingMenuStyle(top: number, preferredWidth: number): ViewStyle {
+ const pane = useOverlayPane()
+ const insets = useScreenInsets()
+ const gutter = 14
+ const width = Math.max(0, Math.min(preferredWidth, pane.width - gutter * 2))
+ const fittedTop = Math.max(pane.y + gutter, Math.min(top, pane.y + pane.height - 120))
+ return {
+ left: pane.x + pane.width - width - gutter,
+ right: undefined,
+ top: fittedTop,
+ width,
+ maxHeight: Math.max(0, pane.y + pane.height - insets.bottom - gutter - fittedTop),
+ }
+}
diff --git a/products/mobile/src/ui/useNativeHeaderCleanup.ts b/products/mobile/src/ui/useNativeHeaderCleanup.ts
new file mode 100644
index 000000000000..50cfc179ff82
--- /dev/null
+++ b/products/mobile/src/ui/useNativeHeaderCleanup.ts
@@ -0,0 +1,8 @@
+import { useNavigation } from 'expo-router'
+import { useLayoutEffect } from 'react'
+
+export function useNativeHeaderCleanup(): void {
+ const navigation = useNavigation()
+ // Stack.Screen leaves its options set after unmount, including when the system moves the rail.
+ useLayoutEffect(() => () => navigation.setOptions({ headerShown: false, gestureEnabled: true }), [navigation])
+}
diff --git a/products/mobile/src/ui/useNativeRail.test.ts b/products/mobile/src/ui/useNativeRail.test.ts
new file mode 100644
index 000000000000..d4ec6a7198d6
--- /dev/null
+++ b/products/mobile/src/ui/useNativeRail.test.ts
@@ -0,0 +1,63 @@
+import { act, cleanupAsync, renderHookAsync } from '@testing-library/react-native'
+import type { VerticalBarEdgeIOS } from 'expo-status-bar'
+import { Platform } from 'react-native'
+import { useNativeRail } from './useNativeRail'
+
+const mockSubscribe = jest.fn()
+const mockSynchronousRead = jest.fn()
+const mockRemove = jest.fn()
+let onChange: (event: { edge: VerticalBarEdgeIOS | null }) => void
+
+jest.mock('expo', () => ({
+ requireOptionalNativeModule: () => ({
+ addListener: (_event: string, listener: typeof onChange) => mockSubscribe(listener),
+ getVerticalBarEdge: () => mockSynchronousRead(),
+ }),
+}))
+
+describe('useNativeRail', () => {
+ const originalPlatform = Platform.OS
+ beforeEach(() => {
+ Platform.OS = 'ios'
+ jest.clearAllMocks()
+ mockSubscribe.mockImplementation((listener: typeof onChange) => {
+ onChange = listener
+ return { remove: mockRemove }
+ })
+ })
+ afterEach(async () => {
+ await cleanupAsync()
+ Platform.OS = originalPlatform
+ })
+
+ test('receives the initial rail and fold changes without a synchronous native read', async () => {
+ const { result } = await renderHookAsync(useNativeRail)
+ expect(result.current).toBe(false)
+ for (const edge of ['leading', 'trailing', null] as const) {
+ await act(async () => onChange({ edge }))
+ expect(result.current).toBe(edge !== null)
+ }
+ expect(mockSynchronousRead).not.toHaveBeenCalled()
+ })
+
+ test('shares the current edge and native subscription across screens', async () => {
+ const first = await renderHookAsync(useNativeRail)
+ await act(async () => onChange({ edge: 'trailing' }))
+ const second = await renderHookAsync(useNativeRail)
+ expect(second.result.current).toBe(true)
+ expect(mockSubscribe).toHaveBeenCalledTimes(1)
+ await first.unmountAsync()
+ expect(mockRemove).not.toHaveBeenCalled()
+ await act(async () => onChange({ edge: null }))
+ expect(second.result.current).toBe(false)
+ await second.unmountAsync()
+ expect(mockRemove).toHaveBeenCalledTimes(1)
+ })
+
+ test('does not subscribe on Android', async () => {
+ Platform.OS = 'android'
+ const { result } = await renderHookAsync(useNativeRail)
+ expect(result.current).toBe(false)
+ expect(mockSubscribe).not.toHaveBeenCalled()
+ })
+})
diff --git a/products/mobile/src/ui/useNativeRail.ts b/products/mobile/src/ui/useNativeRail.ts
new file mode 100644
index 000000000000..f0cf7787e1b6
--- /dev/null
+++ b/products/mobile/src/ui/useNativeRail.ts
@@ -0,0 +1,44 @@
+import { type EventSubscription, requireOptionalNativeModule } from 'expo'
+import type { VerticalBarEdgeIOS } from 'expo-status-bar'
+import { useSyncExternalStore } from 'react'
+import { Platform } from 'react-native'
+
+const statusBar = requireOptionalNativeModule<{
+ addListener: (
+ event: 'onVerticalBarEdgeChange',
+ listener: (event: { edge: VerticalBarEdgeIOS | null }) => void
+ ) => EventSubscription
+}>('ExpoStatusBar')
+const listeners = new Set<() => void>()
+let subscription: EventSubscription | null = null
+let nativeRail = false
+
+function subscribe(listener: () => void): () => void {
+ if (Platform.OS !== 'ios' || !statusBar) return () => undefined
+ listeners.add(listener)
+ if (!subscription) {
+ // Expo sends the initial edge asynchronously; its synchronous getter can deadlock React's event beat.
+ subscription = statusBar.addListener('onVerticalBarEdgeChange', ({ edge }) => {
+ const next = edge === 'leading' || edge === 'trailing'
+ if (next === nativeRail) return
+ nativeRail = next
+ for (const notify of listeners) notify()
+ })
+ }
+ return () => {
+ listeners.delete(listener)
+ if (listeners.size === 0) {
+ subscription?.remove()
+ subscription = null
+ nativeRail = false
+ }
+ }
+}
+
+function snapshot(): boolean {
+ return nativeRail
+}
+
+export function useNativeRail(): boolean {
+ return useSyncExternalStore(subscribe, snapshot, snapshot)
+}
diff --git a/products/mobile/src/ui/useOverlayBack.ts b/products/mobile/src/ui/useOverlayBack.ts
index 7d63d6a1f63a..9432662543d6 100644
--- a/products/mobile/src/ui/useOverlayBack.ts
+++ b/products/mobile/src/ui/useOverlayBack.ts
@@ -1,9 +1,12 @@
import { useIsFocused } from 'expo-router'
-import { useEffect, useRef } from 'react'
+import { useContext, useEffect, useId, useRef } from 'react'
import { BackHandler } from 'react-native'
+import { OverlayDismissContext, useNavigationOverlayStore } from './overlayDismiss'
export function useOverlayBack(visible: boolean, onClose: () => void): void {
const focused = useIsFocused()
+ const key = useId()
+ const setDismissal = useContext(OverlayDismissContext)?.set
const close = useRef(onClose)
useEffect(() => {
close.current = onClose
@@ -13,10 +16,16 @@ export function useOverlayBack(visible: boolean, onClose: () => void): void {
if (!visible || !focused) {
return
}
+ useNavigationOverlayStore.getState().set(key, true)
+ setDismissal?.(key, () => close.current())
const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
close.current()
return true
})
- return () => subscription.remove()
- }, [visible, focused])
+ return () => {
+ useNavigationOverlayStore.getState().set(key, false)
+ setDismissal?.(key, null)
+ subscription.remove()
+ }
+ }, [visible, focused, key, setDismissal])
}
diff --git a/products/mobile/src/ui/useOverlayFrame.ts b/products/mobile/src/ui/useOverlayFrame.ts
new file mode 100644
index 000000000000..bc6ed565bed3
--- /dev/null
+++ b/products/mobile/src/ui/useOverlayFrame.ts
@@ -0,0 +1,11 @@
+import { useContext } from 'react'
+
+import type { DisplayRect } from './displayRegions'
+import { OverlayFrameContext } from './overlayFrame'
+import { useSceneDimensions } from './useSceneDimensions'
+
+export function useOverlayFrame(): DisplayRect {
+ const frame = useContext(OverlayFrameContext)
+ const { width, height } = useSceneDimensions()
+ return frame ?? { x: 0, y: 0, width, height }
+}
diff --git a/products/mobile/src/ui/useOverlayPane.ts b/products/mobile/src/ui/useOverlayPane.ts
new file mode 100644
index 000000000000..f23bf94ed755
--- /dev/null
+++ b/products/mobile/src/ui/useOverlayPane.ts
@@ -0,0 +1,15 @@
+import { useContext } from 'react'
+import { useDisplayRegions } from '@/ui/displayRegionContext'
+
+import { type DisplayRect, overlayPane } from './displayRegions'
+import { OverlayFrameContext } from './overlayFrame'
+import { useSceneDimensions } from './useSceneDimensions'
+
+export function useOverlayPane(anchor?: DisplayRect): DisplayRect {
+ const scene = useSceneDimensions()
+ const frame = useContext(OverlayFrameContext)
+ const { width, height } = frame ?? scene
+ const regions = useDisplayRegions()
+ const localAnchor = anchor && { ...anchor, x: anchor.x - (frame?.x ?? 0), y: anchor.y - (frame?.y ?? 0) }
+ return overlayPane({ x: 0, y: 0, width, height }, regions, localAnchor)
+}
diff --git a/products/mobile/src/ui/usePickerCardStyle.test.ts b/products/mobile/src/ui/usePickerCardStyle.test.ts
index d052d9ce7ee7..a897c62bdddd 100644
--- a/products/mobile/src/ui/usePickerCardStyle.test.ts
+++ b/products/mobile/src/ui/usePickerCardStyle.test.ts
@@ -17,7 +17,7 @@ jest.mock('./useScreenInsets', () => ({
test('keeps a picker above the keyboard when less than 120 points remain', () => {
const { result } = renderHook(() => usePickerCardStyle(90, 320))
- expect(result.current).toEqual({ top: 56, height: 98 })
+ expect(result.current).toMatchObject({ top: 56, height: 98 })
const style = result.current as { top: number; height: number }
expect(style.top + style.height).toBeLessThan(393 - 235)
})
diff --git a/products/mobile/src/ui/usePickerCardStyle.ts b/products/mobile/src/ui/usePickerCardStyle.ts
index 444825cbba21..6812f58730e2 100644
--- a/products/mobile/src/ui/usePickerCardStyle.ts
+++ b/products/mobile/src/ui/usePickerCardStyle.ts
@@ -2,18 +2,26 @@ import type { ComponentProps } from 'react'
import { useReanimatedKeyboardAnimation } from 'react-native-keyboard-controller'
import type Animated from 'react-native-reanimated'
import { useAnimatedStyle } from 'react-native-reanimated'
-
-import { useSceneDimensions } from './useSceneDimensions'
+import { useOverlayFrame } from './useOverlayFrame'
+import { useOverlayPane } from './useOverlayPane'
import { useScreenInsets } from './useScreenInsets'
export function usePickerCardStyle(top: number, height: number): ComponentProps<typeof Animated.View>['style'] {
const keyboard = useReanimatedKeyboardAnimation()
const insets = useScreenInsets()
- const { height: sceneHeight } = useSceneDimensions()
+ const pane = useOverlayPane()
+ const frame = useOverlayFrame()
return useAnimatedStyle(() => {
const keyboardHeight = Math.max(-keyboard.height.value, 0)
- const bottom = sceneHeight - Math.max(keyboardHeight, insets.bottom) - 4
- const fittedTop = Math.min(top, Math.max(insets.top + 4, bottom - height))
- return { top: fittedTop, height: Math.max(0, Math.min(height, bottom - fittedTop)) }
+ const bottom = Math.min(pane.y + pane.height - insets.bottom, frame.height - keyboardHeight) - 4
+ const minimumTop = pane.y + (pane.y === 0 ? insets.top : 0) + 4
+ const fittedTop = Math.min(Math.max(top, minimumTop), Math.max(minimumTop, bottom - height))
+ const side = Math.max(14, (pane.width - 600) / 2)
+ return {
+ left: pane.x + side,
+ right: frame.width - pane.x - pane.width + side,
+ top: fittedTop,
+ height: Math.max(0, Math.min(height, bottom - fittedTop)),
+ }
})
}
diff --git a/products/mobile/src/ui/useScreenInsets.ts b/products/mobile/src/ui/useScreenInsets.ts
index 56981ae37cb2..641263e2c924 100644
--- a/products/mobile/src/ui/useScreenInsets.ts
+++ b/products/mobile/src/ui/useScreenInsets.ts
@@ -2,6 +2,7 @@ import { Platform } from 'react-native'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { layout } from './tokens'
+import { useNativeRail } from './useNativeRail'
export interface ScreenInsets {
top: number
@@ -31,3 +32,13 @@ export function topOffset(insets: Pick<ScreenInsets, 'top'>, designTop: number):
export function bottomOffset(insets: Pick<ScreenInsets, 'bottom'>, designBottom: number): number {
return Math.max(insets.bottom + designBottom - layout.designHomeIndicator, layout.minBottomPadding)
}
+
+export function tabBottomOffset(insets: Pick<ScreenInsets, 'bottom'>): number {
+ return bottomOffset(insets, 120)
+}
+
+export function useTabBottomOffset(): number {
+ const insets = useScreenInsets()
+ const nativeRail = useNativeRail()
+ return nativeRail ? insets.bottom + layout.minBottomPadding : tabBottomOffset(insets)
+}