-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
175 lines (167 loc) · 4.62 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
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
import React, { useContext, useState } from "react";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
//pages common to both
import Signin from "./src/screens/Signin";
import Signup from "./src/screens/Signup";
import ChangePassword from "./src/screens/ChangePassword";
//pages for user
import Home from "./src/screens/Home";
import Restaurants from "./src/screens/Restaurants";
import Summary from "./src/screens/Summary";
import Orders from "./src/screens/Orders";
import Notification from "./src/screens/Notification";
import Profile from "./src/screens/Profile";
import Analysis from "./src/screens/Analysis";
import { AuthContext, AuthProvider } from "./src/services/AuthContext";
import * as Linking from "expo-linking";
const Stack = createNativeStackNavigator();
const prefix = Linking.createURL("/");
const linking = {
prefixes: [prefix],
config: {
screens: {
Summary: "summary",
},
},
};
const App = () => {
const initialScreen = "Signup";
const { user } = useContext(AuthContext);
return user ? (
<NavigationContainer linking={linking}>
<Stack.Navigator
initialRouteName={initialScreen}
screenOptions={{
headerShown: false,
gestureEnabled: true,
gestureDirection: "horizontal",
cardStyleInterpolator: ({ current, layouts }) => {
const { index } = current;
const inputRange = [index - 1, index, index + 1];
const translateX = current.progress.interpolate({
inputRange,
outputRange: [layouts.screen.width, 0, -layouts.screen.width],
});
return {
cardStyle: {
transform: [{ translateX }],
},
};
},
transitionSpec: {
open: { animation: "timing", config: { duration: 1200 } },
close: { animation: "timing", config: { duration: 1200 } },
},
}}
>
<Stack.Screen
name="Home"
component={Home}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="ChangePassword"
component={ChangePassword}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Profile"
component={Profile}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Restaurants"
component={Restaurants}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Analysis"
component={Analysis}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Summary"
component={Summary}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Orders"
component={Orders}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Notification"
component={Notification}
options={{
headerShown: false,
}}
/>
</Stack.Navigator>
</NavigationContainer>
) : (
<NavigationContainer>
<Stack.Navigator
initialRouteName={initialScreen}
screenOptions={{
headerShown: false,
gestureEnabled: true,
gestureDirection: "horizontal",
cardStyleInterpolator: ({ current, layouts }) => {
const { index } = current;
const inputRange = [index - 1, index, index + 1];
const translateX = current.progress.interpolate({
inputRange,
outputRange: [layouts.screen.width, 0, -layouts.screen.width],
});
return {
cardStyle: {
transform: [{ translateX }],
},
};
},
transitionSpec: {
open: { animation: "timing", config: { duration: 1200 } },
close: { animation: "timing", config: { duration: 1200 } },
},
}}
>
<Stack.Screen
name="Signup"
component={Signup}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Signin"
component={Signin}
options={{
headerShown: false,
}}
/>
</Stack.Navigator>
</NavigationContainer>
);
};
export default () => {
return (
<AuthProvider>
<App />
</AuthProvider>
);
};