import PropTypes from 'prop-types'; import React from 'react'; import Meteor from 'react-native-meteor'; import { connect } from 'react-redux'; import { CachedImage } from 'react-native-img-cache'; import { Text, TouchableOpacity, View } from 'react-native'; import { Card, CardImage, // CardTitle, CardContent // CardAction } from 'react-native-card-view'; import RocketChat from '../../lib/rocketchat'; import PhotoModal from './PhotoModal'; @connect(state => ({ base: state.settings.Site_Url, canShowList: state.login.token.length || state.login.user.token })) export default class Cards extends React.PureComponent { static propTypes = { data: PropTypes.object.isRequired, base: PropTypes.string } constructor() { super(); const user = Meteor.user(); this.state = { modalVisible: false }; RocketChat.getUserToken().then((token) => { this.setState({ img: `${ this.props.base }${ this.props.data.image_url }?rc_uid=${ user._id }&rc_token=${ token }` }); }); } getDescription() { if (this.props.data.description) { return {this.props.data.description}; } } getImage() { return ( this._onPressButton()}> {this.props.data.title} {this.getDescription()} this.setState({ modalVisible: false })} /> ); } getOther() { return ( {this.props.data.title} ); } _onPressButton() { this.setState({ modalVisible: true }); } render() { return this.state.img ? this.getImage() : this.getOther(); } }