Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

Stack.tsx

668 lines24.5 KB

1import {
2 createPathConfigForStaticNavigation,
3 getPathFromState,
4 NavigationState,
5 StackActions,
6 useNavigation,
7} from "@react-navigation/native";
8import {
9 createNativeStackNavigator,
10 createNativeStackScreen,
11 type NativeStackNavigationOptions,
12} from "@react-navigation/native-stack";
13import { useEffect, useRef } from "react";
14import { Platform, Pressable, ScrollView, StyleSheet } from "react-native";
15import { useResolveClassNames } from "uniwind";
16​
17import { AppText as Text } from "./components/AppText";
18import { getCompactBrandHeaderOptions } from "./components/CompactBrandTitle";
19import { ArchivedThreadsRouteScreen } from "./features/archive/ArchivedThreadsRouteScreen";
20import { useAgentNotificationNavigation } from "./features/agent-awareness/notificationNavigation";
21import { ConnectOnboardingRouteScreen } from "./features/cloud/ConnectOnboardingRouteScreen";
22import { useConnectOnboardingNavigation } from "./features/cloud/connectOnboardingNavigation";
23import { ThreadFilesTreeScreen, ThreadFileScreen } from "./features/files/ThreadFilesRouteScreen";
24import { AdaptiveWorkspaceLayout } from "./features/layout/AdaptiveWorkspaceLayout";
25import { HardwareKeyboardCommandProvider } from "./features/keyboard/HardwareKeyboardCommandProvider";
26import { ReviewCommentComposerSheet } from "./features/review/ReviewCommentComposerSheet";
27import { ReviewSheet } from "./features/review/ReviewSheet";
28import { ThreadTerminalRouteScreen } from "./features/terminal/ThreadTerminalRouteScreen";
29import { GitBranchesSheet } from "./features/threads/git/GitBranchesSheet";
30import { GitCommitSheet } from "./features/threads/git/GitCommitSheet";
31import { GitConfirmSheet } from "./features/threads/git/GitConfirmSheet";
32import { GitOverviewSheet } from "./features/threads/git/GitOverviewSheet";
33import { ThreadRouteScreen } from "./features/threads/ThreadRouteScreen";
34import { ConnectionsRouteScreen } from "./features/connection/ConnectionsRouteScreen";
35import { ConnectionsNewRouteScreen } from "./features/connection/ConnectionsNewRouteScreen";
36import { HomeRouteScreen } from "./features/home/HomeRouteScreen";
37import { AddProjectDestinationRoute } from "./features/projects/AddProjectDestinationRoute";
38import { AddProjectLocalRoute } from "./features/projects/AddProjectLocalRoute";
39import { AddProjectRepositoryRoute } from "./features/projects/AddProjectRepositoryRoute";
40import { AddProjectSourceRoute } from "./features/projects/AddProjectSourceRoute";
41import { NewTaskDraftRouteScreen } from "./features/threads/NewTaskDraftRouteScreen";
42import {
43 NewTaskBranchPickerRouteScreen,
44 NewTaskEnvironmentPickerRouteScreen,
45} from "./features/threads/NewTaskContextPickerScreens";
46import {
47 ExistingThreadSettingsRouteProvider,
48 ExistingThreadSettingsRouteScreen,
49 NewTaskThreadSettingsRouteScreen,
50} from "./features/threads/ThreadSettingsSheet";
51import { NewTaskFlowProvider } from "./features/threads/new-task-flow-provider";
52import { NewTaskRouteScreen } from "./features/threads/NewTaskRouteScreen";
53import { SettingsAppearanceRouteScreen } from "./features/settings/SettingsAppearanceRouteScreen";
54import { SettingsClientStorageRouteScreen } from "./features/settings/SettingsClientStorageRouteScreen";
55import { SettingsAuthRouteScreen } from "./features/settings/SettingsAuthRouteScreen";
56import { SettingsEnvironmentsRouteScreen } from "./features/settings/SettingsEnvironmentsRouteScreen";
57import { SettingsLegalRouteScreen } from "./features/settings/SettingsLegalRouteScreen";
58import { SettingsProjectGroupingRouteScreen } from "./features/settings/SettingsProjectGroupingRouteScreen";
59import { UsageRouteScreen } from "./features/usage/UsageRouteScreen";
60import { SettingsRouteScreen } from "./features/settings/SettingsRouteScreen";
61import { ShowcaseCaptureCoordinator } from "./features/showcase/ShowcaseCaptureCoordinator";
62import {
63 SettingsLegalDocumentCloseHeaderButton,
64 SettingsLegalDocumentExternalHeaderButton,
65} from "./features/settings/components/SettingsLegalDocumentRouteScreen";
66import { useAppShortcuts } from "./features/shortcuts/useAppShortcuts";
67import { useIncomingShare } from "./features/sharing/IncomingShareProvider";
68import {
69 EMPTY_INCOMING_SHARE_PRESENTATION_STATE,
70 transitionIncomingSharePresentation,
71} from "./features/sharing/incoming-share-presentation";
72import { NATIVE_LIQUID_GLASS_SUPPORTED } from "./native/native-glass";
73import { nativeHeaderScrollEdgeEffects } from "./native/StackHeader";
74import {
75 FORM_SHEET_PRESENTATION_OPTIONS,
76 NATIVE_SHEET_SURFACE_COLOR,
77 NATIVE_SHEET_SURFACE_CONTENT_STYLE,
78} from "./native/sheet-surface";
79import { useThreadOutboxDrain } from "./state/use-thread-outbox-drain";
80​
81const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
82​
83type AppScreenOptions = NativeStackNavigationOptions & {
84 readonly unstable_navigationItemStyle?: "editor";
85};
86​
87// Shared header presets. Screens only override genuinely dynamic values (titles,
88// subtitles, toolbar items, search callbacks) via NativeStackScreenOptions.
89//
90// GLASS: transparent header over the screen's primary scroll view on supported
91// iOS versions. Pre-glass iOS gets the same solid material as internal-scroll
92// surfaces so content is laid out below the bar instead of underlapping it.
93const GLASS_HEADER_OPTIONS: AppScreenOptions = {
94 headerBackButtonDisplayMode: "minimal",
95 headerBackTitle: "",
96 headerLargeTitle: false,
97 headerShadowVisible: false,
98 headerShown: true,
99 headerStyle: NATIVE_LIQUID_GLASS_SUPPORTED
100 ? { backgroundColor: "transparent" }
101 : NATIVE_SHEET_SURFACE_COLOR !== undefined
102 ? { backgroundColor: NATIVE_SHEET_SURFACE_COLOR as unknown as string }
103 : undefined,
104 headerTitleStyle: { fontSize: 18, fontWeight: "800" },
105 headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,
106 scrollEdgeEffects: NATIVE_LIQUID_GLASS_SUPPORTED ? HEADER_SCROLL_EDGE_EFFECTS : undefined,
107 unstable_navigationItemStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? "editor" : undefined,
108};
109​
110// SOLID: opaque sheet-colored header for surfaces whose content scrolls internally
111// (file viewer, terminal, review) — there is nothing for glass to sample there.
112const SOLID_HEADER_OPTIONS: AppScreenOptions = {
113 headerBackButtonDisplayMode: "minimal",
114 headerBackTitle: "",
115 headerLargeTitle: false,
116 headerShadowVisible: false,
117 headerShown: true,
118 headerStyle:
119 NATIVE_SHEET_SURFACE_COLOR !== undefined
120 ? // native-stack types this as `string`, but the native side accepts any
121 // ColorValue including DynamicColorIOS.
122 { backgroundColor: NATIVE_SHEET_SURFACE_COLOR as unknown as string }
123 : undefined,
124 headerTitleStyle: { fontSize: 18, fontWeight: "800" },
125 headerTransparent: false,
126 unstable_navigationItemStyle: Platform.OS === "ios" ? "editor" : undefined,
127};
128​
129// Solid header variant for screens inside sheets (centered title, no editor style).
130const SHEET_SOLID_HEADER_OPTIONS: AppScreenOptions = {
131 ...SOLID_HEADER_OPTIONS,
132 unstable_navigationItemStyle: undefined,
133};
134​
135// A native glass header for a sheet screen whose primary child is a scroll
136// view. The centered sheet title stays stable while UIKit supplies scroll-edge
137// fading from that child.
138const SHEET_GLASS_HEADER_OPTIONS: AppScreenOptions = {
139 ...GLASS_HEADER_OPTIONS,
140 unstable_navigationItemStyle: undefined,
141};
142​
143const LEGAL_DOCUMENT_HEADER_OPTIONS: AppScreenOptions = {
144 ...SHEET_SOLID_HEADER_OPTIONS,
145 headerBackVisible: false,
146 headerLeft: SettingsLegalDocumentCloseHeaderButton,
147 headerRight: () => <SettingsLegalDocumentExternalHeaderButton />,
148 presentation: "fullScreenModal",
149};
150​
151const SettingsContentStack = createNativeStackNavigator({
152 initialRouteName: "Settings",
153 screenOptions: {
154 ...GLASS_HEADER_OPTIONS,
155 // Sheets read better with the iOS-default centered title (no editor style).
156 unstable_navigationItemStyle: undefined,
157 },
158 screens: {
159 Settings: createNativeStackScreen({
160 screen: SettingsRouteScreen,
161 linking: "",
162 options: {
163 title: "Settings",
164 },
165 }),
166 SettingsEnvironments: createNativeStackScreen({
167 screen: SettingsEnvironmentsRouteScreen,
168 linking: "environments",
169 options: {
170 title: "Environments",
171 },
172 }),
173 SettingsEnvironmentNew: createNativeStackScreen({
174 screen: ConnectionsNewRouteScreen,
175 linking: "environment-new",
176 options: {
177 title: "Add Environment",
178 },
179 }),
180 SettingsArchive: createNativeStackScreen({
181 screen: ArchivedThreadsRouteScreen,
182 linking: "archive",
183 options: {
184 title: "Archived Threads",
185 },
186 }),
187 SettingsAppearance: createNativeStackScreen({
188 screen: SettingsAppearanceRouteScreen,
189 linking: "appearance",
190 options: {
191 title: "Appearance",
192 },
193 }),
194 SettingsProjectGrouping: createNativeStackScreen({
195 screen: SettingsProjectGroupingRouteScreen,
196 linking: "project-grouping",
197 options: {
198 title: "Project Grouping",
199 },
200 }),
201 SettingsClientStorage: createNativeStackScreen({
202 screen: SettingsClientStorageRouteScreen,
203 linking: "client-storage",
204 options: {
205 title: "Client Storage",
206 },
207 }),
208 SettingsUsage: createNativeStackScreen({
209 screen: UsageRouteScreen,
210 linking: "usage",
211 options: {
212 title: "Usage",
213 },
214 }),
215 },
216});
217​
218// The outer stack never owns visible chrome. Settings routes render inside a
219// nested stack whose native header remains mounted, while Clerk owns auth chrome.
220// Keeping bar visibility invariant avoids iOS 26's headerless-to-headered jump.
221const SettingsSheetStack = createNativeStackNavigator({
222 initialRouteName: "SettingsContent",
223 screenOptions: {
224 headerShown: false,
225 },
226 screens: {
227 SettingsContent: createNativeStackScreen({
228 screen: SettingsContentStack,
229 linking: "",
230 }),
231 SettingsAuth: createNativeStackScreen({
232 screen: SettingsAuthRouteScreen,
233 linking: "auth",
234 }),
235 SettingsWaitlist: createNativeStackScreen({
236 // Keep the old deep link working after the Connect GA launch.
237 screen: SettingsAuthRouteScreen,
238 linking: "waitlist",
239 }),
240 },
241});
242​
243// Thread routes live FLAT in the root stack (not in a nested navigator). A nested
244// stack means a second UINavigationController with its own UINavigationBar, which
245// breaks iOS 26's shared-header morphing between Home and Thread (each pair inside
246// one bar morphs; across two bars the whole screen slides). Flat linking paths keep
247// the same deep-link URLs the nested config produced.
248const THREAD_LINKING_PREFIX = "threads/:environmentId/:threadId";
249​
250// New-task / add-project flow: nested navigator inside the formSheet (Settings-sheet
251// pattern — a plain formSheet screen cannot render a stack header; the header and
252// in-sheet pushes come from this nested stack).
253const NewTaskSheetStack = createNativeStackNavigator({
254 initialRouteName: "NewTask",
255 screenOptions: {
256 ...SHEET_GLASS_HEADER_OPTIONS,
257 // The form-sheet host owns the one opaque adaptive surface. Child screens
258 // and the navigation bar stay transparent over it, avoiding visible color
259 // slabs as view controllers move horizontally.
260 contentStyle: Platform.OS === "ios" ? { backgroundColor: "transparent" } : undefined,
261 // UIKit's default push adds a dimming shadow and independently transitions
262 // the navigation bar. Both read as mismatched sheet backgrounds here.
263 // simple_push retains native push/pop gestures without either artifact.
264 animation: Platform.OS === "ios" ? "simple_push" : undefined,
265 animationDuration: Platform.OS === "ios" ? 350 : undefined,
266 },
267 screens: {
268 NewTask: createNativeStackScreen({
269 screen: NewTaskRouteScreen,
270 linking: "",
271 options: {
272 title: "Choose project",
273 },
274 }),
275 NewTaskDraft: createNativeStackScreen({
276 screen: NewTaskDraftRouteScreen,
277 linking: "draft",
278 options: {
279 headerBackVisible: false,
280 title: "",
281 },
282 }),
283 NewTaskEnvironment: createNativeStackScreen({
284 screen: NewTaskEnvironmentPickerRouteScreen,
285 linking: "draft/environment",
286 options: {
287 title: "Environment",
288 },
289 }),
290 NewTaskBranch: createNativeStackScreen({
291 screen: NewTaskBranchPickerRouteScreen,
292 linking: "draft/branch",
293 options: {
294 title: "Branch",
295 },
296 }),
297 ThreadSettings: createNativeStackScreen({
298 screen: NewTaskThreadSettingsRouteScreen,
299 linking: "draft/settings",
300 options: {
301 gestureEnabled: true,
302 headerShown: false,
303 ...(Platform.OS === "android"
304 ? { presentation: "card" as const }
305 : {
306 ...FORM_SHEET_PRESENTATION_OPTIONS,
307 sheetAllowedDetents: [1],
308 sheetGrabberVisible: true,
309 }),
310 },
311 }),
312 AddProject: createNativeStackScreen({
313 screen: AddProjectSourceRoute,
314 linking: "add-project",
315 options: {
316 title: "Add Project",
317 },
318 }),
319 AddProjectRepository: createNativeStackScreen({
320 screen: AddProjectRepositoryRoute,
321 linking: "add-project/repository",
322 }),
323 AddProjectDestination: createNativeStackScreen({
324 screen: AddProjectDestinationRoute,
325 linking: "add-project/destination",
326 }),
327 AddProjectLocal: createNativeStackScreen({
328 screen: AddProjectLocalRoute,
329 linking: "add-project/local",
330 }),
331 },
332});
333​
334// Routes presented as sheets/overlays ON TOP of the workspace. They must not
335// influence the adaptive workspace layout: opening Settings over Home should
336// not flip the sidebar in or change the active thread.
337const WORKSPACE_OVERLAY_ROUTES = new Set([
338 "ConnectOnboarding",
339 "Connections",
340 "ConnectionsNew",
341 "GitBranches",
342 "GitCommit",
343 "GitConfirm",
344 "GitOverview",
345 "NewTaskSheet",
346 "SettingsLegal",
347 "SettingsSheet",
348 "ThreadReviewComment",
349 "ThreadSettingsSheet",
350]);
351​
352/**
353 * Pathname of the topmost NON-overlay route — the screen the workspace is
354 * actually "on", regardless of any sheets floating above it.
355 */
356function workspacePathFromState(state: NavigationState): string {
357 const routes = state.routes.filter((route) => !WORKSPACE_OVERLAY_ROUTES.has(route.name));
358 const effectiveState =
359 routes.length > 0 && routes.length !== state.routes.length
360 ? ({ ...state, routes, index: routes.length - 1 } as NavigationState)
361 : state;
362 const path = getPathFromState(effectiveState, navigationPathConfig);
363 return path.startsWith("/") ? path : `/${path}`;
365​
366// The drain hook subscribes to the outbox, all thread shells, projects, and
367// connection statuses. Hosting it in a null-rendering leaf keeps those
368// updates from re-rendering RootStackLayout (and with it every screen) on
369// each enqueue, shell change, or reconnect.
370function ThreadOutboxDrainWorker() {
371 useThreadOutboxDrain();
372 return null;
374​
375function RootStackLayout(props: {
376 readonly children: React.ReactNode;
377 readonly state: NavigationState;
378}) {
379 const navigation = useNavigation();
380 const { pendingShare } = useIncomingShare();
381 const sharePresentationRef = useRef(EMPTY_INCOMING_SHARE_PRESENTATION_STATE);
382 useAgentNotificationNavigation();
383 // Presents the T3 Connect onboarding sheet after an in-session sign-in.
384 useConnectOnboardingNavigation();
385 // Launcher app shortcuts: routes shortcut taps and tracks opened threads.
386 useAppShortcuts(props.state);
387 useEffect(() => {
388 const topRouteName = props.state.routes[props.state.index]?.name;
389 const transition = transitionIncomingSharePresentation(sharePresentationRef.current, {
390 isShareSheetPresented: topRouteName === "NewTaskSheet",
391 pendingShareId: pendingShare?.id ?? null,
392 });
393 sharePresentationRef.current = transition.state;
394 if (!transition.shareIdToPresent) {
395 return;
396 }
397 navigation.navigate("NewTaskSheet", {
398 screen: "NewTask",
399 params: { incomingShareId: transition.shareIdToPresent },
400 });
401 }, [navigation, pendingShare, props.state]);
402 // Full pathname (sheets included) for keyboard-command scoping; the
403 // workspace layout only reacts to the underlying non-overlay route.
404 const path = getPathFromState(props.state, navigationPathConfig);
405 const pathname = path.startsWith("/") ? path : `/${path}`;
406 const workspacePathname = workspacePathFromState(props.state);
407​
408 return (
409 <HardwareKeyboardCommandProvider pathname={pathname}>
410 <ThreadOutboxDrainWorker />
411 <ShowcaseCaptureCoordinator pathname={pathname} />
412 <ExistingThreadSettingsRouteProvider>
413 <AdaptiveWorkspaceLayout pathname={workspacePathname}>
414 {props.children}
415 </AdaptiveWorkspaceLayout>
416 </ExistingThreadSettingsRouteProvider>
417 </HardwareKeyboardCommandProvider>
418 );
420​
421function NotFoundScreen() {
422 const navigation = useNavigation();
423 const screenBgStyle = StyleSheet.flatten(useResolveClassNames("bg-screen"));
424 const primaryBgStyle = StyleSheet.flatten(useResolveClassNames("bg-primary"));
425 const returnHomeButtonStyle = StyleSheet.flatten([
426 {
427 borderRadius: 999,
428 paddingHorizontal: 20,
429 paddingVertical: 14,
430 },
431 primaryBgStyle,
432 ]);
433​
434 return (
435 <ScrollView
436 contentInsetAdjustmentBehavior="automatic"
437 contentContainerStyle={{
438 flexGrow: 1,
439 alignItems: "center",
440 justifyContent: "center",
441 gap: 16,
442 paddingHorizontal: 24,
443 paddingVertical: 32,
444 }}
445 style={[{ flex: 1 }, screenBgStyle]}
446 >
447 <Text className="text-3xl font-t3-bold text-foreground" selectable>
448 Route not found
449 </Text>
450 <Pressable
451 style={returnHomeButtonStyle}
452 onPress={() => navigation.dispatch(StackActions.replace("Home"))}
453 >
454 <Text className="text-base font-t3-bold text-primary-foreground">Return home</Text>
455 </Pressable>
456 </ScrollView>
457 );
459​
460export const RootStack = createNativeStackNavigator({
461 initialRouteName: "Home",
462 layout: RootStackLayout,
463 screenOptions: {
464 headerShown: false,
465 },
466 screens: {
467 Home: createNativeStackScreen({
468 screen: HomeRouteScreen,
469 linking: "",
470 options: {
471 ...GLASS_HEADER_OPTIONS,
472 contentStyle: { backgroundColor: "transparent" },
473 headerBackVisible: false,
474 ...getCompactBrandHeaderOptions(),
475 },
476 }),
477 Thread: createNativeStackScreen({
478 screen: ThreadRouteScreen,
479 linking: THREAD_LINKING_PREFIX,
480 options: GLASS_HEADER_OPTIONS,
481 }),
482 ThreadTerminal: createNativeStackScreen({
483 screen: ThreadTerminalRouteScreen,
484 linking: `${THREAD_LINKING_PREFIX}/terminal`,
485 options: SOLID_HEADER_OPTIONS,
486 }),
487 ThreadReview: createNativeStackScreen({
488 screen: ReviewSheet,
489 linking: `${THREAD_LINKING_PREFIX}/review`,
490 options: SOLID_HEADER_OPTIONS,
491 }),
492 ThreadReviewComment: createNativeStackScreen({
493 screen: ReviewCommentComposerSheet,
494 linking: `${THREAD_LINKING_PREFIX}/review-comment`,
495 options: {
496 // Android cannot host the keyboard-driven comment composer inside a
497 // formSheet; use a full-screen modal there instead.
498 ...(Platform.OS === "android"
499 ? { presentation: "fullScreenModal" as const }
500 : FORM_SHEET_PRESENTATION_OPTIONS),
501 sheetAllowedDetents: Platform.OS === "android" ? undefined : [0.55, 0.92],
502 sheetGrabberVisible: Platform.OS !== "android",
503 },
504 }),
505 ThreadFiles: createNativeStackScreen({
506 screen: ThreadFilesTreeScreen,
507 linking: `${THREAD_LINKING_PREFIX}/files`,
508 options: {
509 ...GLASS_HEADER_OPTIONS,
510 contentStyle: NATIVE_SHEET_SURFACE_CONTENT_STYLE,
511 title: "Files",
512 },
513 }),
514 ThreadFile: createNativeStackScreen({
515 screen: ThreadFileScreen,
516 linking: `${THREAD_LINKING_PREFIX}/files/:path*`,
517 options: SOLID_HEADER_OPTIONS,
518 }),
519 ThreadSettingsSheet: createNativeStackScreen({
520 screen: ExistingThreadSettingsRouteScreen,
521 options: {
522 gestureEnabled: true,
523 headerShown: false,
524 ...(Platform.OS === "android"
525 ? { presentation: "card" as const }
526 : {
527 ...FORM_SHEET_PRESENTATION_OPTIONS,
528 sheetAllowedDetents: [1],
529 sheetGrabberVisible: true,
530 }),
531 },
532 }),
533 GitOverview: createNativeStackScreen({
534 screen: GitOverviewSheet,
535 linking: `${THREAD_LINKING_PREFIX}/git`,
536 options: {
537 ...FORM_SHEET_PRESENTATION_OPTIONS,
538 sheetAllowedDetents: [0.55, 0.92],
539 sheetGrabberVisible: true,
540 },
541 }),
542 GitCommit: createNativeStackScreen({
543 screen: GitCommitSheet,
544 linking: `${THREAD_LINKING_PREFIX}/git/commit`,
545 options: {
546 ...FORM_SHEET_PRESENTATION_OPTIONS,
547 sheetAllowedDetents: [0.55, 0.92],
548 sheetGrabberVisible: true,
549 },
550 }),
551 GitBranches: createNativeStackScreen({
552 screen: GitBranchesSheet,
553 linking: `${THREAD_LINKING_PREFIX}/git/branches`,
554 options: {
555 ...FORM_SHEET_PRESENTATION_OPTIONS,
556 sheetAllowedDetents: [0.55, 0.92],
557 sheetGrabberVisible: true,
558 },
559 }),
560 GitConfirm: createNativeStackScreen({
561 screen: GitConfirmSheet,
562 linking: `${THREAD_LINKING_PREFIX}/git-confirm`,
563 options: {
564 ...FORM_SHEET_PRESENTATION_OPTIONS,
565 sheetAllowedDetents: [0.45, 0.7],
566 sheetGrabberVisible: true,
567 },
568 }),
569 SettingsSheet: createNativeStackScreen({
570 screen: SettingsSheetStack,
571 linking: "settings",
572 options: {
573 gestureEnabled: true,
574 headerShown: false,
575 // Android pushes settings as a regular full page with an in-screen
576 // back header; iOS keeps the detented form sheet.
577 ...(Platform.OS === "android"
578 ? { presentation: "card" as const }
579 : {
580 ...FORM_SHEET_PRESENTATION_OPTIONS,
581 sheetAllowedDetents: [0.7, 0.92],
582 sheetGrabberVisible: true,
583 }),
584 },
585 }),
586 SettingsLegal: createNativeStackScreen({
587 screen: SettingsLegalRouteScreen,
588 linking: "settings/legal",
589 options: {
590 ...LEGAL_DOCUMENT_HEADER_OPTIONS,
591 title: "Legal",
592 },
593 }),
594 ConnectOnboarding: createNativeStackScreen({
595 screen: ConnectOnboardingRouteScreen,
596 linking: "connect-onboarding",
597 options: {
598 // A root-level Android formSheet does not host the native stack bar;
599 // the route renders an embedded AndroidSheetHeader instead.
600 ...(Platform.OS === "android" ? { headerShown: false } : SHEET_SOLID_HEADER_OPTIONS),
601 title: "Set up T3 Connect",
602 gestureEnabled: true,
603 ...FORM_SHEET_PRESENTATION_OPTIONS,
604 sheetAllowedDetents: [0.6, 0.95],
605 sheetGrabberVisible: true,
606 },
607 }),
608 Connections: createNativeStackScreen({
609 screen: ConnectionsRouteScreen,
610 linking: "connections",
611 options: {
612 title: "Environments",
613 // Android: full page; the screen renders its own AndroidScreenHeader,
614 // so the native bar stays hidden. iOS keeps the sheet.
615 ...(Platform.OS === "android"
616 ? { presentation: "card" as const, headerShown: false }
617 : {
618 ...FORM_SHEET_PRESENTATION_OPTIONS,
619 sheetAllowedDetents: [0.55, 0.7],
620 sheetGrabberVisible: true,
621 }),
622 },
623 }),
624 ConnectionsNew: createNativeStackScreen({
625 screen: ConnectionsNewRouteScreen,
626 linking: "connections/new",
627 options: {
628 ...FORM_SHEET_PRESENTATION_OPTIONS,
629 sheetAllowedDetents: [0.55, 0.7],
630 sheetGrabberVisible: true,
631 },
632 }),
633 NewTaskSheet: createNativeStackScreen({
634 screen: NewTaskSheetStack,
635 linking: "new",
636 // The whole new-task flow (choose project → draft → add project) shares
637 // draft state via NewTaskFlowProvider. The expo-router era mounted it in
638 // app/new/_layout.tsx; this layout wrapper is the native-stack equivalent.
639 layout: ({ children }) => <NewTaskFlowProvider>{children}</NewTaskFlowProvider>,
640 options: {
641 gestureEnabled: true,
642 headerShown: false,
643 // Android pushes the flow as a regular full page — the draft should
644 // read like a thread that just doesn't exist yet; iOS keeps the sheet.
645 ...(Platform.OS === "android"
646 ? { presentation: "card" as const }
647 : {
648 ...FORM_SHEET_PRESENTATION_OPTIONS,
649 sheetAllowedDetents: [0.92],
650 sheetGrabberVisible: true,
651 }),
652 },
653 }),
654 NotFound: createNativeStackScreen({
655 screen: NotFoundScreen,
656 linking: "*",
657 }),
658 },
659});
660type RootStackType = typeof RootStack;
661​
662const navigationPathConfig = {
663 screens: createPathConfigForStaticNavigation(RootStack) ?? {},
664};
665​
666declare module "@react-navigation/native" {
667 interface RootNavigator extends RootStackType {}