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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // @flow
  2. import * as React from 'react';
  3. import {Image, 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. type Props = {
  10. navigation: Object,
  11. route: Object
  12. };
  13. function openWebLink(event, link) {
  14. Linking.openURL(link).catch((err) => console.error('Error opening link', err));
  15. }
  16. /**
  17. * Class defining a planning event information page.
  18. */
  19. class PlanningDisplayScreen extends React.Component<Props> {
  20. displayData = this.props.route.params['data'];
  21. colors: Object;
  22. constructor(props) {
  23. super(props);
  24. this.colors = props.theme.colors;
  25. }
  26. render() {
  27. // console.log("rendering planningDisplayScreen");
  28. let subtitle = getFormattedEventTime(
  29. this.displayData["date_begin"], this.displayData["date_end"]);
  30. let dateString = getDateOnlyString(this.displayData["date_begin"]);
  31. if (dateString !== null)
  32. subtitle += ' | ' + DateManager.getInstance().getTranslatedDate(dateString);
  33. return (
  34. <ScrollView style={{paddingLeft: 5, paddingRight: 5}}>
  35. <Card.Title
  36. title={this.displayData.title}
  37. subtitle={subtitle}
  38. />
  39. {this.displayData.logo !== null ?
  40. <View style={{width: '100%', height: 300}}>
  41. <Image style={{flex: 1, resizeMode: "contain"}}
  42. source={{uri: this.displayData.logo}}/>
  43. </View>
  44. : <View/>}
  45. {this.displayData.description !== null ?
  46. // Surround description with div to allow text styling if the description is not html
  47. <Card.Content>
  48. <HTML html={"<div>" + this.displayData.description + "</div>"}
  49. tagsStyles={{
  50. p: {color: this.colors.text,},
  51. div: {color: this.colors.text}
  52. }}
  53. onLinkPress={openWebLink}/>
  54. </Card.Content>
  55. : <View/>}
  56. </ScrollView>
  57. );
  58. }
  59. }
  60. export default withTheme(PlanningDisplayScreen);