68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
import i18next, { getLanguage } from "../services/i18n/index";
|
|
import FontAwesome from "@expo/vector-icons/FontAwesome";
|
|
import {
|
|
DarkTheme,
|
|
DefaultTheme,
|
|
ThemeProvider,
|
|
} from "@react-navigation/native";
|
|
import { useFonts } from "expo-font";
|
|
import { Stack, useRouter } from "expo-router";
|
|
import * as SplashScreen from "expo-splash-screen";
|
|
import { useEffect, useState } from "react";
|
|
import "react-native-reanimated";
|
|
import { I18nextProvider } from "react-i18next"; //I18nextProvider
|
|
|
|
import { useColorScheme } from "@/components/useColorScheme";
|
|
|
|
export {
|
|
// Catch any errors thrown by the Layout component.
|
|
ErrorBoundary,
|
|
} from "expo-router";
|
|
|
|
export const unstable_settings = {
|
|
// Ensure that reloading on `/modal` keeps a back button present.
|
|
initialRouteName: "(tabs)",
|
|
};
|
|
|
|
// Prevent the splash screen from auto-hiding before asset loading is complete.
|
|
SplashScreen.preventAutoHideAsync();
|
|
|
|
export default function RootLayout() {
|
|
const [loaded, error] = useFonts({
|
|
SpaceMono: require("../assets/fonts/SpaceMono-Regular.ttf"),
|
|
...FontAwesome.font,
|
|
});
|
|
|
|
// Expo Router uses Error Boundaries to catch errors in the navigation tree.
|
|
useEffect(() => {
|
|
if (error) throw error;
|
|
}, [error]);
|
|
|
|
useEffect(() => {
|
|
if (loaded) {
|
|
SplashScreen.hideAsync();
|
|
}
|
|
}, [loaded]);
|
|
|
|
if (!loaded) {
|
|
return null;
|
|
}
|
|
|
|
return <RootLayoutNav />;
|
|
}
|
|
|
|
function RootLayoutNav() {
|
|
const colorScheme = useColorScheme();
|
|
|
|
return (
|
|
<I18nextProvider i18n={i18next}>
|
|
<ThemeProvider value={colorScheme === "dark" ? DarkTheme : DefaultTheme}>
|
|
<Stack>
|
|
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
|
<Stack.Screen name="modal" options={{ presentation: "modal" }} />
|
|
</Stack>
|
|
</ThemeProvider>
|
|
</I18nextProvider>
|
|
);
|
|
}
|