-
Notifications
You must be signed in to change notification settings - Fork 807
/
StoryItem.js
93 lines (86 loc) · 2.13 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
'use strict';
var React = require('react-native');
var {
Image,
PixelRatio,
Platform,
StyleSheet,
Text,
TouchableHighlight,
TouchableNativeFeedback,
View,
} = React;
var TITLE_REF = 'title';
var StoryItem = React.createClass({
updateReadSate: function() {
this.refs[TITLE_REF].setNativeProps({style: {color: '#777777'}});
this.props.onSelect();
},
render: function() {
var TouchableElement = TouchableHighlight;
if (Platform.OS === 'android') {
TouchableElement = TouchableNativeFeedback;
}
var image = null;
if (this.props.story.images && this.props.story.images[0]) {
image = <Image
source={{uri: this.props.story.images[0]}}
style={styles.cellImage} />
}
return (
<View {...this.props}>
<TouchableElement
onPress={this.updateReadSate /*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
ref={TITLE_REF}
style={this.props.story.read ? styles.storyTitleRead : styles.storyTitle}
numberOfLines={3}>
{this.props.story.title}
</Text>
{image}
</View>
</TouchableElement>
</View>
);
}
});
var styles = StyleSheet.create({
storyTitle: {
flex: 1,
fontSize: 16,
color: '#333333',
},
storyTitleRead: {
flex: 1,
fontSize: 16,
color: '#777777',
},
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;