forked from race604/ZhiHuDaily-React-Native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStoryItem.js
74 lines (69 loc) · 1.72 KB
/
StoryItem.js
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
'use strict';
var React = require('react-native');
var {
Image,
PixelRatio,
Platform,
StyleSheet,
Text,
TouchableHighlight,
TouchableNativeFeedback,
View
} = React;
var StoryItem = React.createClass({
render: function() {
var TouchableElement = TouchableHighlight;
if (Platform.OS === 'android') {
TouchableElement = TouchableNativeFeedback;
}
return (
<View {...this.props}>
<TouchableElement
onPress={this.props.onSelect}
onShowUnderlay={this.props.onHighlight}
onHideUnderlay={this.props.onUnhighlight}>
<View style={styles.row}>
{/* $FlowIssue #7363964 - There's a bug in Flow where you cannot
* omit a property or set it to undefined if it's inside a shape,
* even if it isn't required */}
<Text style={styles.storyTitle} numberOfLines={3}>
{this.props.story.title}
</Text>
<Image
source={{uri: ((this.props.story.images && this.props.story.images[0])
? this.props.story.images[0] : '')}}
style={styles.cellImage} />
</View>
</TouchableElement>
</View>
);
}
});
var styles = StyleSheet.create({
storyTitle: {
flex: 1,
fontSize: 16,
},
row: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white',
padding: 10,
marginLeft: 10,
marginRight: 10,
marginVertical: 5,
borderColor: '#dddddd',
borderStyle: null,
borderWidth: 0.5,
borderRadius: 2,
},
cellImage: {
backgroundColor: '#dddddd',
height: 60,
marginLeft: 10,
width: 80,
},
});
module.exports = StoryItem;