-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
103 lines (101 loc) · 3.04 KB
/
App.js
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import { Provider, useDispatch, useSelector } from 'react-redux'
import { StatusBar } from 'expo-status-bar'
import React, { useState } from 'react'
import { StyleSheet, Text, View } from 'react-native'
import { store } from './app/store'
import {} from 'react-redux'
import { NavigationContainer } from '@react-navigation/native'
import { createNativeStackNavigator } from '@react-navigation/native-stack'
import Login from './app/features/auth/Login'
import SplashScreen from './app/features/SplashScreen'
import Tabs from './app/features/navigator/BottomNavigator'
import { SafeAreaView } from 'react-native-safe-area-context'
import * as Font from 'expo-font'
import AppLoading from 'expo-app-loading'
import Welcome from './app/features/auth/Welcome'
import Signup from './app/features/auth/Signup'
import JobDetails from './app/features/jobs/jobdetails/JobDetails'
const Stack = createNativeStackNavigator()
const fetchFonts = () => {
return Font.loadAsync({
'graphik-regular': require('./assets/fonts/GraphikRegular.ttf'),
})
}
const App = () => {
const user = useSelector((state) => state.auth)
return (
<SafeAreaView style={{ flex: 1 }}>
<View style={styles.container}>
<NavigationContainer>
{user.status === 'loading' ? (
<Stack.Navigator>
<Stack.Screen
options={{ headerShown: false }}
name="Splash"
component={SplashScreen}
/>
</Stack.Navigator>
) : user.status === 'loggedIn' ? (
<Stack.Navigator>
<Stack.Screen
name="TabStack"
component={Tabs}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="JobDetails"
component={JobDetails}
options={{
headerShown: false,
}}
/>
</Stack.Navigator>
) : (
<Stack.Navigator>
<Stack.Screen
options={{ headerShown: false }}
name="Welcome"
component={Welcome}
></Stack.Screen>
<Stack.Screen
options={{ headerShown: false }}
name="Login"
component={Login}
/>
<Stack.Screen
options={{ headerShown: false }}
name="Signup"
component={Signup}
/>
</Stack.Navigator>
)}
</NavigationContainer>
<StatusBar style="auto" />
</View>
</SafeAreaView>
)
}
export default function AppWrapper() {
const [dataLoaded, setDataLoaded] = useState(false)
if (!dataLoaded) {
return (
<AppLoading
startAsync={fetchFonts}
onFinish={() => setDataLoaded(true)}
onError={console.warn}
/>
)
}
return (
<Provider store={store}>
<App />
</Provider>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
})