Open History to see the last commit
1import {
2 DarkTheme,
3 DefaultTheme,
4 NavigationContainer,
5 NavigationIndependentTree,
6} from "@react-navigation/native";
7import {
8 createNativeStackNavigator,
9 type NativeStackNavigationOptions,
10} from "@react-navigation/native-stack";
11import type { ReactNode } from "react";
12import { Platform, useColorScheme } from "react-native";
13
14import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
15import { nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";
16
17const SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
18
19type SidebarScreenOptions = NativeStackNavigationOptions & {
20 // Same patched RNS option the GLASS/SOLID presets in Stack.tsx use — the
21 // iOS 26 "editor" navigation-item style leading-aligns the inline title.
22 readonly unstable_navigationItemStyle?: "editor";
23};
24
25/**
26 * Static chrome for the sidebar column: a real UINavigationBar with a fixed
27 * inline title (no large title — saves vertical space, left-aligned via the
28 * editor item style) and the search bar pinned below it, scroll-edge blur
29 * sampling the list. Only genuinely dynamic values (search callbacks, header
30 * items) are set by the screen content via NativeStackScreenOptions.
31 */
32const SIDEBAR_SCREEN_OPTIONS: SidebarScreenOptions = {
33 contentStyle: { backgroundColor: "transparent" },
34 headerLargeTitle: false,
35 headerShadowVisible: false,
36 headerShown: true,
37 headerStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? { backgroundColor: "transparent" } : undefined,
38 headerTitleStyle: { fontSize: 18, fontWeight: "800" },
39 headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,
40 scrollEdgeEffects: NATIVE_LIQUID_GLASS_SUPPORTED ? SCROLL_EDGE_EFFECTS : undefined,
41 title: "Threads",
42 unstable_navigationItemStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? "editor" : undefined,
43};
44
45const SidebarStack = createNativeStackNavigator();
46
47/**
48 * Hosts the iPad sidebar pane inside its own single-screen native stack.
49 *
50 * The stack is navigation-inert — nothing is ever pushed onto it. It exists so
51 * the sidebar column owns a real UINavigationBar (large title, native bar
52 * button items, UISearchController), mirroring how each column of a
53 * UISplitViewController has its own UINavigationController. All real
54 * navigation still flows through the root stack via callbacks minted in
55 * AdaptiveWorkspaceLayout; NavigationIndependentTree only isolates the
56 * navigation hooks used for header configuration inside the pane.
57 */
58export function SidebarNavigationShell(props: { readonly children: ReactNode }) {
59 const colorScheme = useColorScheme();
60
61 return (
62 <NavigationIndependentTree>
63 <NavigationContainer theme={colorScheme === "dark" ? DarkTheme : DefaultTheme}>
64 <SidebarStack.Navigator
65 screenOptions={SIDEBAR_SCREEN_OPTIONS}
66 initialRouteName="SidebarThreads"
67 >
68 <SidebarStack.Screen name="SidebarThreads">{() => props.children}</SidebarStack.Screen>
69 </SidebarStack.Navigator>
70 </NavigationContainer>
71 </NavigationIndependentTree>
72 );
73}