Application Android et IOS pour l'amicale des élèves
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.

ServicesSectionScreen.tsx 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 {Collapsible} from 'react-navigation-collapsible';
  21. import {CommonActions} from '@react-navigation/native';
  22. import {StackNavigationProp} from '@react-navigation/stack';
  23. import CardList from '../../components/Lists/CardList/CardList';
  24. import type {ServiceCategoryType} from '../../managers/ServicesManager';
  25. type PropsType = {
  26. navigation: StackNavigationProp<any>;
  27. route: {params: {data: ServiceCategoryType | null}};
  28. collapsibleStack: Collapsible;
  29. };
  30. class ServicesSectionScreen extends React.Component<PropsType> {
  31. finalDataset: null | ServiceCategoryType;
  32. constructor(props: PropsType) {
  33. super(props);
  34. this.finalDataset = null;
  35. this.handleNavigationParams();
  36. }
  37. /**
  38. * Recover the list to display from navigation parameters
  39. */
  40. handleNavigationParams() {
  41. const {props} = this;
  42. if (props.route.params.data) {
  43. this.finalDataset = props.route.params.data;
  44. // reset params to prevent infinite loop
  45. props.navigation.dispatch(CommonActions.setParams({data: null}));
  46. props.navigation.setOptions({
  47. headerTitle: this.finalDataset.title,
  48. });
  49. }
  50. }
  51. render() {
  52. if (!this.finalDataset) {
  53. return null;
  54. }
  55. return (
  56. <CardList dataset={this.finalDataset.content} isHorizontal={false} />
  57. );
  58. }
  59. }
  60. export default ServicesSectionScreen;