Skip to content

Instantly share code, notes, and snippets.

@reyhansofian
Created August 4, 2017 02:31
Show Gist options
  • Save reyhansofian/d3b81e50abfa588d8ba02a2f3a369f83 to your computer and use it in GitHub Desktop.
Save reyhansofian/d3b81e50abfa588d8ba02a2f3a369f83 to your computer and use it in GitHub Desktop.
// FilmDetail.js
import React, { Component, PropTypes } from 'react';
import { gql, graphql } from 'react-apollo';
import {
Text,
View,
} from 'react-native';
@graphql(gql`
query($id: ID!) {
film(id: $id) {
title
openingCrawl
director
producers
releaseDate
}
}
`, {
options: (props) => ({
variables: {
id: props.navigation.state.params.id,
},
}),
})
class FilmDetail extends Component {
static navigationOptions = ({ navigation }) => ({
title: navigation.state.params.title,
});
render() {
const { film } = this.props.data;
return (
<View style={styles.container}>
<Text style={styles.title}>{film.title}</Text>
<View style={styles.rowContainer}>
<Text style={styles.bold}>Released Date:</Text><Text> {moment(film.releaseDate).format('DD MMMM Y')}</Text>
</View>
<View style={styles.rowContainer}>
<Text style={styles.bold}>Director:</Text><Text> {film.director}</Text>
</View>
<View style={styles.rowContainer}>
<Text style={styles.bold}>Producers:</Text><Text> {film.producers.join(', ')}</Text>
</View>
<View style={styles.openingCrawlContainer}>
<Text style={styles.openingCrawlText}>{film.openingCrawl}</Text>
</View>
</View>
);
}
}
export default FilmDetail;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment