// @flow import * as React from 'react'; import {ScrollView, View} from 'react-native'; import HTML from "react-native-render-html"; import {Linking} from "expo"; import {Avatar, Card, Chip, Paragraph, withTheme} from 'react-native-paper'; import ImageModal from 'react-native-image-modal'; import i18n from "i18n-js"; type Props = { navigation: Object, route: Object }; type State = { imageModalVisible: boolean, }; function openWebLink(event, link) { Linking.openURL(link).catch((err) => console.error('Error opening link', err)); } /** * Class defining a planning event information page. */ class ClubDisplayScreen extends React.Component { displayData = this.props.route.params['data']; categories = this.props.route.params['categories']; colors: Object; state = { imageModalVisible: false, }; constructor(props) { super(props); this.colors = props.theme.colors; } componentDidMount(): * { this.props.navigation.setOptions({title: this.displayData.name}) } getCategoryName(id: number) { for (let i = 0; i < this.categories.length; i++) { if (id === this.categories[i].id) return this.categories[i].name; } return ""; } getCategoriesRender(categories: Array) { let final = []; for (let i = 0; i < categories.length; i++) { if (categories[i] !== null) { final.push( {this.getCategoryName(categories[i])} ); } } return {final}; } getManagersRender(resp: Array) { let final = []; for (let i = 0; i < resp.length; i++) { final.push({resp[i]}) } const hasManagers = resp.length > 0; return ( } /> {final} ); } render() { return ( {this.getCategoriesRender(this.displayData.category)} {this.displayData.logo !== null ? : } {this.displayData.description !== null ? // Surround description with div to allow text styling if the description is not html " + this.displayData.description + ""} tagsStyles={{ p: {color: this.colors.text,}, div: {color: this.colors.text} }} onLinkPress={openWebLink}/> : } {this.getManagersRender(this.displayData.responsibles)} ); } } export default withTheme(ClubDisplayScreen);