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, useColorScheme } 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, DarkTheme, DefaultTheme } 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";
25
26import "../global.css";
27
28if (process.env.EXPO_PUBLIC_SHOWCASE === "1") {
29 prepareNativeShowcaseCapture();
30}
31
32void SplashScreen.preventAutoHideAsync().catch(() => {
33 // The native module can be unavailable in non-native test environments.
34});
35
36const appLinking = {
37 prefixes: [Linking.createURL("/"), "t3code://", "t3code-dev://", "t3code-preview://"],
38 // The Expo dev client launches the app via
39 // <scheme>://expo-development-client/?url=<packager> — that URL addresses
40 // the launcher, not app navigation. Without this filter it falls through
41 // to the NotFound wildcard route on every dev launch.
42 // expo-sharing uses a private lifecycle URL only to wake the app. The
43 // persisted share inbox below owns navigation once the payload is durable.
44 filter: (url: string) =>
45 !url.includes("expo-development-client") && !url.includes("://expo-sharing"),
46};
47
48const Navigation = createStaticNavigation(RootStack);
49
50function SplashScreenCoordinator() {
51 const { isReady } = useAppearancePreferences();
52
53 useEffect(() => {
54 if (isReady) void SplashScreen.hide();
55 }, [isReady]);
56
57 return null;
58}
59
60export default function App() {
61 const colorScheme = useColorScheme();
62 const statusBarBg = useThemeColor("--color-status-bar");
63
64 return (
65 <RegistryContext.Provider value={appAtomRegistry}>
66 <CloudAuthProvider>
67 <AppearancePreferencesProvider>
68 <SplashScreenCoordinator />
69 <GestureHandlerRootView className="flex-1">
70 <KeyboardProvider statusBarTranslucent>
71 <SafeAreaProvider>
72 <StatusBar
73 barStyle={colorScheme === "dark" ? "light-content" : "dark-content"}
74 backgroundColor={statusBarBg}
75 translucent
76 />
77 {/* The navigation theme drives the NATIVE header appearance: native-stack
78 forwards `dark` as the nav bar's overrideUserInterfaceStyle. Without
79 this, React Navigation defaults to its light theme and every native
80 header (glass buttons, title, materials) is forced light even when
81 the system is in dark mode. */}
82 {/* Blur target for Android dropdown backdrops — see appBlurTarget.ts. */}
83 <BlurTargetView ref={appBlurTargetRef} style={{ flex: 1 }}>
84 <IncomingShareProvider>
85 <Navigation
86 linking={appLinking}
87 theme={colorScheme === "dark" ? DarkTheme : DefaultTheme}
88 />
89 </IncomingShareProvider>
90 <ConfirmDialogHost />
91 </BlurTargetView>
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 </AppearancePreferencesProvider>
99 </CloudAuthProvider>
100 </RegistryContext.Provider>
101 );
102}