-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFeedItem.js
More file actions
79 lines (76 loc) · 1.78 KB
/
FeedItem.js
File metadata and controls
79 lines (76 loc) · 1.78 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
import React, {Component} from 'react';
import { StyleSheet, Text, View, Linking } from 'react-native';
import moment from 'moment';
import { Card, Button, Icon } from 'react-native-elements';
class FeedItem extends Component {
constructor(props) {
super(props);
this.state = {
};
}
render() {
const {
item: { title, urlToImage, source, publishedAt, content, url }
} = this.props;
const onPress = url => {
Linking.canOpenURL(url).then(supported => {
if (supported) {
Linking.openURL(url);
} else {
console.log(`Don't know how to open URL: ${url}`);
}
});
};
return(
<Card
title={title}
image = {{uri: urlToImage}}>
<View style={styles.row}>
<Text style={styles.label}>Source</Text>
<Text style={styles.info}>{source.name}</Text>
</View>
<Text>{content}</Text>
<View style={styles.row}>
<Text style={styles.label}>Published</Text>
<Text style={styles.info}>
{moment(publishedAt).format('LLL')}
</Text>
</View>
<Button title="READ MORE" backgroundColor="#FF0000" onPress={() => onPress(url)} />
</Card>
)
}
}
const styles = StyleSheet.create({
containerFlex: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
},
container: {
flex: 1,
marginTop: 40,
alignItems: 'center',
backgroundColor: '#fff',
justifyContent: 'center'
},
header: {
height: 30,
width: '100%',
backgroundColor: 'pink'
},
row: {
flexDirection: 'row'
},
label: {
fontSize: 16,
color: 'black',
marginRight: 10,
fontWeight: 'bold'
},
info: {
fontSize: 16,
color: 'grey'
},
});
export default FeedItem;