-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
143 lines (127 loc) · 3.33 KB
/
App.js
File metadata and controls
143 lines (127 loc) · 3.33 KB
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
import React, {useState, useEffect} from 'react';
import {View, Text, StyleSheet} from 'react-native';
import {
useQuery,
useMutation,
useQueryClient,
QueryClient,
QueryClientProvider,
} from 'react-query';
import {GoogleSignin} from '@react-native-google-signin/google-signin';
import Entypo from 'react-native-vector-icons/Entypo';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import {NavigationContainer} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import {
Favorites,
Home,
Park,
Onboard,
Login,
FullMap,
ParkGame,
} from './pages';
import {GlobalProvider, useGlobal} from './context/global-context';
import {useAuth} from './context/auth-context';
import {COLORS} from './constants';
import ASSETS from './assets';
Entypo.loadFont();
MaterialCommunityIcons.loadFont();
const Stack = createStackNavigator();
const Tab = createBottomTabNavigator();
const TabNavigator = () => {
const {
favorites: {FavSvg, NoFavSvg},
} = ASSETS;
return (
<Tab.Navigator
screenOptions={{
tabBarStyle: styles.tabBar,
tabBarActiveTintColor: COLORS.darkGreen,
tabBarInactiveTintColor: 'grey',
tabBarShowLabel: false,
headerShown: false,
}}>
<Tab.Screen
name="Home"
component={Home}
options={{
tabBarIcon: ({color}) => (
<Entypo name="home" size={32} color={color} />
),
}}
/>
<Tab.Screen
name="FullMap"
component={FullMap}
options={{
tabBarIcon: ({color}) => (
<MaterialCommunityIcons name="map" size={32} color={color} />
),
}}
/>
<Tab.Screen
name="Favorites"
component={Favorites}
options={{
tabBarIcon: opt =>
opt.focused ? (
<FavSvg height={32} width={32} />
) : (
<NoFavSvg height={32} width={32} />
),
}}
/>
</Tab.Navigator>
);
};
// Create a client
const queryClient = new QueryClient();
export default function App() {
const {user, initializing} = useAuth();
GoogleSignin.configure({
webClientId:
'12398867805-3t8ijtejc7dibs5rmorc3u1umqsnth3i.apps.googleusercontent.com',
});
const {onboardComplete} = useGlobal();
if (onboardComplete === null) {
return null;
}
if (!user) {
return <Login />;
}
if (onboardComplete === 'NOT_COMPLETE') {
return <Onboard />;
}
return (
<NavigationContainer>
<QueryClientProvider client={queryClient}>
<Stack.Navigator>
<Stack.Screen
name="TabNavigator"
component={TabNavigator}
options={{headerShown: false}}
/>
<Stack.Screen
name="Park"
component={Park}
options={{headerShown: false}}
/>
<Stack.Screen
name="ParkGame"
component={ParkGame}
options={{headerShown: false}}
/>
</Stack.Navigator>
</QueryClientProvider>
</NavigationContainer>
);
}
const styles = StyleSheet.create({
tabBar: {
backgroundColor: 'white',
borderTopLeftRadius: 20,
borderTopRightRadius: 20,
},
});