-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathArticleCell.js
More file actions
executable file
·175 lines (165 loc) · 4.48 KB
/
ArticleCell.js
File metadata and controls
executable file
·175 lines (165 loc) · 4.48 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/**
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @flow
*/
'use strict';
var React = require('react-native');
var Icon = require('react-native-vector-icons/Ionicons');
var {
Image,
PixelRatio,
StyleSheet,
Text,
TouchableHighlight,
View
} = React;
var colors = ["#ef6f67","#46afe4","#81cc7a","#00cbbd"]
var random_color = function(){
return colors[Math.floor(Math.random()*colors.length)]
}
var ArticleCell = React.createClass({
render: function() {
return (
<View>
<TouchableHighlight onPress={this.props.onSelect}>
<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 */}
<View style={styles.textContainer}>
<Text style={styles.title} numberOfLines={2}>
{this.props.article.title}
</Text>
<View style={styles.descContainer} >
<Image
style={styles.icon}
source={{uri: this.props.article.user_headpic}}
/>
<Text style={styles.desc} numberOfLines={1}>
{this.props.article.user_nick} {this.props.article.publish_time}
</Text>
</View>
{this.props.article.tags?
<View style={styles.tags} >
{this.props.article.tags.split(',').map(function(result) {
return <Text style={[styles.tag,{backgroundColor:random_color()}]}> {result}</Text>;
})}
</View>
:null}
<View style={styles.count_container}>
<View style={styles.count_item}>
<Icon name="ios-heart-outline" size={15} color="#aaa" />
<Text style={{fontSize:10,color:"#aaa",marginLeft:2,lineHeight:13}}>{this.props.article.zan_count}</Text>
</View>
<View style={styles.count_item}>
<Icon name="ios-chatboxes-outline" size={15} color="#aaa" />
<Text style={{fontSize:10,color:"#aaa",marginLeft:2,lineHeight:13}}>{this.props.article.comment_count}</Text>
</View>
</View>
</View>
</View>
</TouchableHighlight>
</View>
);
}
});
var styles = StyleSheet.create({
textContainer: {
flex: 1,
},
title: {
flex: 1,
fontSize: 14,
fontWeight: '500',
paddingTop:7,
paddingLeft:5,
paddingBottom:7,
paddingRight:5
},
descContainer:{
flex:1,
flexDirection:"row",
paddingTop:5,
paddingLeft:5,
paddingBottom:5,
},
desc:{
fontSize: 12,
fontWeight: '200',
color:"#999999",
marginLeft:5,
},
icon:{
width:16,
height:16,
borderRadius:8,
overflow:"hidden",
},
movieYear: {
color: '#999999',
fontSize: 12,
},
row: {
alignItems: 'center',
backgroundColor: 'white',
flexDirection: 'row',
padding: 10,
},
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,
},
tags:{
flex: 1,
flexDirection:"row",
paddingTop:5,
paddingLeft:5,
paddingBottom:0,
flexWrap:'wrap',
},
tag:{
fontSize: 11,
color:"#fff",
marginRight:7,
marginBottom:5,
paddingTop:2,
paddingBottom:2,
paddingLeft:1,
paddingRight:3,
borderRadius:2,
overflow:"hidden",
opacity:0.7,
backgroundColor:"#ff0000"
},
count_container:{
position:"absolute",
right:5,
bottom:0,
flexDirection:"row",
},
count_item:{
height:15,
marginLeft:10,
flexDirection:"row",
}
});
module.exports = ArticleCell;