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
|
import React from 'react';
import {
FlatList,
Image,
View,
TouchableOpacity,
} from 'react-native';
import {
RkText,
RkCard, RkStyleSheet,
} from 'react-native-ui-kitten';
import { SocialBar } from '../../components';
import { data } from '../../data';
import NavigationType from '../../config/navigation/propTypes';
const moment = require('moment');
export class Articles1 extends React.Component {
static propTypes = {
navigation: NavigationType.isRequired,
};
static navigationOptions = {
title: 'Article List'.toUpperCase(),
};
state = {
data: data.getArticles(),
};
extractItemKey = (item) => `${item.id}`;
onItemPressed = ({ item }) => {
this.props.navigation.navigate('Article', { id: item.id });
};
renderItem = ({ item }) => (
<TouchableOpacity
delayPressIn={70}
activeOpacity={0.8}
onPress={() => this.onItemPressed(item)}>
<RkCard rkType='backImg'>
<Image rkCardImg source={item.photo} />
<View rkCardImgOverlay rkCardContent style={styles.overlay}>
<RkText rkType='header2 inverseColor'>{item.header}</RkText>
<RkText rkType='secondary2 inverseColor'>{moment().add(item.time, 'seconds').fromNow()}</RkText>
<View rkCardFooter style={styles.footer}>
<SocialBar rkType='leftAligned' />
</View >
</View>
</RkCard>
</TouchableOpacity>
);
render = () => (
<FlatList
data={this.state.data}
renderItem={this.renderItem}
keyExtractor={this.extractItemKey}
style={styles.root}
/>
);
}
const styles = RkStyleSheet.create(theme => ({
root: {
backgroundColor: theme.colors.screen.base,
},
overlay: {
justifyContent: 'flex-end',
},
footer: {
width: 240,
},
}));
|