-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
55 lines (53 loc) · 1.83 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React, {useState} from 'react';
import {StatusBar, Text, useColorScheme} from 'react-native';
import {Colors} from 'react-native/Libraries/NewAppScreen';
import AuthScreen from '~/screens/Auth/AuthScreen';
import {SafeAreaProvider} from 'react-native-safe-area-context';
import {NavigationContainer} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import {BottomTabs} from '~/screens/Layout/BottomTabs';
import SplashScreen from '~/screens/Splash/SplashScreen';
import {useRecoilState} from 'recoil';
import {userInfoState} from '~/states';
import _ from 'lodash';
const Stack = createNativeStackNavigator<RootStackParamList>();
const App = (): JSX.Element => {
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
const [userInfo] = useRecoilState(userInfoState);
return (
<SafeAreaProvider>
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor={backgroundStyle.backgroundColor}
/>
<NavigationContainer>
<Stack.Navigator initialRouteName="Shopping">
{!_.isEmpty(userInfo) ? (
<Stack.Screen
name="BottomTabs"
component={BottomTabs}
options={{headerShown: false}}
/>
) : (
<>
<Stack.Screen
name="Splash"
component={SplashScreen}
options={{headerShown: false}}
/>
<Stack.Screen
name="Auth"
component={AuthScreen}
options={{headerShown: false}}
/>
</>
)}
</Stack.Navigator>
</NavigationContainer>
</SafeAreaProvider>
);
};
export default App;