-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTweetCell.js
47 lines (39 loc) · 955 Bytes
/
TweetCell.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
'use strict';
var React = require('react-native');
var {
StyleSheet,
Text,
View,
TouchableOpacity,
} = React;
var LikeButton = require('./LikeButton.js');
var TweetCell = React.createClass({
render: function() {
var color = this.props.tweet.get('color');
return (
<View style={[styles.tweet, {backgroundColor: color}]}>
<Text style={{fontSize: 20, textAlign: 'center', color: 'white'}}>
{this.props.tweet.get('text')}
</Text>
<LikeButton
count={this.props.tweet.get('likes')}
onPress={this.handleLike} />
</View>
);
},
handleLike: function() {
this.props.tweet.increment('likes', 1);
this.props.tweet.save();
this.forceUpdate();
},
});
var styles = StyleSheet.create({
tweet: {
height: 200,
padding: 30,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#eeeeeeee',
},
});
module.exports = TweetCell;