frontend client for gemstone. decentralised workplace app
at main 2.2 kB view raw
1import { isDevMode } from "@/lib/utils/env"; 2import { RootProviders } from "@/providers"; 3import { useCurrentPalette } from "@/providers/ThemeProvider"; 4import { 5 Lexend_100Thin, 6 Lexend_200ExtraLight, 7 Lexend_300Light, 8 Lexend_400Regular, 9 Lexend_500Medium, 10 Lexend_600SemiBold, 11 Lexend_700Bold, 12 Lexend_800ExtraBold, 13 Lexend_900Black, 14 useFonts, 15} from "@expo-google-fonts/lexend"; 16import { Slot, SplashScreen } from "expo-router"; 17import { useEffect } from "react"; 18import { Platform, View } from "react-native"; 19import { GestureHandlerRootView } from "react-native-gesture-handler"; 20 21const RootLayoutInner = () => { 22 const [loaded, error] = useFonts({ 23 Lexend_100Thin, 24 Lexend_200ExtraLight, 25 Lexend_300Light, 26 Lexend_400Regular, 27 Lexend_500Medium, 28 Lexend_600SemiBold, 29 Lexend_700Bold, 30 Lexend_800ExtraBold, 31 Lexend_900Black, 32 }); 33 34 const { semantic } = useCurrentPalette(); 35 36 useEffect(() => { 37 if (!isDevMode) return; 38 if (Platform.OS === "web" && typeof window !== "undefined") { 39 const hostname = window.location.hostname; 40 if (hostname === "127.0.0.1") return; 41 if (hostname === "localhost") { 42 const newUrl = window.location.href.replace( 43 "localhost", 44 "127.0.0.1", 45 ); 46 window.location.replace(newUrl); 47 return; 48 } 49 50 throw new Error( 51 "don't use localhost, use 127.0.0.1. this shouldn't error unless you've done something very wrong.", 52 ); 53 } 54 }); 55 56 useEffect(() => { 57 if (loaded || error) { 58 void SplashScreen.hideAsync(); 59 } 60 }, [loaded, error]); 61 62 if (!loaded && !error) { 63 return null; 64 } 65 66 return ( 67 <View style={{ backgroundColor: semantic.background, flex: 1 }}> 68 <Slot /> 69 </View> 70 ); 71}; 72 73const RootLayout = () => { 74 return ( 75 <GestureHandlerRootView> 76 <RootProviders> 77 <RootLayoutInner /> 78 </RootProviders> 79 </GestureHandlerRootView> 80 ); 81}; 82 83export default RootLayout;