import React from 'react';
import {
FlatList,
Image,
View,
TouchableOpacity,
} from 'react-native';
import {
RkText,
RkCard, RkStyleSheet,
} from 'react-native-ui-kitten';
import axios from 'axios';
import {SocialBar} from '../../components';
import NavigationType from '../../config/navigation/propTypes';
import {HOST} from '../../constants'
export class Articles2 extends React.Component {
static propTypes = {
navigation: NavigationType.isRequired,
};
static navigationOptions = {
title: 'Problems List'.toUpperCase(),
};
state = {
articles: [],
refreshing: false,
};
componentDidMount() {
this.makeRemoteRequest()
};
makeRemoteRequest = () => {
axios.get(`${HOST}/api/articles`)
.then(res => {
this.setState({
articles: res.data,
refreshing: false,
});
});
};
handleRefresh = () =>{
this.setState({
refreshing: true,
}, () => {
setTimeout(()=>{this.makeRemoteRequest()}, 500)
})
};
extractItemKey = (item) => `${item.id}`;
onItemPressed = (item) => {
this.props.navigation.navigate('Article', {id: item.id});
};
renderItem = ({item}) => (
this.onItemPressed(item)}>
{item.title}
);
render = () => (
);
}
const styles = RkStyleSheet.create(theme => ({
container: {
backgroundColor: theme.colors.screen.scroll,
paddingVertical: 8,
paddingHorizontal: 14,
},
card: {
marginVertical: 8,
},
time: {
marginTop: 5,
},
}));