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 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. import Test from '../screens/Test';
  49. export enum MainRoutes {
  50. Main = 'main',
  51. Gallery = 'gallery',
  52. Settings = 'settings',
  53. DashboardEdit = 'dashboard-edit',
  54. About = 'about',
  55. Dependencies = 'dependencies',
  56. Debug = 'debug',
  57. GameStart = 'game-start',
  58. GameMain = 'game-main',
  59. Login = 'login',
  60. SelfMenu = 'self-menu',
  61. Proximo = 'proximo',
  62. ProximoList = 'proximo-list',
  63. ProximoAbout = 'proximo-about',
  64. Profile = 'profile',
  65. ClubList = 'club-list',
  66. ClubInformation = 'club-information',
  67. ClubAbout = 'club-about',
  68. EquipmentList = 'equipment-list',
  69. EquipmentRent = 'equipment-rent',
  70. EquipmentConfirm = 'equipment-confirm',
  71. Vote = 'vote',
  72. Feedback = 'feedback',
  73. }
  74. type DefaultParams = { [key in MainRoutes]: object | undefined };
  75. export type FullParamsList = DefaultParams & {
  76. 'login': { nextScreen: string };
  77. 'equipment-confirm': {
  78. item?: DeviceType;
  79. dates: [string, string];
  80. };
  81. 'equipment-rent': { item?: DeviceType };
  82. 'gallery': { images: Array<{ url: string }> };
  83. [MainRoutes.ProximoList]: {
  84. shouldFocusSearchBar: boolean;
  85. category: number;
  86. };
  87. };
  88. // Don't know why but TS is complaining without this
  89. // See: https://stackoverflow.com/questions/63652687/interface-does-not-satisfy-the-constraint-recordstring-object-undefined
  90. export type MainStackParamsList = FullParamsList &
  91. Record<string, object | undefined>;
  92. const MainStack = createStackNavigator<MainStackParamsList>();
  93. function MainStackComponent(props: {
  94. createTabNavigator: () => React.ReactElement;
  95. }) {
  96. const { createTabNavigator } = props;
  97. return (
  98. <MainStack.Navigator initialRouteName={MainRoutes.Main} headerMode="screen">
  99. <MainStack.Screen name={'test'} component={Test} />
  100. <MainStack.Screen
  101. name={MainRoutes.Main}
  102. component={createTabNavigator}
  103. options={{
  104. headerShown: false,
  105. title: i18n.t('screens.home.title'),
  106. }}
  107. />
  108. <MainStack.Screen
  109. name={MainRoutes.Gallery}
  110. component={ImageGalleryScreen}
  111. options={{
  112. headerShown: false,
  113. }}
  114. />
  115. <MainStack.Screen
  116. name={MainRoutes.Settings}
  117. component={SettingsScreen}
  118. options={{
  119. title: i18n.t('screens.settings.title'),
  120. }}
  121. />
  122. <MainStack.Screen
  123. name={MainRoutes.DashboardEdit}
  124. component={DashboardEditScreen}
  125. options={{
  126. title: i18n.t('screens.settings.dashboardEdit.title'),
  127. }}
  128. />
  129. <MainStack.Screen
  130. name={MainRoutes.About}
  131. component={AboutScreen}
  132. options={{
  133. title: i18n.t('screens.about.title'),
  134. }}
  135. />
  136. <MainStack.Screen
  137. name={MainRoutes.Dependencies}
  138. component={AboutDependenciesScreen}
  139. options={{
  140. title: i18n.t('screens.about.libs'),
  141. }}
  142. />
  143. <MainStack.Screen
  144. name={MainRoutes.Debug}
  145. component={DebugScreen}
  146. options={{
  147. title: i18n.t('screens.about.debug'),
  148. }}
  149. />
  150. <MainStack.Screen
  151. name={MainRoutes.GameStart}
  152. component={GameStartScreen}
  153. options={{
  154. title: i18n.t('screens.game.title'),
  155. headerStyle: {
  156. backgroundColor: 'transparent',
  157. },
  158. }}
  159. />
  160. <MainStack.Screen
  161. name={MainRoutes.GameMain}
  162. component={GameMainScreen}
  163. options={{
  164. title: i18n.t('screens.game.title'),
  165. }}
  166. />
  167. <MainStack.Screen
  168. name={MainRoutes.Login}
  169. component={LoginScreen}
  170. options={{
  171. title: i18n.t('screens.login.title'),
  172. headerStyle: {
  173. backgroundColor: 'transparent',
  174. },
  175. }}
  176. />
  177. <MainStack.Screen
  178. name={'website'}
  179. component={WebsiteScreen}
  180. options={{
  181. title: '',
  182. }}
  183. />
  184. <MainStack.Screen
  185. name={MainRoutes.SelfMenu}
  186. component={SelfMenuScreen}
  187. options={{
  188. title: i18n.t('screens.menu.title'),
  189. }}
  190. />
  191. <MainStack.Screen
  192. name={MainRoutes.Proximo}
  193. component={ProximoMainScreen}
  194. options={{
  195. title: i18n.t('screens.proximo.title'),
  196. }}
  197. />
  198. <MainStack.Screen
  199. name={MainRoutes.ProximoList}
  200. component={ProximoListScreen}
  201. options={{
  202. title: i18n.t('screens.proximo.articleList'),
  203. }}
  204. />
  205. <MainStack.Screen
  206. name={MainRoutes.ProximoAbout}
  207. component={ProximoAboutScreen}
  208. options={{
  209. title: i18n.t('screens.proximo.title'),
  210. }}
  211. />
  212. <MainStack.Screen
  213. name={MainRoutes.Profile}
  214. component={ProfileScreen}
  215. options={{
  216. title: i18n.t('screens.profile.title'),
  217. }}
  218. />
  219. <MainStack.Screen
  220. name={MainRoutes.ClubList}
  221. component={ClubListScreen}
  222. options={{
  223. title: i18n.t('screens.clubs.title'),
  224. }}
  225. />
  226. <MainStack.Screen
  227. name={MainRoutes.ClubInformation}
  228. component={ClubDisplayScreen}
  229. options={{
  230. title: i18n.t('screens.clubs.details'),
  231. }}
  232. />
  233. <MainStack.Screen
  234. name={MainRoutes.ClubAbout}
  235. component={ClubAboutScreen}
  236. options={{
  237. title: i18n.t('screens.clubs.title'),
  238. }}
  239. />
  240. <MainStack.Screen
  241. name={MainRoutes.EquipmentList}
  242. component={EquipmentScreen}
  243. options={{
  244. title: i18n.t('screens.equipment.title'),
  245. }}
  246. />
  247. <MainStack.Screen
  248. name={MainRoutes.EquipmentRent}
  249. component={EquipmentLendScreen}
  250. options={{
  251. title: i18n.t('screens.equipment.book'),
  252. }}
  253. />
  254. <MainStack.Screen
  255. name={MainRoutes.EquipmentConfirm}
  256. component={EquipmentConfirmScreen}
  257. options={{
  258. title: i18n.t('screens.equipment.confirm'),
  259. }}
  260. />
  261. <MainStack.Screen
  262. name={MainRoutes.Vote}
  263. component={VoteScreen}
  264. options={{
  265. title: i18n.t('screens.vote.title'),
  266. }}
  267. />
  268. <MainStack.Screen
  269. name={MainRoutes.Feedback}
  270. component={BugReportScreen}
  271. options={{
  272. title: i18n.t('screens.feedback.title'),
  273. }}
  274. />
  275. </MainStack.Navigator>
  276. );
  277. }
  278. type PropsType = {
  279. defaultHomeRoute: string | null;
  280. defaultHomeData: { [key: string]: string };
  281. };
  282. export default function MainNavigator(props: PropsType) {
  283. return (
  284. <MainStackComponent
  285. createTabNavigator={() => <TabNavigator {...props} />}
  286. />
  287. );
  288. }