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.

FeedItem.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import * as React from 'react';
  2. import {Avatar, Button, Card, Text} from 'react-native-paper';
  3. import {View} from "react-native";
  4. import Autolink from "react-native-autolink";
  5. import i18n from "i18n-js";
  6. import ImageModal from 'react-native-image-modal';
  7. const ICON_AMICALE = require('../../../assets/amicale.png');
  8. type Props = {
  9. navigation: Object,
  10. theme: Object,
  11. title: string,
  12. subtitle: string,
  13. height: number,
  14. }
  15. /**
  16. * Component used to display a feed item
  17. */
  18. class FeedItem extends React.Component<Props> {
  19. shouldComponentUpdate() {
  20. return false;
  21. }
  22. /**
  23. * Gets the amicale INSAT logo
  24. *
  25. * @return {*}
  26. */
  27. getAvatar() {
  28. return (
  29. <Avatar.Image size={48} source={ICON_AMICALE}
  30. style={{backgroundColor: 'transparent'}}/>
  31. );
  32. }
  33. onPress = () => {
  34. this.props.navigation.navigate('feed-information',
  35. {
  36. data: this.props.item,
  37. date: this.props.subtitle
  38. })
  39. };
  40. render() {
  41. const item = this.props.item;
  42. const hasImage = item.full_picture !== '' && item.full_picture !== undefined;
  43. const cardMargin = 10;
  44. const cardHeight = this.props.height - 2 * cardMargin;
  45. const imageSize = 250;
  46. const titleHeight = 80;
  47. const actionsHeight = 60;
  48. const textHeight = hasImage
  49. ? cardHeight - titleHeight - actionsHeight - imageSize
  50. : cardHeight - titleHeight - actionsHeight;
  51. return (
  52. <Card
  53. style={{
  54. margin: cardMargin,
  55. height: cardHeight,
  56. }}
  57. onPress={this.onPress}
  58. >
  59. <Card.Title
  60. title={this.props.title}
  61. subtitle={this.props.subtitle}
  62. left={this.getAvatar}
  63. style={{height: titleHeight}}
  64. />
  65. {hasImage ?
  66. <View style={{marginLeft: 'auto', marginRight: 'auto'}}>
  67. <ImageModal
  68. resizeMode="contain"
  69. imageBackgroundColor={"#000"}
  70. style={{
  71. width: imageSize,
  72. height: imageSize,
  73. }}
  74. source={{
  75. uri: item.full_picture,
  76. }}
  77. /></View> : null}
  78. <Card.Content>
  79. {item.message !== undefined ?
  80. <Autolink
  81. text={item.message}
  82. hashtag="facebook"
  83. component={Text}
  84. style={{height: textHeight}}
  85. /> : null
  86. }
  87. </Card.Content>
  88. <Card.Actions style={{height: actionsHeight}}>
  89. <Button
  90. onPress={this.onPress}
  91. icon={'plus'}
  92. style={{marginLeft: 'auto'}}>
  93. {i18n.t('homeScreen.dashboard.seeMore')}
  94. </Button>
  95. </Card.Actions>
  96. </Card>
  97. );
  98. }
  99. }
  100. export default FeedItem;