-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScreenNavigation.jsx
256 lines (239 loc) · 7.56 KB
/
ScreenNavigation.jsx
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
import React, { Suspense, lazy, useEffect, useState } from 'react';
import { DefaultTheme, NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { firebase } from '../firebase';
import Spinner from '../misc/Spinner';
import AudioProvider from '../context/AudioProvider.jsx';
import color from '../misc/color.js';
import FontAwesome5 from '@expo/vector-icons/FontAwesome5';
import Entypo from '@expo/vector-icons/Entypo';
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
const Splash = lazy(() => import('../screens/splash/Splash.jsx'));
const LoginScreen = lazy(() =>
import('../screens/authentication/login/LoginScreen.jsx')
);
const ForgotPasswordScreen = lazy(() =>
import('../screens/authentication/forgottenPassword/ForgotPasswordScreen.jsx')
);
const RegistrationScreen = lazy(() =>
import('../screens/authentication/registration/RegistrationScreen.jsx')
);
const HomeScreen = lazy(() => import('../screens/home/HomeScreen'));
const SearchScreen = lazy(() => import('../screens/search/SearchScreen'));
const LibraryScreen = lazy(() => import('../screens/library/LibraryScreen'));
const PlaylistDetail = lazy(() =>
import('../screens/library/PlaylistDetail.jsx')
);
const AudioPlayer = lazy(() =>
import('../screens/music/audioPlayer/AudioPlayer')
);
const AudioMenu = lazy(() => import('../screens/music/audioMenu/AudioMenu'));
const Tab = createBottomTabNavigator();
const Stack = createNativeStackNavigator();
const PlaylistScreen = () => {
return (
<Suspense fallback={<Spinner />}>
<Stack.Navigator
initialRouteName="Library Screen"
screenOptions={{ headerTitleAlign: 'center', headerShown: false }}
>
<Stack.Screen
component={LibraryScreen}
name="Library Screen"
options={{ headerShown: false }}
/>
<Stack.Screen
component={PlaylistDetail}
name="Playlist Detail"
options={{ headerShown: false }}
/>
</Stack.Navigator>
</Suspense>
);
};
const BottomNavigationBar = () => {
return (
<Suspense fallback={<Spinner />}>
<Tab.Navigator
initialRouteName="Home"
screenOptions={{ headerTitleAlign: 'center', headerShown: false }}
>
<Tab.Screen
name="Home"
component={HomeScreen}
options={{
tabBarIcon: () => (
<FontAwesome5 name="home" color={color.ACTIVE_BG} size={25} />
),
tabBarActiveBackgroundColor: 'black',
tabBarActiveTintColor: color.FONT,
tabBarInactiveBackgroundColor: color.FONT,
tabBarInactiveTintColor: color.ACTIVE_BG,
}}
/>
<Tab.Screen
name="Browse"
component={SearchScreen}
options={{
tabBarIcon: () => (
<FontAwesome5 name="search" color={color.ACTIVE_BG} size={25} />
),
tabBarActiveBackgroundColor: 'black',
tabBarActiveTintColor: color.FONT,
tabBarInactiveBackgroundColor: color.FONT,
tabBarInactiveTintColor: color.ACTIVE_BG,
}}
/>
{/* <Tab.Screen
name="Library"
component={LibraryScreen}
options={{
tabBarIcon: () => (
<MaterialIcons
name="library-music"
color={color.ACTIVE_BG}
size={25}
/>
),
tabBarActiveBackgroundColor: 'black',
tabBarActiveTintColor: color.FONT,
tabBarInactiveBackgroundColor: color.FONT,
tabBarInactiveTintColor: color.ACTIVE_BG,
}}
/> */}
<Tab.Screen
name="Hypnotiq Player"
component={AudioPlayer}
options={{
tabBarIcon: () => (
<MaterialIcons name="headset" color={color.ACTIVE_BG} size={25} />
),
tabBarActiveBackgroundColor: 'black',
tabBarActiveTintColor: color.FONT,
tabBarInactiveBackgroundColor: color.FONT,
tabBarInactiveTintColor: color.ACTIVE_BG,
}}
/>
<Tab.Screen
name="Playlist"
component={PlaylistScreen}
options={{
tabBarIcon: () => (
<MaterialIcons
name="library-music"
color={color.ACTIVE_BG}
size={25}
/>
),
tabBarActiveBackgroundColor: 'black',
tabBarActiveTintColor: color.FONT,
tabBarInactiveBackgroundColor: color.FONT,
tabBarInactiveTintColor: color.ACTIVE_BG,
}}
/>
<Tab.Screen
name="Library"
component={AudioMenu}
options={{
tabBarIcon: () => (
<Entypo name="folder-music" color={color.ACTIVE_BG} size={25} />
),
tabBarActiveBackgroundColor: 'black',
tabBarActiveTintColor: color.FONT,
tabBarInactiveBackgroundColor: color.FONT,
tabBarInactiveTintColor: color.ACTIVE_BG,
}}
/>
</Tab.Navigator>
</Suspense>
);
};
const MyTheme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
background: color.APP_BG,
},
};
const Routes = () => {
const [initializing, setInitializing] = useState(true);
const [user, setUser] = useState();
const onAuthStateChanged = (user) => {
setUser(user);
if (initializing) {
setInitializing(false);
}
};
useEffect(() => {
const subscriber = firebase.auth()?.onAuthStateChanged(onAuthStateChanged);
return subscriber;
}, []);
if (initializing) return null;
if (!user) {
return (
<Suspense fallback={<Spinner />}>
<Stack.Navigator
initialRouteName="Splash Screen"
screenOptions={{ headerTitleAlign: 'center', headerShown: false }}
>
<Stack.Screen
component={Splash}
name="Splash Screen"
options={{ headerShown: false }}
/>
<Stack.Screen
component={LoginScreen}
name="Login Screen"
options={{ headerShown: false }}
/>
<Stack.Screen
component={ForgotPasswordScreen}
name="Forgot Password Screen"
options={{ headerShown: false }}
/>
<Stack.Screen
component={RegistrationScreen}
name="Registration Screen"
options={{ headerShown: false }}
/>
<Stack.Screen
component={BottomNavigationBar}
name="Bottom Navigation Bar"
options={{ headerShown: false }}
/>
</Stack.Navigator>
</Suspense>
);
}
return (
<Suspense fallback={<Spinner />}>
<Stack.Navigator
initialRouteName="Splash Screen"
screenOptions={{ headerTitleAlign: 'center', headerShown: false }}
>
<Stack.Screen name="Splash Screen" component={Splash} />
<Stack.Screen
name="Bottom Navigation Bar"
component={BottomNavigationBar}
options={{ headerShown: false }}
/>
{/* <Stack.Screen
component={PlaylistDetail}
name="Playlist Detail"
options={{ headerShown: false }}
/> */}
</Stack.Navigator>
</Suspense>
);
};
const ScreenNavigation = () => {
return (
<AudioProvider>
<NavigationContainer theme={MyTheme}>
<Routes />
</NavigationContainer>
</AudioProvider>
);
};
export default ScreenNavigation;