/**
* UpcomingTournamentsViewController
*
* Yeah, I do it iOS style. Handles fetching and displaying upcoming tournaments.
*
* @copyright Ryan McGrath 2018.
*/
import moment from 'moment';
import React from 'react';
import {FlatList, View, ActivityIndicator} from 'react-native';
import {inject, observer} from 'mobx-react/native';
import {SearchBar} from 'react-native-elements';
import styles from '../styles';
import Constants from '../utils/Constants';
import MemeleeViewController from './MemeleeViewController';
import TournamentRow from './components/TournamentRow';
const keyExtractor = (item, index) => item.id;
@inject('Tournaments') @observer
export default class UpcomingTournamentsViewController extends MemeleeViewController {
componentWillMount() {
this.props.Tournaments.fetchFeatured();
}
onTap = (tournament) => {
this.props.navigator.push({
screen: Constants.Screens.TournamentInfoScreen,
title: tournament.name,
passProps: {tournament: tournament},
navigatorStyle: {tabBarHidden: true}
});
}
renderHeader = () => (
)
renderFooter = () => (
this.props.Tournaments.fetchingData ? (
) : null
)
renderItem = ({item}) => ()
render() {
const props = {
data: this.props.Tournaments.fetchingData ? [] :
this.props.Tournaments.mode === 'search' ? this.props.Tournaments.searchResults :
this.props.Tournaments.tournamentsList,
keyExtractor: keyExtractor,
contentContainerStyle: styles.tournamentsListView,
ListHeaderComponent: this.renderHeader,
ListFooterComponent: this.renderFooter,
renderItem: this.renderItem
};
return
}
}