-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
143 lines (133 loc) · 4.46 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
// Native
import { SafeAreaProvider } from 'react-native-safe-area-context';
// EXPO
import { StatusBar } from 'expo-status-bar';
// Screens
import LoginScreen from './Pages/LoginScreen';
import SignUpScreen from './Pages/SignUpScreen';
import HomeScreen from './Pages/HomeScreen';
import CameraScreen from './Pages/CameraScreen';
import QuestsScreen from './Pages/QuestsScreen';
import CollectionsScreen from './Pages/CollectionsScreen';
// Navigation
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
// Design
import DesignSystem from './components/style/DesignSystem';
import useFont from './components/hooks/useFont';
// Navigators
const Stack = createNativeStackNavigator();
const Tab = createBottomTabNavigator();
// Tab Icon
import { FontAwesome } from '@expo/vector-icons';
import { MaterialCommunityIcons } from '@expo/vector-icons';
import { MaterialIcons } from '@expo/vector-icons';
export default function App() {
const { STACK_NAV_HEADER } = DesignSystem();
const options = STACK_NAV_HEADER;
const isFontLoaded = useFont();
////////////////////////////////////////////////////////////////////////
// Font has to be loaded before the app can be rendered
// Status bar hides phone status bar and RootNavigator is refactored
if (isFontLoaded) {
return (
<SafeAreaProvider>
<NavigationContainer>
<StatusBar hidden />
<RootNavigator options={options} />
</NavigationContainer>
</SafeAreaProvider>
);
} else {
return null;
}
}
/**
* A refactoring of StackNavigator that will handle all the screen routing
* @returns a root navigator that will render the screen in chronological order
*/
function RootNavigator({ options }) {
return (
<Stack.Navigator
headerShown={false}
screenOptions={options}
>
<Stack.Screen
name="LoginScreen"
component={LoginScreen}
/>
<Stack.Screen
name="HomeScreen"
component={HomeScreen}
options={options}
/>
<Stack.Screen
name="CollectionsScreen"
component={CollectionsScreen}
options={options}
/>
<Stack.Screen
name="QuestsScreen"
component={QuestsScreen}
options={options}
/>
<Stack.Screen
name="SignUpScreen"
component={SignUpScreen}
options={options}
/>
<Stack.Screen
name="CameraScreen"
component={BottomNavigator}
options={options}
/>
</Stack.Navigator>
);
}
/**
*
* @returns A bottom navigator with icons that routes to screen
* It's crucial to use navigation.pop() to remove the screen for the active stack.
* Otherwise, the bottom navigator will still be the active stack.
*/
function BottomNavigator() {
return (
<Tab.Navigator initialRouteName="LoginScreen">
<Tab.Screen
name="Camera"
component={CameraScreen}
options={{
headerShown: false,
tabBarIcon: ({ color, size }) => (
<FontAwesome name="qrcode" size={size} color={color} />
),
}}
/>
<Tab.Screen
name="Collection"
component={CollectionsScreen}
options={{
headerShown: false,
tabBarIcon: ({ color, size }) => (
<MaterialIcons name="collections" size={size} color={color} />
),
}}
/>
<Tab.Screen
name="Quest"
component={QuestsScreen}
options={{
headerShown: false,
tabBarIcon: ({ color, size }) => (
<MaterialCommunityIcons
name="map-marker-question"
size={size}
color={color}
/>
),
}}
/>
</Tab.Navigator>
);
}