-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
109 lines (102 loc) · 3.5 KB
/
App.tsx
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
import { MainHeader, SimpleHeader, UsersHeader } from '@/entities/header';
import { HomePage } from '@/pages/home.page';
import { SwipePage } from '@/pages/swipes.page';
import { DefaultTheme, NavigationContainer } from '@react-navigation/native';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import {
StackNavigationProp,
createStackNavigator,
} from '@react-navigation/stack';
import { ToastProvider } from '@/entities/toast/toast-provider';
import { VotingPage } from '@/pages/vote.page';
import * as SplashScreen from 'expo-splash-screen';
import { useFonts } from 'expo-font';
import { useCallback, useEffect } from 'react';
import { ResultPage } from '@/pages/result.page';
import { RootStackParamList } from '@/app/navigation.interface';
import { ProfilePage } from '@/pages/profile.page';
import { LobbyPage } from '@/pages/lobby.page';
import { useAuth } from '@/app/stores/auth.store';
import { LoginPage } from '@/pages/login.page';
import { SocketProvider } from '@/shared/providers/socket.provider';
import { API_URL } from '@/app/app.settings';
import axios from 'axios';
SplashScreen.preventAutoHideAsync();
const Stack = createStackNavigator<RootStackParamList>();
export default function App() {
const [fontsLoaded, fontError] = useFonts({
FormaDJRCyrillicText: require('./assets/fonts/FormaDJRCyrillicText.ttf'),
'Inter-Regular': require('./assets/fonts/Inter-Regular.ttf'),
});
const { authenticated } = useAuth();
const onLayoutRootView = useCallback(async () => {
if (fontsLoaded || fontError) {
await SplashScreen.hideAsync();
}
}, [fontsLoaded, fontError]);
if (!fontsLoaded && !fontError) {
return null;
}
return (
<SafeAreaProvider onLayout={onLayoutRootView}>
<ToastProvider>
<SocketProvider>
<NavigationContainer
theme={{
...DefaultTheme,
colors: {
...DefaultTheme.colors,
background: 'white',
},
}}
>
<Stack.Navigator
screenOptions={{
animationEnabled: false,
cardStyle: { backgroundColor: '#fff' },
}}
>
{/* {!authenticated && (
<Stack.Screen
options={{ header: SimpleHeader }}
name='login'
component={LoginPage}
/>
)}
<Stack.Screen
options={{ header: MainHeader }}
name='home'
component={HomePage}
/>
<Stack.Screen
options={{ header: SimpleHeader }}
name='profile'
component={ProfilePage}
/> */}
<Stack.Screen
options={{ header: UsersHeader }}
name='lobby'
component={LobbyPage}
/>
<Stack.Screen
options={{ header: UsersHeader }}
name='swipes'
component={SwipePage}
/>
<Stack.Screen
options={{ header: UsersHeader }}
name='voting'
component={VotingPage}
/>
<Stack.Screen
options={{ header: UsersHeader }}
name='result'
component={ResultPage}
/>
</Stack.Navigator>
</NavigationContainer>
</SocketProvider>
</ToastProvider>
</SafeAreaProvider>
);
}