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

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