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

_layout.tsx

119 lines3.6 KB

1import "../../global.css";
2import {
3 DMSans_400Regular,
4 DMSans_500Medium,
5 DMSans_700Bold,
6 useFonts,
7} from "@expo-google-fonts/dm-sans";
8import Stack from "expo-router/stack";
9import { StatusBar, useColorScheme } from "react-native";
10import { GestureHandlerRootView } from "react-native-gesture-handler";
11import { KeyboardProvider } from "react-native-keyboard-controller";
12import { SafeAreaProvider } from "react-native-safe-area-context";
13import { useResolveClassNames } from "uniwind";
14​
15import { LoadingScreen } from "../components/LoadingScreen";
16​
17import {
18 useRemoteEnvironmentBootstrap,
19 useRemoteEnvironmentState,
20} from "../state/use-remote-environment-registry";
21import { RegistryContext } from "@effect/atom-react";
22import { appAtomRegistry } from "../state/atom-registry";
23import { CloudAuthProvider } from "../features/cloud/CloudAuthProvider";
24import { useAgentNotificationNavigation } from "../features/agent-awareness/notificationNavigation";
25​
26function AppNavigator() {
27 const { isLoadingSavedConnection } = useRemoteEnvironmentState();
28 const colorScheme = useColorScheme();
29 const statusBarBg = colorScheme === "dark" ? "#0a0a0a" : "#f2f2f7";
30 const sheetStyle = useResolveClassNames("bg-sheet");
31 useAgentNotificationNavigation();
32​
33 const newTaskScreenOptions = {
34 contentStyle: sheetStyle,
35 gestureEnabled: true,
36 headerShown: false,
37 presentation: "formSheet" as const,
38 sheetAllowedDetents: [0.92],
39 sheetGrabberVisible: true,
40 };
41​
42 const connectionSheetScreenOptions = {
43 contentStyle: sheetStyle,
44 gestureEnabled: true,
45 headerShown: false,
46 presentation: "formSheet" as const,
47 sheetAllowedDetents: [0.55, 0.7],
48 sheetGrabberVisible: true,
49 };
50​
51 const settingsSheetScreenOptions = {
52 ...connectionSheetScreenOptions,
53 sheetAllowedDetents: [0.7],
54 };
55​
56 if (isLoadingSavedConnection) {
57 return <LoadingScreen message="Loading remote workspace…" />;
58 }
59​
60 return (
61 <>
62 <StatusBar
63 barStyle={colorScheme === "dark" ? "light-content" : "dark-content"}
64 backgroundColor={statusBarBg as string}
65 translucent
66 />
67 <Stack screenOptions={{ headerShown: false }}>
68 <Stack.Screen
69 name="index"
70 options={{
71 contentStyle: { backgroundColor: "transparent" },
72 headerShown: true,
73 headerTransparent: true,
74 headerShadowVisible: false,
75 }}
76 />
77 <Stack.Screen name="settings" options={settingsSheetScreenOptions} />
78 <Stack.Screen name="connections" options={connectionSheetScreenOptions} />
79 <Stack.Screen name="new" options={newTaskScreenOptions} />
80 <Stack.Screen
81 name="threads/[environmentId]/[threadId]"
82 options={{
83 animation: "slide_from_right",
84 contentStyle: { backgroundColor: "transparent" },
85 gestureEnabled: true,
86 headerShown: false,
87 }}
88 />
89 </Stack>
90 </>
91 );
93​
94export default function RootLayout() {
95 const [fontsLoaded] = useFonts({
96 DMSans_400Regular,
97 DMSans_500Medium,
98 DMSans_700Bold,
99 });
100 useRemoteEnvironmentBootstrap();
101​
102 return (
103 <RegistryContext.Provider value={appAtomRegistry}>
104 <CloudAuthProvider>
105 <GestureHandlerRootView style={{ flex: 1 }}>
106 <KeyboardProvider statusBarTranslucent>
107 <SafeAreaProvider>
108 {fontsLoaded ? (
109 <AppNavigator />
110 ) : (
111 <LoadingScreen message="Loading remote workspace…" />
112 )}
113 </SafeAreaProvider>
114 </KeyboardProvider>
115 </GestureHandlerRootView>
116 </CloudAuthProvider>
117 </RegistryContext.Provider>
118 );