87 lines
2.0 KiB
JavaScript
87 lines
2.0 KiB
JavaScript
|
/**
|
||
|
* Copyright 2004-present Facebook. All Rights Reserved.
|
||
|
* @flow
|
||
|
*/
|
||
|
'use strict';
|
||
|
|
||
|
var React = require('react-native');
|
||
|
var {
|
||
|
Image,
|
||
|
PixelRatio,
|
||
|
StyleSheet,
|
||
|
Text,
|
||
|
TouchableHighlight,
|
||
|
View
|
||
|
} = React;
|
||
|
|
||
|
var getStyleFromScore = require('./getStyleFromScore');
|
||
|
var getImageSource = require('./getImageSource');
|
||
|
var getTextFromScore = require('./getTextFromScore');
|
||
|
|
||
|
var MovieCell = React.createClass({
|
||
|
render: function() {
|
||
|
var criticsScore = this.props.movie.ratings.critics_score;
|
||
|
return (
|
||
|
<View>
|
||
|
<TouchableHighlight onPress={this.props.onSelect}>
|
||
|
<View style={styles.row}>
|
||
|
<Image
|
||
|
source={getImageSource(this.props.movie, 'det')}
|
||
|
style={styles.cellImage}
|
||
|
/>
|
||
|
<View style={styles.textContainer}>
|
||
|
<Text style={styles.movieTitle} numberOfLines={2}>
|
||
|
{this.props.movie.title}
|
||
|
</Text>
|
||
|
<Text style={styles.movieYear} numberOfLines={1}>
|
||
|
{this.props.movie.year}
|
||
|
{' '}•{' '}
|
||
|
<Text style={getStyleFromScore(criticsScore)}>
|
||
|
Critics {getTextFromScore(criticsScore)}
|
||
|
</Text>
|
||
|
</Text>
|
||
|
</View>
|
||
|
</View>
|
||
|
</TouchableHighlight>
|
||
|
<View style={styles.cellBorder} />
|
||
|
</View>
|
||
|
);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
var styles = StyleSheet.create({
|
||
|
textContainer: {
|
||
|
flex: 1,
|
||
|
},
|
||
|
movieTitle: {
|
||
|
flex: 1,
|
||
|
fontSize: 16,
|
||
|
fontWeight: 'bold',
|
||
|
marginBottom: 2,
|
||
|
},
|
||
|
movieYear: {
|
||
|
color: '#999999',
|
||
|
fontSize: 12,
|
||
|
},
|
||
|
row: {
|
||
|
alignItems: 'center',
|
||
|
backgroundColor: 'white',
|
||
|
flexDirection: 'row',
|
||
|
padding: 5,
|
||
|
},
|
||
|
cellImage: {
|
||
|
backgroundColor: '#dddddd',
|
||
|
height: 93,
|
||
|
marginRight: 10,
|
||
|
width: 60,
|
||
|
},
|
||
|
cellBorder: {
|
||
|
backgroundColor: 'rgba(0, 0, 0, 0.1)',
|
||
|
// Trick to get the thinest line the device can display
|
||
|
height: 1 / PixelRatio.get(),
|
||
|
marginLeft: 4,
|
||
|
},
|
||
|
});
|
||
|
|
||
|
module.exports = MovieCell;
|