forked from tokict/react-native-comments
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComment.js
More file actions
executable file
·97 lines (91 loc) · 3.6 KB
/
Comment.js
File metadata and controls
executable file
·97 lines (91 loc) · 3.6 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
/**
* Created by tino on 6/6/17.
*/
import React, { PureComponent } from 'react'
import {
View,
Text,
Image,
FlatList,
ActivityIndicator,
TouchableHighlight,
TouchableOpacity
} from 'react-native'
import PropTypes from 'prop-types'
import TimeAgo from 'react-native-timeago'
import Icon from 'react-native-vector-icons/FontAwesome'
import styles from './styles'
import Collapsible from 'react-native-collapsible'
export default class Comment extends PureComponent {
render () {
return (
<View style={styles.commentContainer}>
<View style={styles.left}>
<TouchableHighlight onPress={() => this.props.usernameTapAction(this.props.username)}>
<View style={{alignItems: 'center'}}>
<Image
style={[styles.image, {width: 30, height: 30, borderRadius: 30}]}
source={{uri: this.props.image}}/>
{this.props.likes.length ? <TouchableHighlight style={[styles.actionButton, {paddingTop: 5}]}
onPress={() =>
this.props.likesTapAction()}>
<View style={{flexDirection: 'row'}}>
<Icon name={'heart'} color={'#df1740'} size={15}/>
<Text style={styles.likeNr}> {this.props.likes.length}</Text>
</View>
</TouchableHighlight> : null}
</View>
</TouchableHighlight>
</View>
<View style={styles.right}>
<View style={styles.rightContent}>
<View style={styles.rightContentTop}>
<TouchableHighlight onPress={() => this.props.usernameTapAction(this.props.username)}>
<Text style={styles.name}>{this.props.username}</Text>
</TouchableHighlight>
{this.props.canEdit?<TouchableHighlight
style={styles.editIcon}
onPress={() => this.props.editComment()}>
<Icon name={'edit'} size={15}/>
</TouchableHighlight>:null}
</View>
<Text style={styles.body}>{this.props.body}</Text>
</View>
<View style={styles.rightActionBar}>
<TimeAgo style={styles.time} time={this.props.updatedAt}/>
<TouchableHighlight style={styles.actionButton}
onPress={() => this.props.likeAction()}>
<View style={{flexDirection: 'row'}}>
<Text style={[styles.actionText, {color: this.props.liked ? '#4DB2DF' : null}]}>Like </Text>
</View>
</TouchableHighlight>
<TouchableHighlight style={styles.actionButton} onPress={() => this.props.replyAction()}>
<Text style={styles.actionText}>Reply</Text>
</TouchableHighlight>
<TouchableHighlight style={styles.actionButton} onPress={() => this.props.reportAction()}>
{this.props.reported ? <Text style={{fontStyle: 'italic', fontSize: 11,}}>Reported</Text>
: <Text style={styles.actionText}>Report</Text>}
</TouchableHighlight>
</View>
</View>
</View>
)
}
}
Comment.propTypes = {
body: PropTypes.string,
canEdit: PropTypes.bool,
child: PropTypes.bool,
editComment: PropTypes.func,
image: PropTypes.string,
likeAction: PropTypes.func,
liked: PropTypes.bool,
likes: PropTypes.array,
likesTapAction: PropTypes.func,
replyAction: PropTypes.func,
reportAction: PropTypes.func,
reported: PropTypes.bool,
updatedAt: PropTypes.string,
username: PropTypes.string,
usernameTapAction: PropTypes.func
}