import {StyleSheet, View, SectionList} from "react-native";
import {Card, ListItem, CardItem, Body, Text as Text, Left, Right, Icon, Button, Content, Spinner} from 'native-base';
import React, { Component } from 'react';
import moment from "moment";
import 'moment/locale/nb';
import theme from "../../theme";
moment.locale('nb');
export default class EventList extends Component {
_renderItem = ({item}) => (
{ this._onPressItem(item); }} style={styles.listItem}>
{item.title.decoded}
{this._formatTime(item.start_time)}
);
_renderSectionHeader = ({section}) => {
return (
{section.title}
);
};
_renderFooter = () => {
if(!this.props.loading) {
return null;
}
return (
);
};
_onPressItem = (item) => {
this.props.showEvent(item);
};
_formatTime(time) {
return moment(time).format('llll');
}
render() {
if (this.props.error) {
return (
{ this._onPressItem(item); }}>
Kunne ikke hente programmet...
)
}
return ( item.id}
refreshing={this.props.refreshing}
onRefresh={this.props.handleRefresh}
onEndReached={this.props.handleLoadMore}
onEndReachedThreshould={10}
initialNumToRender={10}
ListFooterComponent={this._renderFooter}
style={[styles.list, {paddingRight: 0}]}
/>);
}
}
const styles = StyleSheet.create({
listItem: {
marginLeft: 0
},
listItemTitle: {
fontSize: 14,
},
listItemTime: {
fontSize: 14,
color: '#666'
},
listItemSectionTitle: {
fontSize: 14,
fontWeight: 'bold',
},
loadingText: {
textAlign: 'center',
paddingBottom: 8
},
list: theme.card,
});