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