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 { 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 { appBlurTargetRef } from "./lib/appBlurTarget";
24import { useThemeColor } from "./lib/useThemeColor";
25import { useMobileNavigationTheme } from "./lib/useMobileNavigationTheme";
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 // The Expo dev client launches the app via
40 // <scheme>://expo-development-client/?url=<packager> — that URL addresses
41 // the launcher, not app navigation. Without this filter it falls through
42 // to the NotFound wildcard route on every dev launch.
43 // expo-sharing uses a private lifecycle URL only to wake the app. The
44 // persisted share inbox below owns navigation once the payload is durable.
45 filter: (url: string) =>
46 !url.includes("expo-development-client") && !url.includes("://expo-sharing"),
47};
48
49const Navigation = createStaticNavigation(RootStack);
50
51function SplashScreenCoordinator() {
52 const { isReady } = useAppearancePreferences();
53
54 useEffect(() => {
55 if (isReady) void SplashScreen.hide();
56 }, [isReady]);
57
58 return null;
59}
60
61export default function App() {
62 return (
63 <RegistryContext.Provider value={appAtomRegistry}>
64 <CloudAuthProvider>
65 <AppearancePreferencesProvider>
66 <AppContent />
67 </AppearancePreferencesProvider>
68 </CloudAuthProvider>
69 </RegistryContext.Provider>
70 );
71}
72
73function AppContent() {
74 const { themeAppearance } = useAppearancePreferences();
75 const statusBarBg = useThemeColor("--color-status-bar");
76 const navigationTheme = useMobileNavigationTheme(themeAppearance);
77
78 return (
79 <>
80 <SplashScreenCoordinator />
81 <GestureHandlerRootView className="flex-1">
82 <KeyboardProvider statusBarTranslucent>
83 <SafeAreaProvider>
84 <StatusBar
85 barStyle={themeAppearance === "dark" ? "light-content" : "dark-content"}
86 backgroundColor={statusBarBg}
87 translucent
88 />
89 {/* The navigation theme drives the NATIVE header appearance: native-stack
90 forwards `dark` as the nav bar's overrideUserInterfaceStyle. Without
91 this, React Navigation defaults to its light theme and every native
92 header (glass buttons, title, materials) is forced light even when
93 the system is in dark mode. */}
94 {/* Blur target for Android dropdown backdrops — see appBlurTarget.ts. */}
95 <BlurTargetView ref={appBlurTargetRef} style={{ flex: 1 }}>
96 <IncomingShareProvider>
97 <Navigation linking={appLinking} theme={navigationTheme} />
98 </IncomingShareProvider>
99 <ConfirmDialogHost />
100 </BlurTargetView>
101 {/* Anchored-menu overlays render here — in-window, so the
102 keyboard stays up while a dropdown is open. */}
103 <OverlayPortalHost />
104 </SafeAreaProvider>
105 </KeyboardProvider>
106 </GestureHandlerRootView>
107 </>
108 );
109}