Open History to see the last commit
1import {
2 DMSans_400Regular,
3 DMSans_500Medium,
4 DMSans_700Bold,
5 useFonts,
6} from "@expo-google-fonts/dm-sans";
7import * as Linking from "expo-linking";
8import * as SplashScreen from "expo-splash-screen";
9import { StatusBar, useColorScheme } from "react-native";
10import { GestureHandlerRootView } from "react-native-gesture-handler";
11import { KeyboardProvider } from "react-native-keyboard-controller";
12import { SafeAreaProvider } from "react-native-safe-area-context";
13import { createStaticNavigation, DarkTheme, DefaultTheme } from "@react-navigation/native";
14
15import { RegistryContext } from "@effect/atom-react";
16import { useEffect } from "react";
17import { CloudAuthProvider } from "./features/cloud/CloudAuthProvider";
18import { AppearancePreferencesProvider } from "./features/settings/appearance/AppearancePreferencesProvider";
19import { RootStack } from "./Stack";
20import { appAtomRegistry } from "./state/atom-registry";
21import { useThemeColor } from "./lib/useThemeColor";
22
23import "../global.css";
24
25const appLinking = {
26 prefixes: [Linking.createURL("/"), "t3code://", "t3code-dev://", "t3code-preview://"],
27};
28
29const Navigation = createStaticNavigation(RootStack);
30
31export default function App() {
32 const [fontsLoaded] = useFonts({
33 DMSans_400Regular,
34 DMSans_500Medium,
35 DMSans_700Bold,
36 });
37 const colorScheme = useColorScheme();
38 const statusBarBg = useThemeColor("--color-status-bar");
39
40 useEffect(() => {
41 if (fontsLoaded) SplashScreen.hide();
42 }, [fontsLoaded]);
43
44 return (
45 <RegistryContext.Provider value={appAtomRegistry}>
46 <CloudAuthProvider>
47 <AppearancePreferencesProvider>
48 <GestureHandlerRootView style={{ flex: 1 }}>
49 <KeyboardProvider statusBarTranslucent>
50 <SafeAreaProvider>
51 <StatusBar
52 barStyle={colorScheme === "dark" ? "light-content" : "dark-content"}
53 backgroundColor={statusBarBg}
54 translucent
55 />
56 {/* The navigation theme drives the NATIVE header appearance: native-stack
57 forwards `dark` as the nav bar's overrideUserInterfaceStyle. Without
58 this, React Navigation defaults to its light theme and every native
59 header (glass buttons, title, materials) is forced light even when
60 the system is in dark mode. */}
61 <Navigation
62 linking={appLinking}
63 theme={colorScheme === "dark" ? DarkTheme : DefaultTheme}
64 />
65 </SafeAreaProvider>
66 </KeyboardProvider>
67 </GestureHandlerRootView>
68 </AppearancePreferencesProvider>
69 </CloudAuthProvider>
70 </RegistryContext.Provider>
71 );
72}