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
|
import React, {useEffect} from 'react';
import {Image, StyleSheet, Text, View, ViewProps} from 'react-native';
import {getMomentCommentsCount} from '../../services';
import {ScreenType} from '../../types';
import {getTimePosted, SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils';
import {CommentsCount} from '../comments';
interface MomentPostContentProps extends ViewProps {
screenType: ScreenType;
momentId: string;
caption: string;
pathHash: string;
dateTime: string;
}
const MomentPostContent: React.FC<MomentPostContentProps> = ({
screenType,
momentId,
caption,
pathHash,
dateTime,
style,
}) => {
const [elapsedTime, setElapsedTime] = React.useState<string>();
const [comments_count, setCommentsCount] = React.useState('');
useEffect(() => {
setElapsedTime(getTimePosted(dateTime));
getMomentCommentsCount(momentId, setCommentsCount);
}, [dateTime, momentId]);
return (
<View style={[styles.container, style]}>
<Image
style={styles.image}
source={{uri: pathHash}}
resizeMode={'cover'}
/>
<View style={styles.footerContainer}>
<CommentsCount
commentsCount={comments_count}
momentId={momentId}
screenType={screenType}
/>
<Text style={styles.text}>{elapsedTime}</Text>
</View>
<Text style={styles.captionText}>{caption}</Text>
</View>
);
};
const styles = StyleSheet.create({
container: {
height: SCREEN_HEIGHT,
},
image: {
width: SCREEN_WIDTH,
aspectRatio: 1,
marginBottom: '3%',
},
footerContainer: {
flexDirection: 'row',
justifyContent: 'space-between',
marginLeft: '7%',
marginRight: '5%',
marginBottom: '2%',
},
text: {
position: 'relative',
paddingBottom: '1%',
paddingTop: '1%',
marginLeft: '7%',
marginRight: '2%',
color: '#ffffff',
fontWeight: 'bold',
},
captionText: {
position: 'relative',
paddingBottom: '34%',
paddingTop: '1%',
marginLeft: '5%',
marginRight: '5%',
color: '#ffffff',
fontWeight: 'bold',
},
});
export default MomentPostContent;
|