Skip to content
TypeScript

fix(mobile): smoother Settings and composer transitions on wide Android (#26297)

Julius Marminge7ccd02cc810a
diff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsx
index eea909a7294..79f0932b1e9 100644
--- a/apps/mobile/src/Stack.tsx
+++ b/apps/mobile/src/Stack.tsx
@@ -1042,9 +1042,15 @@ export const RootStack = RootStackConfig.with(function AdaptiveRootStack({ Navig
return (
<Navigator
screenLayout={(props) => <GuardedScreenLayout {...props} />}
- screenOptions={({ route }) =>
+ screenOptions={({ route, navigation }) =>
Platform.OS === "android"
- ? { animation: androidWorkspaceDestinationAnimation(route.name, usesSplitView) }
+ ? {
+ animation: androidWorkspaceDestinationAnimation(
+ route,
+ navigation.getState().routes,
+ usesSplitView,
+ ),
+ }
: {}
}
/>
diff --git a/apps/mobile/src/features/keyboard/useSoftKeyboardShowing.ts b/apps/mobile/src/features/keyboard/useSoftKeyboardShowing.ts
new file mode 100644
index 00000000000..b7956524a10
--- /dev/null
+++ b/apps/mobile/src/features/keyboard/useSoftKeyboardShowing.ts
@@ -0,0 +1,26 @@
+import { useSyncExternalStore } from "react";
+import { KeyboardController, KeyboardEvents } from "react-native-keyboard-controller";
+
+// `useKeyboardState` only flips on willShow and didHide. This follows the will-events, so a
+// layout that makes room for the keyboard gives it back as soon as the keyboard starts hiding.
+let keyboardShowing = KeyboardController.isVisible();
+function subscribeKeyboardShowing(onChange: () => void) {
+ keyboardShowing = KeyboardController.isVisible();
+ const willShow = KeyboardEvents.addListener("keyboardWillShow", () => {
+ keyboardShowing = true;
+ onChange();
+ });
+ const willHide = KeyboardEvents.addListener("keyboardWillHide", () => {
+ keyboardShowing = false;
+ onChange();
+ });
+ return () => {
+ willShow.remove();
+ willHide.remove();
+ };
+}
+const getKeyboardShowing = () => keyboardShowing;
+
+export function useSoftKeyboardShowing() {
+ return useSyncExternalStore(subscribeKeyboardShowing, getKeyboardShowing);
+}
diff --git a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
index 1605498fcd2..5cdbcfe7fbf 100644
--- a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+++ b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
@@ -3,6 +3,7 @@ import {
WorkspacePresentationHostContext,
} from "./workspace-presentation-context";
import { useAndroidFloatingTabs } from "../settings/appearance/AppearancePreferencesProvider";
+import { useSoftKeyboardShowing } from "../keyboard/useSoftKeyboardShowing";
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
import { AdaptiveWorkspaceContext, useAdaptiveWorkspaceLayout } from "./adaptive-workspace-context";
import { threadSelectionDeferral } from "./deferred-navigation";
@@ -28,7 +29,7 @@ import {
useWindowDimensions,
View,
} from "react-native";
-import { KeyboardController, useKeyboardState } from "react-native-keyboard-controller";
+import { KeyboardController, useKeyboardContext } from "react-native-keyboard-controller";
import Animated, {
runOnJS,
useAnimatedStyle,
@@ -285,20 +286,32 @@ function AdaptiveWorkspaceLayoutContent(
usesSplitView: baseLayout.usesSplitView,
});
const [composerEditing, setComposerEditing] = useState(false);
- const softKeyboardVisible = useKeyboardState((state) => state.isVisible);
+ const softKeyboardVisible = useSoftKeyboardShowing();
// Keyed on the soft keyboard, not focus: a hardware keyboard leaves room for the sidebar, and
- // Back closes the keyboard while the editor keeps focus. Deferred so the composer commits its
- // keyboard render first; relaying out in the same commit held it behind the keyboard.
+ // Back closes the keyboard while the editor keeps focus. The sidebar returns as the keyboard
+ // starts hiding, not after. Deferred so the composer commits its keyboard render first;
+ // relaying out in the same commit held it behind the keyboard.
const composerKeyboardActive = useDeferredValue(
Platform.OS === "android" && baseLayout.usesSplitView && composerEditing && softKeyboardVisible,
);
+ const sidebarWithoutKeyboard =
+ !workspacePage && (primarySidebarPinned || preferredSidebarVisible);
const showPrimarySidebar =
- !workspacePage &&
- (primarySidebarPinned || (preferredSidebarVisible && !composerKeyboardActive));
+ sidebarWithoutKeyboard && (primarySidebarPinned || !composerKeyboardActive);
// Medium windows float the sidebar over a page; beside a list it keeps its room.
const sidebarFloats =
baseLayout.variant === "medium" &&
(nativeWorkspace || (!primarySidebarPinned && !workspacePage));
+ // While the composer edits, the sidebar's width follows the keyboard's own progress, so it
+ // leaves and returns in step with the keyboard instead of on a timer of its own.
+ const keyboardHoldsSidebar =
+ Platform.OS === "android" &&
+ baseLayout.usesSplitView &&
+ !workspacePage &&
+ !primarySidebarPinned &&
+ !sidebarFloats &&
+ (composerEditing || composerKeyboardActive);
+ const keyboardProgress = useKeyboardContext().reanimated.progress;
const shouldRenderNavigationRail =
Platform.OS === "android" && baseLayout.usesSplitView && !floatingTabsEnabled;
const enabledTabs = useEnabledNavigationTabs();
@@ -405,6 +418,37 @@ function AdaptiveWorkspaceLayoutContent(
workspacePage,
],
);
+ // Whether the sidebar is open once the keyboard is gone; the keyboard's progress scales it.
+ const sidebarRestsOpen = useMemo(
+ () =>
+ showPrimarySidebar === sidebarWithoutKeyboard
+ ? panes.primarySidebarVisible
+ : deriveWorkspacePaneLayout({
+ layout,
+ viewportWidth: width,
+ nativeWorkspace,
+ primarySidebarFloats: sidebarFloats,
+ primarySidebarPreferredVisible: sidebarWithoutKeyboard,
+ auxiliaryPanePreferredVisible:
+ !workspacePage && inspectorActive && fileInspectorPreferredVisible,
+ auxiliaryPanePreferredWidth: fileInspectorPreferredWidth ?? undefined,
+ nativeInspectorWidth,
+ }).primarySidebarVisible,
+ [
+ nativeInspectorWidth,
+ fileInspectorPreferredVisible,
+ fileInspectorPreferredWidth,
+ inspectorActive,
+ layout,
+ nativeWorkspace,
+ panes.primarySidebarVisible,
+ showPrimarySidebar,
+ sidebarFloats,
+ sidebarWithoutKeyboard,
+ width,
+ workspacePage,
+ ],
+ );
// Routes still on the stack remember their reveal, so going back to one keeps the user's choice.
const revealedInspectors = useRef<ReadonlyMap<string, string>>(new Map());
const workspaceInspectorOwner = useRef<symbol | null>(null);
@@ -704,10 +748,16 @@ function AdaptiveWorkspaceLayoutContent(
panes.primarySidebarVisible ? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0) : 0,
);
const renderedRailWidth = useSharedValue(navigationRailWidth);
+ const keyboardHold = useSharedValue(keyboardHoldsSidebar);
const leavingWorkspacePage = useRef(false);
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- animates the Reanimated rail and sidebar width shared values toward the layout's targets
useEffect(() => {
if (nativeWorkspace) return;
+ // Released mid-keyboard (the composer blurred), the timing starts where the sidebar is drawn.
+ if (keyboardHold.get() && !keyboardHoldsSidebar) {
+ renderedSidebarWidth.set(renderedSidebarWidth.get() * (1 - keyboardProgress.get()));
+ }
+ keyboardHold.set(keyboardHoldsSidebar);
renderedRailWidth.set(withTiming(navigationRailWidth, WORKSPACE_PANE_TIMING));
// A workspace page hides the sidebar through React instead, in the same commit that mounts
// the page. Animating it here would hide it a few frames before the page appears.
@@ -717,7 +767,7 @@ function AdaptiveWorkspaceLayoutContent(
}
const snap = leavingWorkspacePage.current;
leavingWorkspacePage.current = false;
- const targetWidth = panes.primarySidebarVisible
+ const targetWidth = (keyboardHoldsSidebar ? sidebarRestsOpen : panes.primarySidebarVisible)
? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0)
: 0;
// The content beside it already took its final width when the page closed.
@@ -732,6 +782,10 @@ function AdaptiveWorkspaceLayoutContent(
layout.listPaneWidth,
layout.listPaneGap,
panes.primarySidebarVisible,
+ keyboardHoldsSidebar,
+ keyboardHold,
+ keyboardProgress,
+ sidebarRestsOpen,
renderedSidebarWidth,
renderedRailWidth,
settleListPane,
@@ -765,19 +819,23 @@ function AdaptiveWorkspaceLayoutContent(
// Showing or hiding the sidebar clips a fixed-width list. A hinge resize instead tracks the
// animated edge, so the header actions slide with it rather than jumping or being covered.
const listPaneGap = layout.listPaneGap ?? 0;
+ const drawnSidebarWidth = useDerivedValue(
+ () => renderedSidebarWidth.value * (keyboardHold.value ? 1 - keyboardProgress.value : 1),
+ );
const listPaneAnimatedStyle = useAnimatedStyle(() => ({
width: Math.min(
listPaneCeiling,
- Math.max(listPaneFloor, renderedSidebarWidth.value - listPaneGap),
+ Math.max(listPaneFloor, drawnSidebarWidth.value - listPaneGap),
),
+ // Following the keyboard, the list rides the sidebar's edge like the content beside it,
+ // instead of being uncovered in place.
+ transform: [{ translateX: drawnSidebarWidth.value - renderedSidebarWidth.value }],
}));
const sidebarAnimatedStyle = useAnimatedStyle(() => ({
// Fading a UIKit glass ancestor can leave remounted header effects missing.
opacity:
- Platform.OS === "ios" || floatingTabsEnabled
- ? 1
- : Math.min(1, renderedSidebarWidth.value / 80),
- width: renderedSidebarWidth.value,
+ Platform.OS === "ios" || floatingTabsEnabled ? 1 : Math.min(1, drawnSidebarWidth.value / 80),
+ width: drawnSidebarWidth.value,
}));
// Clip the navigator at its settled width so native headers and markdown reflow only once per pane toggle.
@@ -787,7 +845,7 @@ function AdaptiveWorkspaceLayoutContent(
0,
viewportWidth -
(sidebarFloats ? 0 : renderedRailWidth.value) -
- (workspacePage || sidebarFloats ? 0 : renderedSidebarWidth.value) -
+ (workspacePage || sidebarFloats ? 0 : drawnSidebarWidth.value) -
renderedInspectorWidth.value,
),
);
@@ -951,14 +1009,18 @@ function AdaptiveWorkspaceLayoutContent(
<Animated.View
collapsable={false}
style={[
- contentTargetWidth !== null
- ? {
- flex: 1,
- width: contentTargetWidth,
- alignSelf: contentAnchor.end ? "flex-end" : "flex-start",
- marginRight: contentAnchor.end ? contentEndGap : 0,
- }
- : { flex: 1 },
+ // While the keyboard moves the sidebar, the content tracks its edge every frame so
+ // the two land together; a settled width would jump when React commits mid-slide.
+ keyboardHoldsSidebar
+ ? { flex: 1, marginRight: contentEndGap }
+ : contentTargetWidth !== null
+ ? {
+ flex: 1,
+ width: contentTargetWidth,
+ alignSelf: contentAnchor.end ? "flex-end" : "flex-start",
+ marginRight: contentAnchor.end ? contentEndGap : 0,
+ }
+ : { flex: 1 },
Platform.OS === "android" ? androidNavigatorLimit : undefined,
]}
>
diff --git a/apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx
index 8b89877879e..73e1ffa9358 100644
--- a/apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx
@@ -1,11 +1,11 @@
import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
import { useAtomSet, useAtomValue } from "@effect/atom-react";
-import { useNavigation } from "@react-navigation/native";
import { AsyncResult } from "effect/reactivity";
import { Platform, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppBar } from "../../components/ui/AppBar";
+import { useSettingsPageBack } from "./useSettingsPageBack";
import { AppText as Text } from "../../components/ui/AppText";
import { NativeStackScreenOptions } from "../../native/StackHeader";
import {
@@ -34,7 +34,7 @@ const ENTER_BEHAVIOR_OPTIONS: ReadonlyArray<{
];
export function SettingsKeyboardRouteScreen() {
- const navigation = useNavigation();
+ const back = useSettingsPageBack();
const insets = useSafeAreaInsets();
const preferencesResult = useAtomValue(mobilePreferencesAtom);
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
@@ -48,7 +48,7 @@ export function SettingsKeyboardRouteScreen() {
{Platform.OS === "android" ? (
<>
<NativeStackScreenOptions options={{ headerShown: false }} />
- <AppBar embedded title="Keyboard" onBack={() => navigation.goBack()} />
+ <AppBar embedded title="Keyboard" onBack={back} />
</>
) : null}
<ScrollView
diff --git a/apps/mobile/src/features/settings/SettingsWorkspaceLayout.android.tsx b/apps/mobile/src/features/settings/SettingsWorkspaceLayout.android.tsx
index 9fbc8eb4528..05bef326c3e 100644
--- a/apps/mobile/src/features/settings/SettingsWorkspaceLayout.android.tsx
+++ b/apps/mobile/src/features/settings/SettingsWorkspaceLayout.android.tsx
@@ -33,7 +33,8 @@ export function SettingsWorkspaceLayout(props: { readonly children: ReactNode })
</View>
</Activity>
) : null}
- <View className="flex-1">
+ {/* A push slides the page underneath to the left; keep it out of the list beside it. */}
+ <View className="flex-1 overflow-hidden">
<View
className="flex-1"
pointerEvents={emptyDetail ? "none" : "auto"}
diff --git a/apps/mobile/src/features/settings/components/SettingsScreen.tsx b/apps/mobile/src/features/settings/components/SettingsScreen.tsx
index ac9ef97706c..a18ae1c1566 100644
--- a/apps/mobile/src/features/settings/components/SettingsScreen.tsx
+++ b/apps/mobile/src/features/settings/components/SettingsScreen.tsx
@@ -1,4 +1,4 @@
-import { useNavigation, useRoute } from "@react-navigation/native";
+import { useRoute } from "@react-navigation/native";
import type { ReactNode } from "react";
import { Platform, View } from "react-native";
@@ -9,6 +9,7 @@ import { useWorkspaceTabs } from "../../workspace/WorkspaceTabsContext";
import { useDeviceType } from "../../../native/native-layout-metrics";
import { useCompactWorkspaceTabs } from "../../workspace/useSystemWorkspaceTabBar";
import { useAdaptiveWorkspaceLayout } from "../../layout/adaptive-workspace-context";
+import { useSettingsPageBack } from "../useSettingsPageBack";
import {
ScreenScrollViewBottomInset,
ScreenScrollViewSurface,
@@ -23,12 +24,12 @@ export function SettingsScreen(
readonly workspaceRoot?: boolean;
},
) {
- const navigation = useNavigation();
const route = useRoute();
const workspace = useWorkspaceTabs();
const deviceType = useDeviceType();
const compactTabs = useCompactWorkspaceTabs();
const { layout } = useAdaptiveWorkspaceLayout();
+ const back = useSettingsPageBack();
const cover = deviceType === "duo-folded";
// Android opens Settings as a workspace tab; its root page has nothing to go back to.
const workspaceRoot =
@@ -47,7 +48,7 @@ export function SettingsScreen(
// iOS screens put their filter menus in native header items themselves.
menus={Platform.OS === "android" ? props.menus : undefined}
sheet={Platform.OS === "android" && props.formSheet}
- onBack={workspaceRoot ? undefined : () => navigation.goBack()}
+ onBack={workspaceRoot ? undefined : back}
hideBottomBorder={!props.formSheet || Platform.OS === "android"}
options={props.options}
/>
diff --git a/apps/mobile/src/features/settings/useSettingsPageBack.ts b/apps/mobile/src/features/settings/useSettingsPageBack.ts
new file mode 100644
index 00000000000..6ce90918341
--- /dev/null
+++ b/apps/mobile/src/features/settings/useSettingsPageBack.ts
@@ -0,0 +1,25 @@
+import { useNavigation, useRoute } from "@react-navigation/native";
+import { Platform } from "react-native";
+
+import { resetAndroidWorkspace } from "../../lib/android-workspace-navigation";
+import { useHardwareBack } from "../../lib/backHandler";
+import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context";
+
+/**
+ * The page's Back action, or undefined for the first page beside the Settings list on wide
+ * Android: that page roots the detail column, so Back leaves Settings rather than emptying it.
+ */
+export function useSettingsPageBack() {
+ const navigation = useNavigation();
+ const route = useRoute();
+ const { layout } = useAdaptiveWorkspaceLayout();
+ const routes = navigation.getState()?.routes ?? [];
+ const below = routes[routes.findIndex((candidate) => candidate.key === route.key) - 1];
+ const columnRoot =
+ Platform.OS === "android" && layout.usesSplitView && below?.name === "Settings";
+ useHardwareBack(columnRoot, () => {
+ resetAndroidWorkspace(navigation);
+ return true;
+ });
+ return columnRoot ? undefined : () => navigation.goBack();
+}
diff --git a/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx b/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx
index 016b75cfb30..82ede662bba 100644
--- a/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx
+++ b/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx
@@ -13,7 +13,7 @@ import { AppBar } from "../../components/ui/AppBar";
import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
import { useAtomMount } from "@effect/atom-react";
-import { useMemo, useRef, useState, useSyncExternalStore } from "react";
+import { useMemo, useRef, useState } from "react";
import { Platform, Pressable, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppText as Text } from "../../components/ui/AppText";
@@ -24,7 +24,6 @@ import * as Schema from "effect/Schema";
import { AsyncResult } from "effect/reactivity";
import {
KeyboardController,
- KeyboardEvents,
KeyboardStickyView,
useKeyboardState,
} from "react-native-keyboard-controller";
@@ -35,6 +34,7 @@ import {
ComposerToolbarScroller,
} from "../../components/ComposerToolbar";
import { EmptyState } from "../../components/ui/EmptyState";
+import { useSoftKeyboardShowing } from "../keyboard/useSoftKeyboardShowing";
import { GlassSurface } from "../../components/ui/GlassSurface";
import { LoadingScreen } from "../../components/LoadingScreen";
import { ScreenContent } from "../../components/ui/ScreenContent";
@@ -352,26 +352,6 @@ function readLiveTerminalSessions(
}));
}
-// `useKeyboardState` only flips on willShow and didHide; the accessory must
-// leave as soon as the keyboard starts hiding, so it follows the will-events.
-let keyboardShowing = KeyboardController.isVisible();
-function subscribeKeyboardShowing(onChange: () => void) {
- keyboardShowing = KeyboardController.isVisible();
- const willShow = KeyboardEvents.addListener("keyboardWillShow", () => {
- keyboardShowing = true;
- onChange();
- });
- const willHide = KeyboardEvents.addListener("keyboardWillHide", () => {
- keyboardShowing = false;
- onChange();
- });
- return () => {
- willShow.remove();
- willHide.remove();
- };
-}
-const getKeyboardShowing = () => keyboardShowing;
-
function ThreadTerminal(props: {
readonly params: ThreadTerminalRouteScreenProps["route"]["params"];
readonly routeEnvironmentId: EnvironmentId | null;
@@ -589,7 +569,8 @@ function ThreadTerminal(props: {
height: state.height,
isVisible: state.isVisible,
}));
- const keyboardShowing = useSyncExternalStore(subscribeKeyboardShowing, getKeyboardShowing);
+ // The accessory leaves as soon as the keyboard starts hiding.
+ const keyboardShowing = useSoftKeyboardShowing();
// The accessory follows the keyboard, except that the dismiss and show
// buttons flip it ahead of the keyboard animation.
const [accessory, setAccessory] = useState({ keyboardShowing, dismissed: false });
diff --git a/apps/mobile/src/features/threads/ThreadFeed.tsx b/apps/mobile/src/features/threads/ThreadFeed.tsx
index b5e0ab3cb42..1abfb6061a6 100644
--- a/apps/mobile/src/features/threads/ThreadFeed.tsx
+++ b/apps/mobile/src/features/threads/ThreadFeed.tsx
@@ -3807,7 +3807,12 @@ export const ThreadFeed = memo(function ThreadFeed({
return (
<PresentationSource identifier={fileShareSourceIdentifier} style={{ flex: 1 }}>
- <View className="flex-1" onLayout={handleViewportLayout}>
+ {/* While the pane tracks a sliding sidebar, rows keep its settled width and re-wrap once. */}
+ <View
+ className="flex-1"
+ style={settledPaneWidth !== null ? { width: settledPaneWidth } : undefined}
+ onLayout={handleViewportLayout}
+ >
<View className="flex-1">
{/* oxlint-disable-next-line t3code/require-registered-list-scroll -- ThreadFeedScrollView is passed through the iOS-only spread below; the prop rejects undefined. */}
<KeyboardAwareLegendList
diff --git a/apps/mobile/src/features/workspace/AndroidWorkspaceNavigation.android.tsx b/apps/mobile/src/features/workspace/AndroidWorkspaceNavigation.android.tsx
index 53cfcc5a33e..51720288def 100644
--- a/apps/mobile/src/features/workspace/AndroidWorkspaceNavigation.android.tsx
+++ b/apps/mobile/src/features/workspace/AndroidWorkspaceNavigation.android.tsx
@@ -10,7 +10,6 @@ import {
type ViewProps,
} from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
-import { useKeyboardState } from "react-native-keyboard-controller";
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
@@ -22,6 +21,8 @@ import {
type AndroidWorkspaceNavigationTab,
} from "./android-workspace-tabs";
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
+import { useSoftKeyboardShowing } from "../keyboard/useSoftKeyboardShowing";
+import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context";
import { useAndroidWorkspaceRoot } from "./AndroidWorkspaceTabsProvider";
import { useNavigationTabOrder, useHiddenNavigationTabs } from "./navigation-tabs";
import { useWorkspaceTabs } from "./WorkspaceTabsContext";
@@ -79,7 +80,8 @@ export function AndroidWorkspaceNavigation(props: {
const insets = useSafeAreaInsets();
const toolbar = useToolbarLayout();
const connectionState = useWorkspaceConnectionState();
- const keyboardVisible = useKeyboardState((state) => state.isVisible);
+ const keyboardVisible = useSoftKeyboardShowing();
+ const { layout } = useAdaptiveWorkspaceLayout();
const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
const { scale, fabSize } = useAndroidControlSizing();
const window = useWindowDimensions();
@@ -141,7 +143,9 @@ export function AndroidWorkspaceNavigation(props: {
const rootState = rootNavigationRef.getRootState();
if (root && rootState) {
navigation.dispatch({
- ...CommonActions.reset(androidWorkspaceTabNavigationState(rootState, tab, rail)),
+ ...CommonActions.reset(
+ androidWorkspaceTabNavigationState(rootState, tab, layout.usesSplitView),
+ ),
target: root.key,
});
}
diff --git a/apps/mobile/src/lib/android-workspace-navigation.ts b/apps/mobile/src/lib/android-workspace-navigation.ts
index 3c2a995e41a..eed0adbd8e5 100644
--- a/apps/mobile/src/lib/android-workspace-navigation.ts
+++ b/apps/mobile/src/lib/android-workspace-navigation.ts
@@ -1,4 +1,5 @@
import type { NavigationState } from "@react-navigation/native";
+import { isSettingsRoute } from "../features/settings/settings-navigation";
import { resetRootStack, type RootStackNavigation } from "./root-stack-reset";
function androidWorkspaceBackReturnsToThread(state: NavigationState) {
@@ -67,10 +68,17 @@ export function returnToAndroidWorkspaceList(
resetAndroidWorkspace(navigation);
}
-// In the split view these destinations swap the detail pane beside the sidebar instead of
-// stacking over Home, so the default slide-in would show a layer that is not there.
-export function androidWorkspaceDestinationAnimation(routeName: string, usesSplitView: boolean) {
- return usesSplitView && (routeName === "Thread" || routeName === "PullRequest")
- ? ("none" as const)
- : undefined;
+// Split view: Thread, PullRequest, and a Settings page picked from the list swap the detail pane
+// rather than stack, so they don't animate. Pages opened from a Settings page crossfade inside the
+// pane's card; the default push edge-extends the incoming page, bleeding a stripe beside the list.
+export function androidWorkspaceDestinationAnimation(
+ route: { readonly key: string; readonly name: string },
+ routes: readonly { readonly key: string; readonly name: string }[],
+ usesSplitView: boolean,
+) {
+ if (!usesSplitView) return undefined;
+ if (route.name === "Thread" || route.name === "PullRequest") return "none" as const;
+ if (route.name === "Settings" || !isSettingsRoute(route.name)) return undefined;
+ const below = routes[routes.findIndex((candidate) => candidate.key === route.key) - 1];
+ return below?.name === "Settings" ? ("none" as const) : ("fade" as const);
}