// @flow import * as React from 'react'; import {Linking, Image} from 'react-native'; import {Card, Text, withTheme} from 'react-native-paper'; import Autolink from 'react-native-autolink'; import {StackNavigationProp} from '@react-navigation/stack'; import MaterialHeaderButtons, { Item, } from '../../components/Overrides/CustomHeaderButton'; import CustomTabBar from '../../components/Tabbar/CustomTabBar'; import type {FeedItemType} from './HomeScreen'; import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView'; import ImageGalleryButton from '../../components/Media/ImageGalleryButton'; import NewsSourcesConstants from '../../constants/NewsSourcesConstants'; import type {NewsSourceType} from '../../constants/NewsSourcesConstants'; type PropsType = { navigation: StackNavigationProp, route: {params: {data: FeedItemType, date: string}}, }; /** * Class defining a feed item page. */ class FeedItemScreen extends React.Component { displayData: FeedItemType; date: string; constructor(props: PropsType) { super(props); this.displayData = props.route.params.data; this.date = props.route.params.date; } componentDidMount() { const {props} = this; props.navigation.setOptions({ headerRight: this.getHeaderButton, }); } /** * Opens the feed item out link in browser or compatible app */ onOutLinkPress = () => { Linking.openURL(this.displayData.url); }; /** * Gets the out link header button * * @returns {*} */ getHeaderButton = (): React.Node => { return ( ); }; render(): React.Node { const {navigation} = this.props; const hasImage = this.displayData.image !== '' && this.displayData.image != null; const pageSource: NewsSourceType = NewsSourcesConstants[this.displayData.page_id]; return ( ( )} /> {hasImage ? ( ) : null} {this.displayData.message !== undefined ? ( ) : null} ); } } export default withTheme(FeedItemScreen);