generated from bell-kevin/kevinBellTemplateRepo
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
148 lines (138 loc) · 4.33 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import { useContext } from 'react';
import { StatusBar } from 'expo-status-bar';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import IconButton from './components/UI/IconButton';
import Map from './screens/Map';
import PlaceDetails from './screens/PlaceDetails';
import AuthContextProvider from './context/authContext';
import UserContextProvider from './context/userContext';
import { AuthContext } from './context/authContext';
import LoginScreen from './screens/LoginScreen';
import SignupScreen from './screens/SignupScreen';
import WelcomeScreen from './screens/WelcomeScreen';
import NameScreen from './screens/NameScreen';
import PhoneScreen from './screens/PhoneScreen';
import ValidateScreen from './screens/ValidateScreen';
import FavoritePlacesNew from './screens/FavoritePlacesNew';
import AllPlaces from './screens/AllPlaces';
import AddPlace from './screens/AddPlace';
import DeletePlace from './screens/DeletePlace';
const Stack = createNativeStackNavigator();
function AuthStack() {
return (
<Stack.Navigator
screenOptions={{
headerStyle: { backgroundColor: 'black' },
headerTintColor: 'white',
headerTitleStyle: { fontWeight: 'bold' },
}}
>
<Stack.Screen name="Login" component={LoginScreen} />
<Stack.Screen name="Signup" component={SignupScreen} />
</Stack.Navigator>
);
}
function DataStack() {
return (
<Stack.Navigator
screenOptions={{
headerStyle: { backgroundColor: 'black' },
headerTintColor: 'white',
headerTitleStyle: { fontWeight: 'bold' },
}}
>
<Stack.Screen name="Name" component={NameScreen} />
<Stack.Screen name="Phone" component={PhoneScreen} />
<Stack.Screen name="FavoritePlaces" component={FavoritePlacesNew} options={{ headerShown: false }} />
<Stack.Screen
name="AllPlaces"
component={AllPlaces}
options={({ navigation }) => ({
title: 'Your Fav. Places',
headerRight: ({ tintColor }) => (
<>
<IconButton
icon="arrow-forward-outline"
size={24}
color={tintColor}
onPress={() => navigation.navigate('Validate')}
/>
<IconButton
icon="add"
size={24}
color={tintColor}
onPress={() => navigation.navigate('AddPlace')}
/>
<IconButton
icon="trash"
size={24}
color={tintColor}
onPress={() => navigation.navigate('DeletePlace')}
/>
</>
),
})}
/>
<Stack.Screen
name="AddPlace"
component={AddPlace}
options={{
title: 'Add a new Place',
}}
/>
<Stack.Screen
name="DeletePlace"
component={DeletePlace}
options={{
title: 'Delete a Place',
}}
/>
<Stack.Screen name="Map" component={Map} />
<Stack.Screen
name="PlaceDetails"
component={PlaceDetails}
options={{
title: 'Loading Place...',
}}
/>
<Stack.Screen name="Validate" component={ValidateScreen} />
<Stack.Screen name="Welcome" component={WelcomeScreen} />
</Stack.Navigator>
);
}
function AuthenticatedStack() {
return (
<Stack.Navigator
screenOptions={{
headerStyle: { backgroundColor: 'black' },
headerTintColor: 'white',
headerTitleStyle: { fontWeight: 'bold' },
}}
>
<Stack.Screen name="Welcome" component={WelcomeScreen} />
</Stack.Navigator>
);
}
function Root() {
const authCtx = useContext(AuthContext);
return (
<NavigationContainer>
{(!authCtx.isAuthenticated) && <AuthStack />}
{(authCtx.isAuthenticated && !authCtx.dataProvided) && <DataStack />}
{(authCtx.isAuthenticated && authCtx.dataProvided) && <AuthenticatedStack />}
</NavigationContainer>
);
}
export default function App() {
return (
<>
<StatusBar style="light" />
<AuthContextProvider>
<UserContextProvider>
<Root />
</UserContextProvider>
</AuthContextProvider>
</>
);
}