import PropTypes from 'prop-types'; import React from 'react'; import Meteor from 'react-native-meteor'; import { CachedImage } from 'react-native-img-cache'; import { Text, TouchableOpacity } from 'react-native'; import { Navigation } from 'react-native-navigation'; import { Card, CardImage, // CardTitle, CardContent // CardAction } from 'react-native-card-view'; import RocketChat from '../../lib/rocketchat'; const close = () => Navigation.dismissModal({ animationType: 'slide-down' }); const CustomButton = ({ text }) => ( {text} ); Navigation.registerComponent('CustomButton', () => CustomButton); export default class Cards extends React.PureComponent { static propTypes = { data: PropTypes.object.isRequired } constructor() { super(); const user = Meteor.user(); this.state = {}; RocketChat.getUserToken().then((token) => { this.setState({ img: `${ RocketChat.currentServer }${ this.props.data.image_url }?rc_uid=${ user._id }&rc_token=${ token }` }); }); } _onPressButton() { Navigation.showModal({ screen: 'Photo', title: this.props.data.title, // title of the screen as appears in the nav bar (optional) passProps: { image: this.state.img }, // navigatorStyle: {}, // override the navigator style for the screen, see "Styling the navigator" below (optional) navigatorButtons: { leftButtons: [{ id: 'custom-button', component: 'CustomButton', passProps: { text: 'close' } }] }, // override the nav buttons for the screen, see "Adding buttons to the navigator" below (optional) animationType: 'slide-up' // 'none' / 'slide-up' , appear animation for the modal (optional, default 'slide-up') }); } render() { return this.state.img ? ( this._onPressButton()}> {this.props.data.title} {this.props.data.description} ) : {this.props.data.title}; } }