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.

FeedItemScreen.js 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // @flow
  2. import * as React from 'react';
  3. import {Linking, ScrollView, View} from 'react-native';
  4. import {Avatar, Card, Text, withTheme} from 'react-native-paper';
  5. import ImageModal from 'react-native-image-modal';
  6. import Autolink from "react-native-autolink";
  7. import MaterialHeaderButtons, {Item} from "../../components/Overrides/CustomHeaderButton";
  8. import CustomTabBar from "../../components/Tabbar/CustomTabBar";
  9. type Props = {
  10. navigation: Object,
  11. route: Object
  12. };
  13. const ICON_AMICALE = require('../../../assets/amicale.png');
  14. const NAME_AMICALE = 'Amicale INSA Toulouse';
  15. /**
  16. * Class defining a planning event information page.
  17. */
  18. class FeedItemScreen extends React.Component<Props> {
  19. displayData: Object;
  20. date: string;
  21. colors: Object;
  22. constructor(props) {
  23. super(props);
  24. this.colors = props.theme.colors;
  25. this.displayData = this.props.route.params.data;
  26. this.date = this.props.route.params.date;
  27. }
  28. componentDidMount() {
  29. this.props.navigation.setOptions({
  30. headerRight: this.getHeaderButton,
  31. });
  32. }
  33. onOutLinkPress = () => {
  34. Linking.openURL(this.displayData.permalink_url);
  35. };
  36. getHeaderButton = () => {
  37. return <MaterialHeaderButtons>
  38. <Item title="main" iconName={'facebook'} onPress={this.onOutLinkPress}/>
  39. </MaterialHeaderButtons>;
  40. };
  41. getAvatar() {
  42. return (
  43. <Avatar.Image size={48} source={ICON_AMICALE}
  44. style={{backgroundColor: 'transparent'}}/>
  45. );
  46. }
  47. getContent() {
  48. const hasImage = this.displayData.full_picture !== '' && this.displayData.full_picture !== undefined;
  49. return (
  50. <ScrollView style={{margin: 5,}}>
  51. <Card.Title
  52. title={NAME_AMICALE}
  53. subtitle={this.date}
  54. left={this.getAvatar}
  55. />
  56. {hasImage ?
  57. <View style={{marginLeft: 'auto', marginRight: 'auto'}}>
  58. <ImageModal
  59. resizeMode="contain"
  60. imageBackgroundColor={"#000"}
  61. style={{
  62. width: 250,
  63. height: 250,
  64. }}
  65. source={{
  66. uri: this.displayData.full_picture,
  67. }}
  68. /></View> : null}
  69. <Card.Content style={{paddingBottom: CustomTabBar.TAB_BAR_HEIGHT + 20}}>
  70. {this.displayData.message !== undefined ?
  71. <Autolink
  72. text={this.displayData.message}
  73. hashtag="facebook"
  74. component={Text}
  75. /> : null
  76. }
  77. </Card.Content>
  78. </ScrollView>
  79. );
  80. }
  81. render() {
  82. return this.getContent();
  83. }
  84. }
  85. export default withTheme(FeedItemScreen);