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 barStyle={themeAppearance === "dark" ? "light-content" : "dark-content"} />
80 {/* The navigation theme drives the NATIVE header appearance: native-stack
81 forwards `dark` as the nav bar's overrideUserInterfaceStyle. Without
82 this, React Navigation defaults to its light theme and every native
83 header (glass buttons, title, materials) is forced light even when
84 the system is in dark mode. */}
85 <View style={{ flex: 1 }}>
86 <IncomingShareProvider>
87 <Navigation linking={appLinking} theme={navigationTheme} />
88 </IncomingShareProvider>
89 <ConfirmDialogHost />
90 <ThreadArrangementHost />
91 </View>
92 {/* Anchored-menu overlays render here — in-window, so the
93 keyboard stays up while a dropdown is open. */}
94 <OverlayPortalHost />
95 </SafeAreaProvider>
96 </KeyboardProvider>
97 </GestureHandlerRootView>
98 </>
99 );
100}