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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. import {StackNavigationProp} from "@react-navigation/stack";
  10. import type {feedItem} from "./HomeScreen";
  11. type Props = {
  12. navigation: StackNavigationProp,
  13. route: { params: { data: feedItem, date: string } }
  14. };
  15. const ICON_AMICALE = require('../../../assets/amicale.png');
  16. const NAME_AMICALE = 'Amicale INSA Toulouse';
  17. /**
  18. * Class defining a feed item page.
  19. */
  20. class FeedItemScreen extends React.Component<Props> {
  21. displayData: feedItem;
  22. date: string;
  23. constructor(props) {
  24. super(props);
  25. this.displayData = props.route.params.data;
  26. this.date = props.route.params.date;
  27. }
  28. componentDidMount() {
  29. this.props.navigation.setOptions({
  30. headerRight: this.getHeaderButton,
  31. });
  32. }
  33. /**
  34. * Opens the feed item out link in browser or compatible app
  35. */
  36. onOutLinkPress = () => {
  37. Linking.openURL(this.displayData.permalink_url);
  38. };
  39. /**
  40. * Gets the out link header button
  41. *
  42. * @returns {*}
  43. */
  44. getHeaderButton = () => {
  45. return <MaterialHeaderButtons>
  46. <Item title="main" iconName={'facebook'} color={"#2e88fe"} onPress={this.onOutLinkPress}/>
  47. </MaterialHeaderButtons>;
  48. };
  49. /**
  50. * Gets the Amicale INSA avatar
  51. *
  52. * @returns {*}
  53. */
  54. getAvatar() {
  55. return (
  56. <Avatar.Image size={48} source={ICON_AMICALE}
  57. style={{backgroundColor: 'transparent'}}/>
  58. );
  59. }
  60. render() {
  61. const hasImage = this.displayData.full_picture !== '' && this.displayData.full_picture != null;
  62. return (
  63. <ScrollView style={{margin: 5,}}>
  64. <Card.Title
  65. title={NAME_AMICALE}
  66. subtitle={this.date}
  67. left={this.getAvatar}
  68. />
  69. {hasImage ?
  70. <View style={{marginLeft: 'auto', marginRight: 'auto'}}>
  71. <ImageModal
  72. resizeMode="contain"
  73. imageBackgroundColor={"#000"}
  74. style={{
  75. width: 250,
  76. height: 250,
  77. }}
  78. source={{
  79. uri: this.displayData.full_picture,
  80. }}
  81. /></View> : null}
  82. <Card.Content style={{paddingBottom: CustomTabBar.TAB_BAR_HEIGHT + 20}}>
  83. {this.displayData.message !== undefined ?
  84. <Autolink
  85. text={this.displayData.message}
  86. hashtag="facebook"
  87. component={Text}
  88. /> : null
  89. }
  90. </Card.Content>
  91. </ScrollView>
  92. );
  93. }
  94. }
  95. export default withTheme(FeedItemScreen);