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
|
import * as React from 'react';
import {Text} from 'react-native-animatable';
import {StyleSheet, TouchableOpacity} from 'react-native';
import CommentIcon from '../../assets/icons/moment-comment-icon.svg';
import {useNavigation} from '@react-navigation/native';
/**
* Provides a view for the comment icon and the comment count.
* When the user clicks on this view, a new screen opens to display all the comments.
*/
type CommentsCountProps = {
comments_count: string;
isProfileView: boolean;
moment_id: string;
};
const CommentsCount: React.FC<CommentsCountProps> = ({
comments_count,
isProfileView,
moment_id,
}) => {
const navigation = useNavigation();
const navigateToCommentsScreen = async () => {
navigation.navigate('MomentCommentsScreen', {
isProfileView: isProfileView,
moment_id: moment_id,
});
};
return (
<>
<TouchableOpacity onPress={() => navigateToCommentsScreen()}>
<CommentIcon style={styles.image} />
<Text style={styles.count}>
{comments_count !== '0' ? comments_count : ''}
</Text>
</TouchableOpacity>
</>
);
};
const styles = StyleSheet.create({
image: {
position: 'relative',
width: 21,
height: 21,
},
count: {
position: 'relative',
fontWeight: 'bold',
color: 'white',
paddingTop: '2%',
},
});
export default CommentsCount;
|