123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- // @flow
-
- import * as React from 'react';
- import {Linking, ScrollView, View} from 'react-native';
- import {Avatar, Card, Text, withTheme} from 'react-native-paper';
- import ImageModal from 'react-native-image-modal';
- import Autolink from "react-native-autolink";
- import MaterialHeaderButtons, {Item} from "../../components/Overrides/CustomHeaderButton";
- import CustomTabBar from "../../components/Tabbar/CustomTabBar";
- import {StackNavigationProp} from "@react-navigation/stack";
- import type {feedItem} from "./HomeScreen";
-
- type Props = {
- navigation: StackNavigationProp,
- route: { params: { data: feedItem, date: string } }
- };
-
- const ICON_AMICALE = require('../../../assets/amicale.png');
- const NAME_AMICALE = 'Amicale INSA Toulouse';
-
- /**
- * Class defining a feed item page.
- */
- class FeedItemScreen extends React.Component<Props> {
-
- displayData: feedItem;
- date: string;
-
- constructor(props) {
- super(props);
- this.displayData = props.route.params.data;
- this.date = props.route.params.date;
- }
-
- componentDidMount() {
- this.props.navigation.setOptions({
- headerRight: this.getHeaderButton,
- });
- }
-
- /**
- * Opens the feed item out link in browser or compatible app
- */
- onOutLinkPress = () => {
- Linking.openURL(this.displayData.permalink_url);
- };
-
- /**
- * Gets the out link header button
- *
- * @returns {*}
- */
- getHeaderButton = () => {
- return <MaterialHeaderButtons>
- <Item title="main" iconName={'facebook'} color={"#2e88fe"} onPress={this.onOutLinkPress}/>
- </MaterialHeaderButtons>;
- };
-
- /**
- * Gets the Amicale INSA avatar
- *
- * @returns {*}
- */
- getAvatar() {
- return (
- <Avatar.Image size={48} source={ICON_AMICALE}
- style={{backgroundColor: 'transparent'}}/>
- );
- }
-
- render() {
- const hasImage = this.displayData.full_picture !== '' && this.displayData.full_picture != null;
- return (
- <ScrollView style={{margin: 5,}}>
- <Card.Title
- title={NAME_AMICALE}
- subtitle={this.date}
- left={this.getAvatar}
- />
- {hasImage ?
- <View style={{marginLeft: 'auto', marginRight: 'auto'}}>
- <ImageModal
- resizeMode="contain"
- imageBackgroundColor={"#000"}
- style={{
- width: 250,
- height: 250,
- }}
- source={{
- uri: this.displayData.full_picture,
- }}
- /></View> : null}
- <Card.Content style={{paddingBottom: CustomTabBar.TAB_BAR_HEIGHT + 20}}>
- {this.displayData.message !== undefined ?
- <Autolink
- text={this.displayData.message}
- hashtag="facebook"
- component={Text}
- /> : null
- }
- </Card.Content>
- </ScrollView>
- );
- }
- }
-
- export default withTheme(FeedItemScreen);
|