File tree Expand file tree Collapse file tree 4 files changed +19
-7
lines changed Expand file tree Collapse file tree 4 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -3,12 +3,19 @@ import 'react-native-reanimated'
33import { Stack } from 'expo-router'
44
55import { useListenLocalStorage } from '@/common/localStorage'
6+ import { Spinner } from '@/components/Spinner'
7+ import { useSplashScreen } from '@/hooks/useSplashScreen'
68
79export default function AppLayout ( ) {
10+ const ready = useSplashScreen ( )
811 const [ accessToken ] = useListenLocalStorage ( 'accessToken' )
912
1013 const isLoggedIn = Boolean ( accessToken )
1114
15+ if ( ! ready ) {
16+ return < Spinner />
17+ }
18+
1219 return (
1320 < Stack screenOptions = { { headerShown : false } } >
1421 < Stack . Protected guard = { isLoggedIn } >
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import { Slot } from 'expo-router'
1010import { StatusBar } from 'expo-status-bar'
1111import { useLayoutEffect } from 'react'
1212
13- import { SplashScreen } from '@/components/SplashScreen'
1413import { useColorScheme } from '@/hooks/useColorScheme'
1514
1615export default function RootLayout ( ) {
@@ -22,7 +21,6 @@ export default function RootLayout() {
2221
2322 return (
2423 < ThemeProvider value = { colorScheme === 'dark' ? DarkTheme : DefaultTheme } >
25- < SplashScreen />
2624 < Slot />
2725 < StatusBar style = "auto" />
2826 </ ThemeProvider >
Original file line number Diff line number Diff line change 1+ import { ActivityIndicator , ActivityIndicatorProps } from 'react-native'
2+
3+ import { Color } from '@/constants/Colors'
4+
5+ export function Spinner ( props : ActivityIndicatorProps ) {
6+ return < ActivityIndicator color = { Color . Green } { ...props } />
7+ }
Original file line number Diff line number Diff line change 1- import 'react-native-reanimated'
2-
31import { useFonts } from 'expo-font'
42import * as ExpoSplashScreen from 'expo-splash-screen'
5- import { FunctionComponent , useEffect } from 'react'
3+ import { useEffect , useState } from 'react'
64
75import SpaceMono from '@/assets/fonts/SpaceMono-Regular.ttf'
86
97ExpoSplashScreen . preventAutoHideAsync ( )
108
11- export const SplashScreen : FunctionComponent = ( ) => {
9+ export const useSplashScreen = ( ) => {
1210 const [ loaded ] = useFonts ( { SpaceMono } )
11+ const [ ready , setReady ] = useState < boolean > ( false )
1312
1413 useEffect ( ( ) => {
1514 if ( loaded ) {
1615 ExpoSplashScreen . hideAsync ( )
16+ setReady ( true )
1717 }
1818 } , [ loaded ] )
1919
20- return null
20+ return ready
2121}
You can’t perform that action at this time.
0 commit comments