application-amicale/screens/Planning/PlanningDisplayScreen.js

71 lines
2.5 KiB
JavaScript
Raw Normal View History

// @flow
import * as React from 'react';
import {Image, ScrollView, View} from 'react-native';
import HTML from "react-native-render-html";
import {Linking} from "expo";
2020-03-08 14:22:03 +01:00
import PlanningEventManager from '../../utils/PlanningEventManager';
import {Card, withTheme} from 'react-native-paper';
import DateManager from "../../utils/DateManager";
type Props = {
navigation: Object,
2020-03-06 09:12:56 +01:00
route: Object
};
2020-02-11 01:05:24 +01:00
function openWebLink(event, link) {
Linking.openURL(link).catch((err) => console.error('Error opening link', err));
}
/**
* Class defining an about screen. This screen shows the user information about the app and it's author.
*/
class PlanningDisplayScreen extends React.Component<Props> {
2020-03-06 09:12:56 +01:00
displayData = this.props.route.params['data'];
colors: Object;
constructor(props) {
super(props);
this.colors = props.theme.colors;
}
render() {
2020-02-11 01:05:24 +01:00
// console.log("rendering planningDisplayScreen");
2020-03-22 17:02:00 +01:00
let subtitle = PlanningEventManager.getFormattedEventTime(
this.displayData["date_begin"], this.displayData["date_end"]);
let dateString = PlanningEventManager.getDateOnlyString(this.displayData["date_begin"]);
if (dateString !== null)
subtitle += ' | ' + DateManager.getInstance().getTranslatedDate(dateString);
return (
<ScrollView style={{paddingLeft: 5, paddingRight: 5}}>
2020-03-08 12:05:22 +01:00
<Card.Title
title={this.displayData.title}
2020-03-22 17:02:00 +01:00
subtitle={subtitle}
2020-03-08 12:05:22 +01:00
/>
{this.displayData.logo !== null ?
2020-03-08 12:05:22 +01:00
<View style={{width: '100%', height: 300}}>
<Image style={{flex: 1, resizeMode: "contain"}}
source={{uri: this.displayData.logo}}/>
</View>
: <View/>}
{this.displayData.description !== null ?
// Surround description with div to allow text styling if the description is not html
2020-03-08 12:05:22 +01:00
<Card.Content>
<HTML html={"<div>" + this.displayData.description + "</div>"}
tagsStyles={{
p: {color: this.colors.text,},
div: {color: this.colors.text}
2020-03-08 12:05:22 +01:00
}}
onLinkPress={openWebLink}/>
</Card.Content>
: <View/>}
</ScrollView>
);
}
}
export default withTheme(PlanningDisplayScreen);