-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
116 lines (111 loc) · 3.6 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
import React, { useState, useEffect, useRef } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import LoginScreen from './src/auth/screens/LoginScreen';
import MainScreen from './src/feed/screens/MainScreen';
import AsyncStorage from '@react-native-async-storage/async-storage';
import OnboardingScreen from './src/auth/screens/OnboardingScreenUsername';
import AddFriendsOnboarding from './src/auth/screens/addFriendsOnboarding';
import EventsRendering from './src/events/screens/eventsRenderingScreen';
import AddFriendsCircleScreen from './src/events/screens/addFriendsCircleScreen';
import AddCircle from './src/events/screens/addCircleScreen';
import CreateNewCircleWithFriends from './src/events/screens/addFriendsToCircleScreen';
import AddEventScreen from './src/addEvent/screen/AddEventScreen';
import AddFriendsCircles from './src/addEvent/screen/AddFriendsCirclesScreen';
const Stack = createStackNavigator();
const RootStack = () => {
const [initialRoute, setInitialRoute] = useState('Login');
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
AsyncStorage.getItem('userToken').then((userToken) => {
if (userToken) {
setInitialRoute('EventsRendering');
} else {
setInitialRoute('Login');
}
setIsLoading(false);
});
}, []);
const verticalAnimation = {
gestureDirection: 'vertical',
headerShown: false,
cardStyleInterpolator: ({ current, layouts }) => {
return {
cardStyle: {
transform: [
{
translateY: current.progress.interpolate({
inputRange: [0, 1],
outputRange: [layouts.screen.height, 0],
}),
},
],
},
};
},
};
if (!isLoading) {
return (
<Stack.Navigator initialRouteName={initialRoute}>
<Stack.Screen
name="Login"
component={LoginScreen}
options={{ headerShown: false }}
initialParams={{ navigation: null }} // Pass navigation as initialParams
/>
{/* <Stack.Screen
name="Main"
component={MainScreen}
options={{ headerShown: false }}
/> */}
<Stack.Screen
name="Onboard"
component={OnboardingScreen}
options={{ headerShown: false }}
/>
<Stack.Screen
name="OnboardFriends"
component={AddFriendsOnboarding}
options={{ headerShown: false }}
/>
<Stack.Screen
name="AddEvent"
component={AddEventScreen}
options={verticalAnimation}/>
<Stack.Screen
name="EventsRendering"
component={EventsRendering}
options={{ headerShown: false }}
/>
<Stack.Screen
name="AddNewFriendsCircles"
component={AddFriendsCircleScreen}
options={{ headerShown: false }}
/>
<Stack.Screen
name="AddCircle"
component={AddCircle}
options={{ headerShown: false }}
/>
<Stack.Screen
name="CreateNewCircleWithFriends"
component={CreateNewCircleWithFriends}
options={{ headerShown: false }}
/>
<Stack.Screen
name="AddFriendsCirclesEventFlow"
component={AddFriendsCircles}
options={{ headerShown: false }}
/>
</Stack.Navigator>
);
}
}
const App = () => {
return (
<NavigationContainer>
<RootStack />
</NavigationContainer>
);
}
export default App;