Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

App.tsx

88 lines3.9 KB

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