-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathMovieCell.js
More file actions
94 lines (84 loc) · 2.02 KB
/
MovieCell.js
File metadata and controls
94 lines (84 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
'use strict';
var React = require('react-native');
var {
Image,
PixelRatio,
Platform,
StyleSheet,
Text,
TouchableHighlight,
TouchableNativeFeedback,
View
} = React;
var MovieCell = React.createClass({
getActors: function(movie) {
var actors = new Array();
for(var i in movie.casts){
actors.push(movie.casts[i].name);
}
return actors.join('/');
},
render: function() {
var image = this.props.movie.images.small;
var title = this.props.movie.title;
var rating = '评分:' + this.props.movie.rating.average;
var actors = '演员:' + this.getActors(this.props.movie);
var TouchableElement = TouchableNativeFeedback;
if (Platform.OS === 'ios') {
TouchableElement = TouchableHighlight;
}
return (
<View>
<TouchableElement
onPress={this.props.onSelect}
onShowUnderlay={this.props.onHighlight}
onHideUnderlay={this.props.onUnhighlight}>
<View style={styles.row}>
<Image
source={{uri: image}}
style={styles.cellImage} />
<View style={styles.textContainer}>
<Text style={styles.movieTitle} numberOfLines={1}>
{title}
</Text>
<Text style={styles.movieRating} numberOfLines={1}>
{rating}
</Text>
<Text style={styles.movieRating} numberOfLines={1}>
{actors}
</Text>
</View>
</View>
</TouchableElement>
</View>
);
}
});
var styles = StyleSheet.create({
textContainer: {
flex: 1,
},
movieTitle: {
fontSize: 18,
fontWeight: '500',
marginBottom: 2,
},
movieRating: {
marginTop: 5,
color: '#999999',
fontSize: 14,
},
row: {
alignItems: 'center',
backgroundColor: 'white',
flexDirection: 'row',
padding: 10,
},
cellImage: {
backgroundColor: '#dddddd',
height: 80,
marginRight: 10,
width: 55,
},
});
module.exports = MovieCell;