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.

ClubDisplayScreen.js 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 {Avatar, Card, Chip, Paragraph, withTheme} from 'react-native-paper';
  7. import ImageModal from 'react-native-image-modal';
  8. import i18n from "i18n-js";
  9. type Props = {
  10. navigation: Object,
  11. route: Object
  12. };
  13. type State = {
  14. imageModalVisible: boolean,
  15. };
  16. function openWebLink(event, link) {
  17. Linking.openURL(link).catch((err) => console.error('Error opening link', err));
  18. }
  19. /**
  20. * Class defining a planning event information page.
  21. */
  22. class ClubDisplayScreen extends React.Component<Props, State> {
  23. displayData = this.props.route.params['data'];
  24. categories = this.props.route.params['categories'];
  25. colors: Object;
  26. state = {
  27. imageModalVisible: false,
  28. };
  29. constructor(props) {
  30. super(props);
  31. this.colors = props.theme.colors;
  32. }
  33. componentDidMount(): * {
  34. this.props.navigation.setOptions({title: this.displayData.name})
  35. }
  36. getCategoryName(id: number) {
  37. for (let i = 0; i < this.categories.length; i++) {
  38. if (id === this.categories[i].id)
  39. return this.categories[i].name;
  40. }
  41. return "";
  42. }
  43. getCategoriesRender(categories: Array<number|null>) {
  44. let final = [];
  45. for (let i = 0; i < categories.length; i++) {
  46. if (categories[i] !== null)
  47. final.push(<Chip style={{marginRight: 5}}>{this.getCategoryName(categories[i])}</Chip>);
  48. }
  49. return <View style={{flexDirection: 'row', marginTop: 5}}>{final}</View>;
  50. }
  51. getResponsiblesRender(resp: Array<string>) {
  52. let final = [];
  53. for (let i = 0; i < resp.length; i++) {
  54. final.push(<Paragraph>{resp[i]}</Paragraph>)
  55. }
  56. return (
  57. <Card style={{marginTop: 10, marginBottom: 10}}>
  58. <Card.Title
  59. title={i18n.t('clubs.managers')}
  60. subtitle={i18n.t('clubs.managersSubtitle')}
  61. left={(props) => <Avatar.Icon
  62. style={{backgroundColor: 'transparent'}}
  63. {...props}
  64. icon="account-tie"/>}
  65. />
  66. <Card.Content>
  67. {final}
  68. </Card.Content>
  69. </Card>
  70. );
  71. }
  72. render() {
  73. return (
  74. <ScrollView style={{paddingLeft: 5, paddingRight: 5}}>
  75. {this.getCategoriesRender(this.displayData.category)}
  76. {this.displayData.logo !== null ?
  77. <View style={{
  78. marginLeft: 'auto',
  79. marginRight: 'auto',
  80. marginTop: 10,
  81. marginBottom: 10,
  82. }}>
  83. <ImageModal
  84. resizeMode="contain"
  85. imageBackgroundColor={this.colors.background}
  86. style={{
  87. width: 300,
  88. height: 300,
  89. }}
  90. source={{
  91. uri: this.displayData.logo,
  92. }}
  93. /></View>
  94. : <View/>}
  95. {this.displayData.description !== null ?
  96. // Surround description with div to allow text styling if the description is not html
  97. <Card.Content>
  98. <HTML html={"<div>" + this.displayData.description + "</div>"}
  99. tagsStyles={{
  100. p: {color: this.colors.text,},
  101. div: {color: this.colors.text}
  102. }}
  103. onLinkPress={openWebLink}/>
  104. </Card.Content>
  105. : <View/>}
  106. {this.getResponsiblesRender(this.displayData.responsibles)}
  107. </ScrollView>
  108. );
  109. }
  110. }
  111. export default withTheme(ClubDisplayScreen);