|
@@ -17,8 +17,6 @@
|
17
|
17
|
* along with Campus INSAT. If not, see <https://www.gnu.org/licenses/>.
|
18
|
18
|
*/
|
19
|
19
|
|
20
|
|
-// @flow
|
21
|
|
-
|
22
|
20
|
import * as React from 'react';
|
23
|
21
|
import {createStackNavigator, TransitionPresets} from '@react-navigation/stack';
|
24
|
22
|
import i18n from 'i18n-js';
|
|
@@ -40,18 +38,63 @@ import ClubListScreen from '../screens/Amicale/Clubs/ClubListScreen';
|
40
|
38
|
import ClubAboutScreen from '../screens/Amicale/Clubs/ClubAboutScreen';
|
41
|
39
|
import ClubDisplayScreen from '../screens/Amicale/Clubs/ClubDisplayScreen';
|
42
|
40
|
import {
|
43
|
|
- createScreenCollapsibleStack,
|
|
41
|
+ CreateScreenCollapsibleStack,
|
44
|
42
|
getWebsiteStack,
|
45
|
43
|
} from '../utils/CollapsibleUtils';
|
46
|
44
|
import BugReportScreen from '../screens/Other/FeedbackScreen';
|
47
|
45
|
import WebsiteScreen from '../screens/Services/WebsiteScreen';
|
48
|
|
-import EquipmentScreen from '../screens/Amicale/Equipment/EquipmentListScreen';
|
|
46
|
+import EquipmentScreen, {
|
|
47
|
+ DeviceType,
|
|
48
|
+} from '../screens/Amicale/Equipment/EquipmentListScreen';
|
49
|
49
|
import EquipmentLendScreen from '../screens/Amicale/Equipment/EquipmentRentScreen';
|
50
|
50
|
import EquipmentConfirmScreen from '../screens/Amicale/Equipment/EquipmentConfirmScreen';
|
51
|
51
|
import DashboardEditScreen from '../screens/Other/Settings/DashboardEditScreen';
|
52
|
52
|
import GameStartScreen from '../screens/Game/screens/GameStartScreen';
|
53
|
53
|
import ImageGalleryScreen from '../screens/Media/ImageGalleryScreen';
|
54
|
54
|
|
|
55
|
+export enum MainRoutes {
|
|
56
|
+ Main = 'main',
|
|
57
|
+ Gallery = 'gallery',
|
|
58
|
+ Settings = 'settings',
|
|
59
|
+ DashboardEdit = 'dashboard-edit',
|
|
60
|
+ About = 'about',
|
|
61
|
+ Dependencies = 'dependencies',
|
|
62
|
+ Debug = 'debug',
|
|
63
|
+ GameStart = 'game-start',
|
|
64
|
+ GameMain = 'game-main',
|
|
65
|
+ Login = 'login',
|
|
66
|
+ SelfMenu = 'self-menu',
|
|
67
|
+ Proximo = 'proximo',
|
|
68
|
+ ProximoList = 'proximo-list',
|
|
69
|
+ ProximoAbout = 'proximo-about',
|
|
70
|
+ Profile = 'profile',
|
|
71
|
+ ClubList = 'club-list',
|
|
72
|
+ ClubInformation = 'club-information',
|
|
73
|
+ ClubAbout = 'club-about',
|
|
74
|
+ EquipmentList = 'equipment-list',
|
|
75
|
+ EquipmentRent = 'equipment-rent',
|
|
76
|
+ EquipmentConfirm = 'equipment-confirm',
|
|
77
|
+ Vote = 'vote',
|
|
78
|
+ Feedback = 'feedback',
|
|
79
|
+}
|
|
80
|
+
|
|
81
|
+type DefaultParams = {[key in MainRoutes]: object | undefined};
|
|
82
|
+
|
|
83
|
+export interface FullParamsList extends DefaultParams {
|
|
84
|
+ login: {nextScreen: string};
|
|
85
|
+ 'equipment-confirm': {
|
|
86
|
+ item?: DeviceType;
|
|
87
|
+ dates: [string, string];
|
|
88
|
+ };
|
|
89
|
+ 'equipment-rent': {item?: DeviceType};
|
|
90
|
+ gallery: {images: Array<{url: string}>};
|
|
91
|
+}
|
|
92
|
+
|
|
93
|
+// Don't know why but TS is complaining without this
|
|
94
|
+// See: https://stackoverflow.com/questions/63652687/interface-does-not-satisfy-the-constraint-recordstring-object-undefined
|
|
95
|
+export type MainStackParamsList = FullParamsList &
|
|
96
|
+ Record<string, object | undefined>;
|
|
97
|
+
|
55
|
98
|
const modalTransition =
|
56
|
99
|
Platform.OS === 'ios'
|
57
|
100
|
? TransitionPresets.ModalPresentationIOS
|
|
@@ -63,19 +106,17 @@ const defaultScreenOptions = {
|
63
|
106
|
...TransitionPresets.SlideFromRightIOS,
|
64
|
107
|
};
|
65
|
108
|
|
66
|
|
-const MainStack = createStackNavigator();
|
|
109
|
+const MainStack = createStackNavigator<MainStackParamsList>();
|
67
|
110
|
|
68
|
|
-function MainStackComponent(props: {
|
69
|
|
- createTabNavigator: () => React.Node,
|
70
|
|
-}): React.Node {
|
|
111
|
+function MainStackComponent(props: {createTabNavigator: () => JSX.Element}) {
|
71
|
112
|
const {createTabNavigator} = props;
|
72
|
113
|
return (
|
73
|
114
|
<MainStack.Navigator
|
74
|
|
- initialRouteName="main"
|
|
115
|
+ initialRouteName={MainRoutes.Main}
|
75
|
116
|
headerMode="screen"
|
76
|
117
|
screenOptions={defaultScreenOptions}>
|
77
|
118
|
<MainStack.Screen
|
78
|
|
- name="main"
|
|
119
|
+ name={MainRoutes.Main}
|
79
|
120
|
component={createTabNavigator}
|
80
|
121
|
options={{
|
81
|
122
|
headerShown: false,
|
|
@@ -83,62 +124,62 @@ function MainStackComponent(props: {
|
83
|
124
|
}}
|
84
|
125
|
/>
|
85
|
126
|
<MainStack.Screen
|
86
|
|
- name="gallery"
|
|
127
|
+ name={MainRoutes.Gallery}
|
87
|
128
|
component={ImageGalleryScreen}
|
88
|
129
|
options={{
|
89
|
130
|
headerShown: false,
|
90
|
131
|
...modalTransition,
|
91
|
132
|
}}
|
92
|
133
|
/>
|
93
|
|
- {createScreenCollapsibleStack(
|
94
|
|
- 'settings',
|
|
134
|
+ {CreateScreenCollapsibleStack(
|
|
135
|
+ MainRoutes.Settings,
|
95
|
136
|
MainStack,
|
96
|
137
|
SettingsScreen,
|
97
|
138
|
i18n.t('screens.settings.title'),
|
98
|
139
|
)}
|
99
|
|
- {createScreenCollapsibleStack(
|
100
|
|
- 'dashboard-edit',
|
|
140
|
+ {CreateScreenCollapsibleStack(
|
|
141
|
+ MainRoutes.DashboardEdit,
|
101
|
142
|
MainStack,
|
102
|
143
|
DashboardEditScreen,
|
103
|
144
|
i18n.t('screens.settings.dashboardEdit.title'),
|
104
|
145
|
)}
|
105
|
|
- {createScreenCollapsibleStack(
|
106
|
|
- 'about',
|
|
146
|
+ {CreateScreenCollapsibleStack(
|
|
147
|
+ MainRoutes.About,
|
107
|
148
|
MainStack,
|
108
|
149
|
AboutScreen,
|
109
|
150
|
i18n.t('screens.about.title'),
|
110
|
151
|
)}
|
111
|
|
- {createScreenCollapsibleStack(
|
112
|
|
- 'dependencies',
|
|
152
|
+ {CreateScreenCollapsibleStack(
|
|
153
|
+ MainRoutes.Dependencies,
|
113
|
154
|
MainStack,
|
114
|
155
|
AboutDependenciesScreen,
|
115
|
156
|
i18n.t('screens.about.libs'),
|
116
|
157
|
)}
|
117
|
|
- {createScreenCollapsibleStack(
|
118
|
|
- 'debug',
|
|
158
|
+ {CreateScreenCollapsibleStack(
|
|
159
|
+ MainRoutes.Debug,
|
119
|
160
|
MainStack,
|
120
|
161
|
DebugScreen,
|
121
|
162
|
i18n.t('screens.about.debug'),
|
122
|
163
|
)}
|
123
|
164
|
|
124
|
|
- {createScreenCollapsibleStack(
|
125
|
|
- 'game-start',
|
|
165
|
+ {CreateScreenCollapsibleStack(
|
|
166
|
+ MainRoutes.GameStart,
|
126
|
167
|
MainStack,
|
127
|
168
|
GameStartScreen,
|
128
|
169
|
i18n.t('screens.game.title'),
|
129
|
170
|
true,
|
130
|
|
- null,
|
|
171
|
+ undefined,
|
131
|
172
|
'transparent',
|
132
|
173
|
)}
|
133
|
174
|
<MainStack.Screen
|
134
|
|
- name="game-main"
|
|
175
|
+ name={MainRoutes.GameMain}
|
135
|
176
|
component={GameMainScreen}
|
136
|
177
|
options={{
|
137
|
178
|
title: i18n.t('screens.game.title'),
|
138
|
179
|
}}
|
139
|
180
|
/>
|
140
|
|
- {createScreenCollapsibleStack(
|
141
|
|
- 'login',
|
|
181
|
+ {CreateScreenCollapsibleStack(
|
|
182
|
+ MainRoutes.Login,
|
142
|
183
|
MainStack,
|
143
|
184
|
LoginScreen,
|
144
|
185
|
i18n.t('screens.login.title'),
|
|
@@ -148,26 +189,26 @@ function MainStackComponent(props: {
|
148
|
189
|
)}
|
149
|
190
|
{getWebsiteStack('website', MainStack, WebsiteScreen, '')}
|
150
|
191
|
|
151
|
|
- {createScreenCollapsibleStack(
|
152
|
|
- 'self-menu',
|
|
192
|
+ {CreateScreenCollapsibleStack(
|
|
193
|
+ MainRoutes.SelfMenu,
|
153
|
194
|
MainStack,
|
154
|
195
|
SelfMenuScreen,
|
155
|
196
|
i18n.t('screens.menu.title'),
|
156
|
197
|
)}
|
157
|
|
- {createScreenCollapsibleStack(
|
158
|
|
- 'proximo',
|
|
198
|
+ {CreateScreenCollapsibleStack(
|
|
199
|
+ MainRoutes.Proximo,
|
159
|
200
|
MainStack,
|
160
|
201
|
ProximoMainScreen,
|
161
|
202
|
i18n.t('screens.proximo.title'),
|
162
|
203
|
)}
|
163
|
|
- {createScreenCollapsibleStack(
|
164
|
|
- 'proximo-list',
|
|
204
|
+ {CreateScreenCollapsibleStack(
|
|
205
|
+ MainRoutes.ProximoList,
|
165
|
206
|
MainStack,
|
166
|
207
|
ProximoListScreen,
|
167
|
208
|
i18n.t('screens.proximo.articleList'),
|
168
|
209
|
)}
|
169
|
|
- {createScreenCollapsibleStack(
|
170
|
|
- 'proximo-about',
|
|
210
|
+ {CreateScreenCollapsibleStack(
|
|
211
|
+ MainRoutes.ProximoAbout,
|
171
|
212
|
MainStack,
|
172
|
213
|
ProximoAboutScreen,
|
173
|
214
|
i18n.t('screens.proximo.title'),
|
|
@@ -175,60 +216,60 @@ function MainStackComponent(props: {
|
175
|
216
|
{...modalTransition},
|
176
|
217
|
)}
|
177
|
218
|
|
178
|
|
- {createScreenCollapsibleStack(
|
179
|
|
- 'profile',
|
|
219
|
+ {CreateScreenCollapsibleStack(
|
|
220
|
+ MainRoutes.Profile,
|
180
|
221
|
MainStack,
|
181
|
222
|
ProfileScreen,
|
182
|
223
|
i18n.t('screens.profile.title'),
|
183
|
224
|
)}
|
184
|
|
- {createScreenCollapsibleStack(
|
185
|
|
- 'club-list',
|
|
225
|
+ {CreateScreenCollapsibleStack(
|
|
226
|
+ MainRoutes.ClubList,
|
186
|
227
|
MainStack,
|
187
|
228
|
ClubListScreen,
|
188
|
229
|
i18n.t('screens.clubs.title'),
|
189
|
230
|
)}
|
190
|
|
- {createScreenCollapsibleStack(
|
191
|
|
- 'club-information',
|
|
231
|
+ {CreateScreenCollapsibleStack(
|
|
232
|
+ MainRoutes.ClubInformation,
|
192
|
233
|
MainStack,
|
193
|
234
|
ClubDisplayScreen,
|
194
|
235
|
i18n.t('screens.clubs.details'),
|
195
|
236
|
true,
|
196
|
237
|
{...modalTransition},
|
197
|
238
|
)}
|
198
|
|
- {createScreenCollapsibleStack(
|
199
|
|
- 'club-about',
|
|
239
|
+ {CreateScreenCollapsibleStack(
|
|
240
|
+ MainRoutes.ClubAbout,
|
200
|
241
|
MainStack,
|
201
|
242
|
ClubAboutScreen,
|
202
|
243
|
i18n.t('screens.clubs.title'),
|
203
|
244
|
true,
|
204
|
245
|
{...modalTransition},
|
205
|
246
|
)}
|
206
|
|
- {createScreenCollapsibleStack(
|
207
|
|
- 'equipment-list',
|
|
247
|
+ {CreateScreenCollapsibleStack(
|
|
248
|
+ MainRoutes.EquipmentList,
|
208
|
249
|
MainStack,
|
209
|
250
|
EquipmentScreen,
|
210
|
251
|
i18n.t('screens.equipment.title'),
|
211
|
252
|
)}
|
212
|
|
- {createScreenCollapsibleStack(
|
213
|
|
- 'equipment-rent',
|
|
253
|
+ {CreateScreenCollapsibleStack(
|
|
254
|
+ MainRoutes.EquipmentRent,
|
214
|
255
|
MainStack,
|
215
|
256
|
EquipmentLendScreen,
|
216
|
257
|
i18n.t('screens.equipment.book'),
|
217
|
258
|
)}
|
218
|
|
- {createScreenCollapsibleStack(
|
219
|
|
- 'equipment-confirm',
|
|
259
|
+ {CreateScreenCollapsibleStack(
|
|
260
|
+ MainRoutes.EquipmentConfirm,
|
220
|
261
|
MainStack,
|
221
|
262
|
EquipmentConfirmScreen,
|
222
|
263
|
i18n.t('screens.equipment.confirm'),
|
223
|
264
|
)}
|
224
|
|
- {createScreenCollapsibleStack(
|
225
|
|
- 'vote',
|
|
265
|
+ {CreateScreenCollapsibleStack(
|
|
266
|
+ MainRoutes.Vote,
|
226
|
267
|
MainStack,
|
227
|
268
|
VoteScreen,
|
228
|
269
|
i18n.t('screens.vote.title'),
|
229
|
270
|
)}
|
230
|
|
- {createScreenCollapsibleStack(
|
231
|
|
- 'feedback',
|
|
271
|
+ {CreateScreenCollapsibleStack(
|
|
272
|
+ MainRoutes.Feedback,
|
232
|
273
|
MainStack,
|
233
|
274
|
BugReportScreen,
|
234
|
275
|
i18n.t('screens.feedback.title'),
|
|
@@ -238,25 +279,10 @@ function MainStackComponent(props: {
|
238
|
279
|
}
|
239
|
280
|
|
240
|
281
|
type PropsType = {
|
241
|
|
- defaultHomeRoute: string | null,
|
242
|
|
- // eslint-disable-next-line flowtype/no-weak-types
|
243
|
|
- defaultHomeData: {[key: string]: string},
|
|
282
|
+ defaultHomeRoute: string | null;
|
|
283
|
+ defaultHomeData: {[key: string]: string};
|
244
|
284
|
};
|
245
|
285
|
|
246
|
|
-export default class MainNavigator extends React.Component<PropsType> {
|
247
|
|
- createTabNavigator: () => React.Node;
|
248
|
|
-
|
249
|
|
- constructor(props: PropsType) {
|
250
|
|
- super(props);
|
251
|
|
- this.createTabNavigator = (): React.Node => (
|
252
|
|
- <TabNavigator
|
253
|
|
- defaultHomeRoute={props.defaultHomeRoute}
|
254
|
|
- defaultHomeData={props.defaultHomeData}
|
255
|
|
- />
|
256
|
|
- );
|
257
|
|
- }
|
258
|
|
-
|
259
|
|
- render(): React.Node {
|
260
|
|
- return <MainStackComponent createTabNavigator={this.createTabNavigator} />;
|
261
|
|
- }
|
|
286
|
+export default function MainNavigator(props: PropsType) {
|
|
287
|
+ return <MainStackComponent createTabNavigator={() => TabNavigator(props)} />;
|
262
|
288
|
}
|