import { StyleSheet, View, Platform, SectionList, TouchableOpacity } from 'react-native'; import { Card, Text, Button, Spinner, ArrowForwardIcon, HStack } from 'native-base'; import React from 'react'; import moment from 'moment'; import 'moment/locale/nb'; import theme from '../../theme'; moment.locale('nb'); const _formatTime = (time) => { return moment(time).format('llll'); }; const EventList = ({ eventsSectioned, refreshing, handleRefresh, handleLoadMore, showEvent, error, loading }) => { const _renderItem = ({ item }) => ( { showEvent(item); }} style={styles.listItem} > {item.title.decoded} {_formatTime(item.start_time)} ); const _renderSectionHeader = ({ section }) => { return ( {section.title} ); }; const _renderFooter = () => { if (!loading) { return null; } return ( ); }; if (error) { return ( Kunne ikke hente programmet... ); } return ( item.id} refreshing={refreshing} onRefresh={handleRefresh} onEndReached={handleLoadMore} onEndReachedThreshould={10} initialNumToRender={10} ListFooterComponent={_renderFooter} style={[styles.card, styles.list]} ListHeaderComponent={() => { return ; }} /> ); }; export default EventList; const styles = StyleSheet.create({ listItem: { backgroundColor: 'white', padding: 8, borderBottomWidth: 1, borderBottomColor: '#ccc', }, listItemTitle: { fontSize: 14, }, listItemTime: { fontSize: 14, color: '#666', }, sectionHeader: { backgroundColor: 'white', ...Platform.select({ ios: { marginBottom: -8 }, }), paddingTop: 8, paddingLeft: 8, paddingRight: 8, }, sectionTitle: { fontSize: 16, fontWeight: 'bold', }, loadingText: { textAlign: 'center', paddingBottom: 8, }, card: theme.card, list: { padding: 0, marginTop: 0, marginBottom: 0, backgroundColor: 'transparent', }, listHeader: { paddingTop: 8, }, });