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.

PlanningDisplayScreen.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // @flow
  2. import * as React from 'react';
  3. import {ScrollView, View} from 'react-native';
  4. import HTML from "react-native-render-html";
  5. import {Linking} from "expo";
  6. import {getDateOnlyString, getFormattedEventTime} from '../../utils/Planning';
  7. import {Card, withTheme} from 'react-native-paper';
  8. import DateManager from "../../managers/DateManager";
  9. import ImageModal from 'react-native-image-modal';
  10. type Props = {
  11. navigation: Object,
  12. route: Object
  13. };
  14. type State = {
  15. };
  16. function openWebLink(event, link) {
  17. Linking.openURL(link).catch((err) => console.error('Error opening link', err));
  18. }
  19. const FAKE_EVENT = {
  20. "id": 142,
  21. "title": "Soir\u00e9e Impact'INSA",
  22. "logo": null,
  23. "date_begin": "2020-04-22 19:00",
  24. "date_end": "2020-04-22 00:00",
  25. "description": "<p>R\u00e9servation salle de boom + PK pour la soir\u00e9e Impact'Insa<\/p>",
  26. "club": "Impact Insa",
  27. "category_id": 10,
  28. "url": "https:\/\/www.amicale-insat.fr\/event\/142\/view"
  29. };
  30. /**
  31. * Class defining a planning event information page.
  32. */
  33. class PlanningDisplayScreen extends React.Component<Props, State> {
  34. displayData: Object;
  35. shouldFetchData: boolean;
  36. eventId: number;
  37. colors: Object;
  38. state = {
  39. };
  40. constructor(props) {
  41. super(props);
  42. this.colors = props.theme.colors;
  43. if (this.props.route.params.data !== undefined) {
  44. this.displayData = this.props.route.params.data;
  45. this.eventId = this.props.route.params.data.eventId;
  46. this.shouldFetchData = false;
  47. } else {
  48. this.displayData = FAKE_EVENT;
  49. this.eventId = this.props.route.params.eventId;
  50. this.shouldFetchData = true;
  51. console.log(this.eventId);
  52. }
  53. }
  54. render() {
  55. // console.log("rendering planningDisplayScreen");
  56. let subtitle = getFormattedEventTime(
  57. this.displayData["date_begin"], this.displayData["date_end"]);
  58. let dateString = getDateOnlyString(this.displayData["date_begin"]);
  59. if (dateString !== null)
  60. subtitle += ' | ' + DateManager.getInstance().getTranslatedDate(dateString);
  61. return (
  62. <ScrollView style={{paddingLeft: 5, paddingRight: 5}}>
  63. <Card.Title
  64. title={this.displayData.title}
  65. subtitle={subtitle}
  66. />
  67. {this.displayData.logo !== null ?
  68. <View style={{marginLeft: 'auto', marginRight: 'auto'}}>
  69. <ImageModal
  70. resizeMode="contain"
  71. imageBackgroundColor={this.colors.background}
  72. style={{
  73. width: 300,
  74. height: 300,
  75. }}
  76. source={{
  77. uri: this.displayData.logo,
  78. }}
  79. /></View>
  80. : <View/>}
  81. {this.displayData.description !== null ?
  82. // Surround description with div to allow text styling if the description is not html
  83. <Card.Content>
  84. <HTML html={"<div>" + this.displayData.description + "</div>"}
  85. tagsStyles={{
  86. p: {color: this.colors.text,},
  87. div: {color: this.colors.text}
  88. }}
  89. onLinkPress={openWebLink}/>
  90. </Card.Content>
  91. : <View/>}
  92. </ScrollView>
  93. );
  94. }
  95. }
  96. export default withTheme(PlanningDisplayScreen);