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

App.tsx

109 lines4.3 KB

1import { PermissionUpdateNotice } from "./features/connection/PermissionUpdateNotice";
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 * as Dialog from "./components/ui/Dialog";
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/ui/OverlayPortal";
24import { shouldHandleAppLink } from "./lib/appLinking";
25import { useMobileNavigationTheme } from "./lib/useMobileNavigationTheme";
26import { useUiRuntimeMemoryWarningGc } from "./lib/useUiRuntimeMemoryWarningGc";
27import { SubscriptionUsageCoordinator } from "./widgets/SubscriptionUsageCoordinator";
28import { VoiceInputProvider } from "./features/voice-input/VoiceInputProvider";
29import { GlobalVoiceInputControl } from "./features/voice-input/GlobalVoiceInputControl";
30import { NativeLayoutMetricsProvider } from "./native/native-layout-metrics";
31​
32import "../global.css";
33​
34if (process.env.EXPO_PUBLIC_SHOWCASE === "1") {
35 prepareNativeShowcaseCapture();
37​
38void SplashScreen.preventAutoHideAsync().catch(() => {});
39​
40const appLinking = {
41 prefixes: [Linking.createURL("/"), "t3code://", "t3code-dev://", "t3code-preview://"],
42 config: { initialRouteName: "Home" },
43 filter: shouldHandleAppLink,
44};
45​
46const Navigation = createStaticNavigation(RootStack);
47​
48function SplashScreenCoordinator() {
49 const { isReady } = useAppearancePreferences();
50​
51 useEffect(() => {
52 if (isReady) void SplashScreen.hide();
53 }, [isReady]);
54​
55 return null;
57​
58export default function App() {
59 useUiRuntimeMemoryWarningGc();
60​
61 return (
62 <RegistryContext.Provider value={appAtomRegistry}>
63 <CloudAuthProvider>
64 <AppearancePreferencesProvider>
65 <AppContent />
66 </AppearancePreferencesProvider>
67 </CloudAuthProvider>
68 </RegistryContext.Provider>
69 );
71​
72function AppContent() {
73 const { themeAppearance } = useAppearancePreferences();
74 const navigationTheme = useMobileNavigationTheme();
75​
76 return (
77 <>
78 <SplashScreenCoordinator />
79 <SubscriptionUsageCoordinator />
80 <PermissionUpdateNotice />
81 <GestureHandlerRootView className="flex-1">
82 <KeyboardProvider statusBarTranslucent>
83 <SafeAreaProvider>
84 <VoiceInputProvider>
85 <StatusBar barStyle={themeAppearance === "dark" ? "light-content" : "dark-content"} />
86 {/* The navigation theme drives the NATIVE header appearance: native-stack
87 forwards `dark` as the nav bar's overrideUserInterfaceStyle. Without
88 this, React Navigation defaults to its light theme and every native
89 header (glass buttons, title, materials) is forced light even when
90 the system is in dark mode. */}
91 <GlobalVoiceInputControl>
92 <NativeLayoutMetricsProvider>
93 <IncomingShareProvider>
94 <Navigation linking={appLinking} theme={navigationTheme} />
95 </IncomingShareProvider>
96 <Dialog.Host />
97 <ThreadArrangementHost />
98 </NativeLayoutMetricsProvider>
99 </GlobalVoiceInputControl>
100 {/* Anchored-menu overlays render here — in-window, so the
101 keyboard stays up while a dropdown is open. */}
102 <OverlayPortalHost />
103 </VoiceInputProvider>
104 </SafeAreaProvider>
105 </KeyboardProvider>
106 </GestureHandlerRootView>
107 </>
108 );