// @flow import * as React from 'react'; import {Button, Card, Text, TouchableRipple} from 'react-native-paper'; import {Image, View} from 'react-native'; import Autolink from 'react-native-autolink'; import i18n from 'i18n-js'; import ImageModal from 'react-native-image-modal'; import {StackNavigationProp} from '@react-navigation/stack'; import type {FeedItemType} from '../../screens/Home/HomeScreen'; const ICON_AMICALE = require('../../../assets/amicale.png'); type PropsType = { navigation: StackNavigationProp, item: FeedItemType, title: string, subtitle: string, height: number, }; /** * Component used to display a feed item */ class FeedItem extends React.Component { shouldComponentUpdate(): boolean { return false; } onPress = () => { const {props} = this; props.navigation.navigate('feed-information', { data: props.item, date: props.subtitle, }); }; render(): React.Node { const {props} = this; const {item} = props; const hasImage = item.full_picture !== '' && item.full_picture !== undefined; const cardMargin = 10; const cardHeight = props.height - 2 * cardMargin; const imageSize = 250; const titleHeight = 80; const actionsHeight = 60; const textHeight = hasImage ? cardHeight - titleHeight - actionsHeight - imageSize : cardHeight - titleHeight - actionsHeight; return ( ( )} style={{height: titleHeight}} /> {hasImage ? ( ) : null} {item.message !== undefined ? ( ) : null} ); } } export default FeedItem;