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.

FeedItemScreen.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // @flow
  2. import * as React from 'react';
  3. import {Linking} from 'react-native';
  4. import {Avatar, Card, Text, withTheme} from 'react-native-paper';
  5. import Autolink from 'react-native-autolink';
  6. import {StackNavigationProp} from '@react-navigation/stack';
  7. import MaterialHeaderButtons, {
  8. Item,
  9. } from '../../components/Overrides/CustomHeaderButton';
  10. import CustomTabBar from '../../components/Tabbar/CustomTabBar';
  11. import type {FeedItemType} from './HomeScreen';
  12. import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView';
  13. import ImageGalleryButton from '../../components/Media/ImageGalleryButton';
  14. type PropsType = {
  15. navigation: StackNavigationProp,
  16. route: {params: {data: FeedItemType, date: string}},
  17. };
  18. const ICON_AMICALE = require('../../../assets/amicale.png');
  19. const NAME_AMICALE = 'Amicale INSA Toulouse';
  20. /**
  21. * Class defining a feed item page.
  22. */
  23. class FeedItemScreen extends React.Component<PropsType> {
  24. displayData: FeedItemType;
  25. date: string;
  26. constructor(props: PropsType) {
  27. super(props);
  28. this.displayData = props.route.params.data;
  29. this.date = props.route.params.date;
  30. }
  31. componentDidMount() {
  32. const {props} = this;
  33. props.navigation.setOptions({
  34. headerRight: this.getHeaderButton,
  35. });
  36. }
  37. /**
  38. * Opens the feed item out link in browser or compatible app
  39. */
  40. onOutLinkPress = () => {
  41. Linking.openURL(this.displayData.url);
  42. };
  43. /**
  44. * Gets the out link header button
  45. *
  46. * @returns {*}
  47. */
  48. getHeaderButton = (): React.Node => {
  49. return (
  50. <MaterialHeaderButtons>
  51. <Item
  52. title="main"
  53. iconName="facebook"
  54. color="#2e88fe"
  55. onPress={this.onOutLinkPress}
  56. />
  57. </MaterialHeaderButtons>
  58. );
  59. };
  60. render(): React.Node {
  61. const {navigation} = this.props;
  62. const hasImage =
  63. this.displayData.image !== '' && this.displayData.image != null;
  64. return (
  65. <CollapsibleScrollView style={{margin: 5}} hasTab>
  66. <Card.Title
  67. title={NAME_AMICALE}
  68. subtitle={this.date}
  69. left={(): React.Node => (
  70. <Avatar.Image
  71. size={48}
  72. source={ICON_AMICALE}
  73. style={{backgroundColor: 'transparent'}}
  74. />
  75. )}
  76. />
  77. {hasImage ? (
  78. <ImageGalleryButton
  79. navigation={navigation}
  80. images={[{url: this.displayData.image}]}
  81. style={{
  82. width: 250,
  83. height: 250,
  84. marginLeft: 'auto',
  85. marginRight: 'auto',
  86. }}
  87. />
  88. ) : null}
  89. <Card.Content style={{paddingBottom: CustomTabBar.TAB_BAR_HEIGHT + 20}}>
  90. {this.displayData.message !== undefined ? (
  91. <Autolink
  92. text={this.displayData.message}
  93. hashtag="facebook"
  94. component={Text}
  95. />
  96. ) : null}
  97. </Card.Content>
  98. </CollapsibleScrollView>
  99. );
  100. }
  101. }
  102. export default withTheme(FeedItemScreen);