Application Android et IOS pour l'amicale des élèves https://play.google.com/store/apps/details?id=fr.amicaleinsat.application
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MainNavigator.tsx 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. /*
  2. * Copyright (c) 2019 - 2020 Arnaud Vergnet.
  3. *
  4. * This file is part of Campus INSAT.
  5. *
  6. * Campus INSAT is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Campus INSAT is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Campus INSAT. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. import * as React from 'react';
  20. import { createStackNavigator } from '@react-navigation/stack';
  21. import i18n from 'i18n-js';
  22. import SettingsScreen from '../screens/Other/Settings/SettingsScreen';
  23. import AboutScreen from '../screens/About/AboutScreen';
  24. import AboutDependenciesScreen from '../screens/About/AboutDependenciesScreen';
  25. import DebugScreen from '../screens/About/DebugScreen';
  26. import TabNavigator from './TabNavigator';
  27. import GameMainScreen from '../screens/Game/screens/GameMainScreen';
  28. import VoteScreen from '../screens/Amicale/VoteScreen';
  29. import LoginScreen from '../screens/Amicale/LoginScreen';
  30. import SelfMenuScreen from '../screens/Services/SelfMenuScreen';
  31. import ProximoMainScreen from '../screens/Services/Proximo/ProximoMainScreen';
  32. import ProximoListScreen from '../screens/Services/Proximo/ProximoListScreen';
  33. import ProximoAboutScreen from '../screens/Services/Proximo/ProximoAboutScreen';
  34. import ProfileScreen from '../screens/Amicale/ProfileScreen';
  35. import ClubListScreen from '../screens/Amicale/Clubs/ClubListScreen';
  36. import ClubAboutScreen from '../screens/Amicale/Clubs/ClubAboutScreen';
  37. import ClubDisplayScreen from '../screens/Amicale/Clubs/ClubDisplayScreen';
  38. import BugReportScreen from '../screens/Other/FeedbackScreen';
  39. import WebsiteScreen from '../screens/Services/WebsiteScreen';
  40. import EquipmentScreen, {
  41. DeviceType,
  42. } from '../screens/Amicale/Equipment/EquipmentListScreen';
  43. import EquipmentLendScreen from '../screens/Amicale/Equipment/EquipmentRentScreen';
  44. import EquipmentConfirmScreen from '../screens/Amicale/Equipment/EquipmentConfirmScreen';
  45. import DashboardEditScreen from '../screens/Other/Settings/DashboardEditScreen';
  46. import GameStartScreen from '../screens/Game/screens/GameStartScreen';
  47. import ImageGalleryScreen from '../screens/Media/ImageGalleryScreen';
  48. export enum MainRoutes {
  49. Main = 'main',
  50. Gallery = 'gallery',
  51. Settings = 'settings',
  52. DashboardEdit = 'dashboard-edit',
  53. About = 'about',
  54. Dependencies = 'dependencies',
  55. Debug = 'debug',
  56. GameStart = 'game-start',
  57. GameMain = 'game-main',
  58. Login = 'login',
  59. SelfMenu = 'self-menu',
  60. Proximo = 'proximo',
  61. ProximoList = 'proximo-list',
  62. ProximoAbout = 'proximo-about',
  63. Profile = 'profile',
  64. ClubList = 'club-list',
  65. ClubInformation = 'club-information',
  66. ClubAbout = 'club-about',
  67. EquipmentList = 'equipment-list',
  68. EquipmentRent = 'equipment-rent',
  69. EquipmentConfirm = 'equipment-confirm',
  70. Vote = 'vote',
  71. Feedback = 'feedback',
  72. }
  73. type DefaultParams = { [key in MainRoutes]: object | undefined };
  74. export type FullParamsList = DefaultParams & {
  75. 'login': { nextScreen: string };
  76. 'equipment-confirm': {
  77. item?: DeviceType;
  78. dates: [string, string];
  79. };
  80. 'equipment-rent': { item?: DeviceType };
  81. 'gallery': { images: Array<{ url: string }> };
  82. [MainRoutes.ProximoList]: {
  83. shouldFocusSearchBar: boolean;
  84. category: number;
  85. };
  86. };
  87. // Don't know why but TS is complaining without this
  88. // See: https://stackoverflow.com/questions/63652687/interface-does-not-satisfy-the-constraint-recordstring-object-undefined
  89. export type MainStackParamsList = FullParamsList &
  90. Record<string, object | undefined>;
  91. const MainStack = createStackNavigator<MainStackParamsList>();
  92. function MainStackComponent(props: {
  93. createTabNavigator: () => React.ReactElement;
  94. }) {
  95. const { createTabNavigator } = props;
  96. return (
  97. <MainStack.Navigator
  98. initialRouteName={MainRoutes.Main}
  99. headerMode={'screen'}
  100. >
  101. <MainStack.Screen
  102. name={MainRoutes.Main}
  103. component={createTabNavigator}
  104. options={{
  105. headerShown: false,
  106. title: i18n.t('screens.home.title'),
  107. }}
  108. />
  109. <MainStack.Screen
  110. name={MainRoutes.Gallery}
  111. component={ImageGalleryScreen}
  112. options={{
  113. headerShown: false,
  114. }}
  115. />
  116. <MainStack.Screen
  117. name={MainRoutes.Settings}
  118. component={SettingsScreen}
  119. options={{
  120. title: i18n.t('screens.settings.title'),
  121. }}
  122. />
  123. <MainStack.Screen
  124. name={MainRoutes.DashboardEdit}
  125. component={DashboardEditScreen}
  126. options={{
  127. title: i18n.t('screens.settings.dashboardEdit.title'),
  128. }}
  129. />
  130. <MainStack.Screen
  131. name={MainRoutes.About}
  132. component={AboutScreen}
  133. options={{
  134. title: i18n.t('screens.about.title'),
  135. }}
  136. />
  137. <MainStack.Screen
  138. name={MainRoutes.Dependencies}
  139. component={AboutDependenciesScreen}
  140. options={{
  141. title: i18n.t('screens.about.libs'),
  142. }}
  143. />
  144. <MainStack.Screen
  145. name={MainRoutes.Debug}
  146. component={DebugScreen}
  147. options={{
  148. title: i18n.t('screens.about.debug'),
  149. }}
  150. />
  151. <MainStack.Screen
  152. name={MainRoutes.GameStart}
  153. component={GameStartScreen}
  154. options={{
  155. title: i18n.t('screens.game.title'),
  156. headerStyle: {
  157. backgroundColor: 'transparent',
  158. },
  159. }}
  160. />
  161. <MainStack.Screen
  162. name={MainRoutes.GameMain}
  163. component={GameMainScreen}
  164. options={{
  165. title: i18n.t('screens.game.title'),
  166. }}
  167. />
  168. <MainStack.Screen
  169. name={MainRoutes.Login}
  170. component={LoginScreen}
  171. options={{
  172. title: i18n.t('screens.login.title'),
  173. headerStyle: {
  174. backgroundColor: 'transparent',
  175. },
  176. }}
  177. />
  178. <MainStack.Screen
  179. name={'website'}
  180. component={WebsiteScreen}
  181. options={{
  182. title: '',
  183. }}
  184. />
  185. <MainStack.Screen
  186. name={MainRoutes.SelfMenu}
  187. component={SelfMenuScreen}
  188. options={{
  189. title: i18n.t('screens.menu.title'),
  190. }}
  191. />
  192. <MainStack.Screen
  193. name={MainRoutes.Proximo}
  194. component={ProximoMainScreen}
  195. options={{
  196. title: i18n.t('screens.proximo.title'),
  197. }}
  198. />
  199. <MainStack.Screen
  200. name={MainRoutes.ProximoList}
  201. component={ProximoListScreen}
  202. options={{
  203. title: i18n.t('screens.proximo.articleList'),
  204. }}
  205. />
  206. <MainStack.Screen
  207. name={MainRoutes.ProximoAbout}
  208. component={ProximoAboutScreen}
  209. options={{
  210. title: i18n.t('screens.proximo.title'),
  211. }}
  212. />
  213. <MainStack.Screen
  214. name={MainRoutes.Profile}
  215. component={ProfileScreen}
  216. options={{
  217. title: i18n.t('screens.profile.title'),
  218. }}
  219. />
  220. <MainStack.Screen
  221. name={MainRoutes.ClubList}
  222. component={ClubListScreen}
  223. options={{
  224. title: i18n.t('screens.clubs.title'),
  225. }}
  226. />
  227. <MainStack.Screen
  228. name={MainRoutes.ClubInformation}
  229. component={ClubDisplayScreen}
  230. options={{
  231. title: i18n.t('screens.clubs.details'),
  232. }}
  233. />
  234. <MainStack.Screen
  235. name={MainRoutes.ClubAbout}
  236. component={ClubAboutScreen}
  237. options={{
  238. title: i18n.t('screens.clubs.title'),
  239. }}
  240. />
  241. <MainStack.Screen
  242. name={MainRoutes.EquipmentList}
  243. component={EquipmentScreen}
  244. options={{
  245. title: i18n.t('screens.equipment.title'),
  246. }}
  247. />
  248. <MainStack.Screen
  249. name={MainRoutes.EquipmentRent}
  250. component={EquipmentLendScreen}
  251. options={{
  252. title: i18n.t('screens.equipment.book'),
  253. }}
  254. />
  255. <MainStack.Screen
  256. name={MainRoutes.EquipmentConfirm}
  257. component={EquipmentConfirmScreen}
  258. options={{
  259. title: i18n.t('screens.equipment.confirm'),
  260. }}
  261. />
  262. <MainStack.Screen
  263. name={MainRoutes.Vote}
  264. component={VoteScreen}
  265. options={{
  266. title: i18n.t('screens.vote.title'),
  267. }}
  268. />
  269. <MainStack.Screen
  270. name={MainRoutes.Feedback}
  271. component={BugReportScreen}
  272. options={{
  273. title: i18n.t('screens.feedback.title'),
  274. }}
  275. />
  276. </MainStack.Navigator>
  277. );
  278. }
  279. type PropsType = {
  280. defaultHomeRoute: string | null;
  281. defaultHomeData: { [key: string]: string };
  282. };
  283. export default function MainNavigator(props: PropsType) {
  284. return (
  285. <MainStackComponent
  286. createTabNavigator={() => <TabNavigator {...props} />}
  287. />
  288. );
  289. }