-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreens.js
60 lines (57 loc) · 1.62 KB
/
screens.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
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import React from 'react';
import { useAuth } from './context/AuthCtx';
import Login from './Login';
import Search from './Search';
import UserTabsNavigation from './UserProfile/UserTabsNavigation';
import { ActivityIndicator, StyleSheet, View } from 'react-native';
const Screens = () => {
const Stack = createNativeStackNavigator();
const { isAuthenticated } = useAuth();
const screenOptions = {
headerShown: false, // hide the header on all screens
loadingEnabled: true, // enable the loading component
loadingComponent: (
<View style={styles.loadingContainer}>
<ActivityIndicator size='large' color='#FFFFFF' />
</View>
), // set the custom loading component
};
return (
<Stack.Navigator screenOptions={screenOptions}>
{isAuthenticated ? (
<>
<Stack.Screen
name='SearchScreen'
component={Search}
options={{ headerShown: false }}
/>
<Stack.Screen
name='UserTabsNavigation'
options={{ headerShown: false }}
component={UserTabsNavigation}
/>
</>
) : (
<Stack.Screen
name='Login'
component={Login}
options={{ headerShown: false }}
/>
)}
</Stack.Navigator>
);
};
export default Screens;
const styles = StyleSheet.create({
loadingContainer: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'rgba(0, 0, 0, 0.5)',
},
});