Open History to see the last commit
1import * as Linking from "expo-linking";
2import * as SplashScreen from "expo-splash-screen";
3import { useEffect } from "react";
4import { StatusBar, View } from "react-native";
5import { GestureHandlerRootView } from "react-native-gesture-handler";
6import { KeyboardProvider } from "react-native-keyboard-controller";
7import { SafeAreaProvider } from "react-native-safe-area-context";
8import { createStaticNavigation } from "@react-navigation/native";
9β
10import { RegistryContext } from "@effect/atom-react";
11import { ThreadArrangementHost } from "./features/threads/ThreadArrangementSheet";
12import { ConfirmDialogHost } from "./components/ConfirmDialogHost";
13import { CloudAuthProvider } from "./features/cloud/CloudAuthProvider";
14import { prepareNativeShowcaseCapture } from "./features/showcase/nativeShowcaseScene";
15import { IncomingShareProvider } from "./features/sharing/IncomingShareProvider";
16import {
17 AppearancePreferencesProvider,
18 useAppearancePreferences,
19} from "./features/settings/appearance/AppearancePreferencesProvider";
20import { RootStack } from "./Stack";
21import { appAtomRegistry } from "./state/atom-registry";
22import { OverlayPortalHost } from "./components/OverlayPortal";
23import { shouldHandleAppLink } from "./lib/appLinking";
24import { useMobileNavigationTheme } from "./lib/useMobileNavigationTheme";
25import { SubscriptionUsageCoordinator } from "./widgets/SubscriptionUsageCoordinator";
26β
27import "../global.css";
28β
29if (process.env.EXPO_PUBLIC_SHOWCASE === "1") {
30 prepareNativeShowcaseCapture();
31}
32β
33void SplashScreen.preventAutoHideAsync().catch(() => {
34 // The native module can be unavailable in non-native test environments.
35});
36β
37const appLinking = {
38 prefixes: [Linking.createURL("/"), "t3code://", "t3code-dev://", "t3code-preview://"],
39 // Keep the compact thread list available beneath a directly opened thread.
40 config: { initialRouteName: "Home" },
41 filter: shouldHandleAppLink,
42};
43β
44const Navigation = createStaticNavigation(RootStack);
45β
46function SplashScreenCoordinator() {
47 const { isReady } = useAppearancePreferences();
48β
49 useEffect(() => {
50 if (isReady) void SplashScreen.hide();
51 }, [isReady]);
52β
53 return null;
54}
55β
56export default function App() {
57 return (
58 <RegistryContext.Provider value={appAtomRegistry}>
59 <CloudAuthProvider>
60 <AppearancePreferencesProvider>
61 <AppContent />
62 </AppearancePreferencesProvider>
63 </CloudAuthProvider>
64 </RegistryContext.Provider>
65 );
66}
67β
68function AppContent() {
69 const { themeAppearance } = useAppearancePreferences();
70 const navigationTheme = useMobileNavigationTheme();
71β
72 return (
73 <>
74 <SplashScreenCoordinator />
75 <SubscriptionUsageCoordinator />
76 <GestureHandlerRootView className="flex-1">
77 <KeyboardProvider statusBarTranslucent>
78 <SafeAreaProvider>
79 <StatusBar
80 barStyle={themeAppearance === "dark" ? "light-content" : "dark-content"}
81 translucent
82 />
83 {/* The navigation theme drives the NATIVE header appearance: native-stack
84 forwards `dark` as the nav bar's overrideUserInterfaceStyle. Without
85 this, React Navigation defaults to its light theme and every native
86 header (glass buttons, title, materials) is forced light even when
87 the system is in dark mode. */}
88 <View style={{ flex: 1 }}>
89 <IncomingShareProvider>
90 <Navigation linking={appLinking} theme={navigationTheme} />
91 </IncomingShareProvider>
92 <ConfirmDialogHost />
93 <ThreadArrangementHost />
94 </View>
95 {/* Anchored-menu overlays render here β in-window, so the
96 keyboard stays up while a dropdown is open. */}
97 <OverlayPortalHost />
98 </SafeAreaProvider>
99 </KeyboardProvider>
100 </GestureHandlerRootView>
101 </>
102 );
103}