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.

PlanningDisplayScreen.js 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. imageModalVisible: boolean,
  16. };
  17. function openWebLink(event, link) {
  18. Linking.openURL(link).catch((err) => console.error('Error opening link', err));
  19. }
  20. /**
  21. * Class defining a planning event information page.
  22. */
  23. class PlanningDisplayScreen extends React.Component<Props, State> {
  24. displayData = this.props.route.params['data'];
  25. colors: Object;
  26. state = {
  27. imageModalVisible: false,
  28. };
  29. constructor(props) {
  30. super(props);
  31. this.colors = props.theme.colors;
  32. }
  33. showImageModal = () => {
  34. this.setState({imageModalVisible: true});
  35. };
  36. hideImageModal = () => {
  37. this.setState({imageModalVisible: false});
  38. };
  39. render() {
  40. // console.log("rendering planningDisplayScreen");
  41. let subtitle = getFormattedEventTime(
  42. this.displayData["date_begin"], this.displayData["date_end"]);
  43. let dateString = getDateOnlyString(this.displayData["date_begin"]);
  44. if (dateString !== null)
  45. subtitle += ' | ' + DateManager.getInstance().getTranslatedDate(dateString);
  46. return (
  47. <ScrollView style={{paddingLeft: 5, paddingRight: 5}}>
  48. <Card.Title
  49. title={this.displayData.title}
  50. subtitle={subtitle}
  51. />
  52. {this.displayData.logo !== null ?
  53. <View style={{marginLeft: 'auto', marginRight: 'auto'}}>
  54. <ImageModal
  55. resizeMode="contain"
  56. imageBackgroundColor={this.colors.background}
  57. style={{
  58. width: 300,
  59. height: 300,
  60. }}
  61. source={{
  62. uri: this.displayData.logo,
  63. }}
  64. /></View>
  65. : <View/>}
  66. {this.displayData.description !== null ?
  67. // Surround description with div to allow text styling if the description is not html
  68. <Card.Content>
  69. <HTML html={"<div>" + this.displayData.description + "</div>"}
  70. tagsStyles={{
  71. p: {color: this.colors.text,},
  72. div: {color: this.colors.text}
  73. }}
  74. onLinkPress={openWebLink}/>
  75. </Card.Content>
  76. : <View/>}
  77. </ScrollView>
  78. );
  79. }
  80. }
  81. export default withTheme(PlanningDisplayScreen);