More fixes/patches

This commit is contained in:
Ryan McGrath 2018-04-11 23:16:10 -04:00
parent 1f90ca2575
commit c02ad19f2b
No known key found for this signature in database
GPG key ID: 811674B62B666830
18 changed files with 582 additions and 239 deletions

View file

@ -8,40 +8,61 @@
import moment from 'moment';
import React from 'react';
import {ScrollView, Image, Text, View, TouchableOpacity} from 'react-native';
import {ScrollView, StyleSheet, ActivityIndicator, Image, Text, View, TouchableOpacity} from 'react-native';
import {inject, observer} from 'mobx-react/native';
import Markdown from 'react-native-simple-markdown'
//import SmashGG from '../store';
import SegmentedControlTab from 'react-native-segmented-control-tab';
import SettingsList, {Header, Item} from 'react-native-settings-list';
import styles from '../styles';
import Constants from '../utils/Constants';
import MemeleeViewController from './MemeleeViewController';
const Loading = (props) => (
<View style={{paddingTop: 20}}>
<ActivityIndicator animating size="large" />
</View>
);
const Standings = (props) => (
props.error ? <View style={{padding: 20}}>
<Text style={styles.eventsErrorTextHeader}>No Standings Found</Text>
<Text style={styles.eventsErrorText}>Matches may not have been played yet.</Text>
</View> : <View>
<View style={{flexDirection: 'row', backgroundColor: '#010101'}}>
<Text style={{backgroundColor: '#010101', color: '#f9f9f9', padding: 8, paddingLeft: 58, width: 230}}>Players</Text>
<Text style={{backgroundColor: '#010101', color: '#f9f9f9', padding: 8}}>Losses</Text>
</View>
<ScrollView>
{props.standings.map(standing => (
<View key={standing.id} style={{flexDirection: 'row', borderBottomWidth: 1, borderBottomColor: 'gray'}}>
<Text key={standing.id} style={{padding: 8, width: 50, textAlign: 'center', backgroundColor: 'gray'}}>
{standing.standing}
</Text>
<Text style={{padding: 8, width: 180}}>{standing.name}</Text>
<View style={{padding: 8, flex: 1}}>{standing.losses.map(loss => <Text key={standing.id + loss} style={{flexShrink: 1}}>{loss}</Text>)}</View>
</View>
))}
</ScrollView>
</View>
);
const s = StyleSheet.flatten(styles.tournamentDetailsEventWrapper);
const Brackets = (props) => (
<SettingsList style={styles.tournamentEventsWrapper} borderWidth={s.borderBottomWidth} borderColor={s.borderBottomColor}>
{props.brackets.map(bracket => (
<Item key={bracket.name} itemWidth={50} title={bracket.name} backgroundColor={s.backgroundColor} style={styles.tournamentDetailsEventWrapper} titleStyle={styles.tournamentDetailsEventItem} onPress={() => props.onPress(bracket)} />
))}
</SettingsList>
);
@inject('Events') @observer
export default class EventInfoViewController extends MemeleeViewController {
state = {
standings: [],
brackets: []
};
componentWillMount() {
const evtSlugs = this.props.evt.slug.split('/');
const evtSlug = evtSlugs.length > 0 ? evtSlugs[evtSlugs.length - 1] : null;
const tournamentSlug = this.props.tournament.slugs[0].replace('tournament/', '');
if((evtSlug && evtSlug !== '') && (tournamentSlug && tournamentSlug != '')) {
SmashGG.fetchEventExpanded(tournamentSlug, evtSlug).then(this.updateBracketsData).catch(console.error);
SmashGG.fetchEventStandings(tournamentSlug, evtSlug).then(this.updateStandingsData).catch(console.error);
}
}
updateBracketsData = (data) => {
this.setState({brackets: data});
}
updateStandingsData = (data) => {
this.setState({standings: data});
}
state = {selectedIndex: 0};
onBracketPress = (bracket) => {
this.props.navigator.push({
screen: 'memelee.bracket',
screen: Constants.Screens.Bracket,
title: bracket.name,
backButtonTitle: 'Back',
passProps: {
@ -53,29 +74,25 @@ export default class EventInfoViewController extends MemeleeViewController {
});
}
render() {
return (<ScrollView>
<Text style={{padding: 8, backgroundColor: '#003366', fontSize: 16}}>Brackets</Text>
{this.state.brackets.map(bracket => (
<TouchableOpacity key={bracket.id} onPress={() => this.onBracketPress(bracket)}>
<Text style={{padding: 8, backgroundColor: 'gray'}}>{bracket.name}</Text>
</TouchableOpacity>
))}
swapIndex = (index) => {
this.setState({selectedIndex: index});
}
<Text style={{padding: 8, marginTop: 20, backgroundColor: '#003366', fontSize: 16}}>Standings</Text>
<View style={{flexDirection: 'row', backgroundColor: '#010101'}}>
<Text style={{backgroundColor: '#010101', color: '#f9f9f9', padding: 8, paddingLeft: 58, width: 230}}>Players</Text>
<Text style={{backgroundColor: '#010101', color: '#f9f9f9', padding: 8}}>Losses</Text>
</View>
{this.state.standings.map(standing => (
<View key={standing.id} style={{flexDirection: 'row', borderBottomWidth: 1, borderBottomColor: 'gray'}}>
<Text key={standing.id} style={{padding: 8, width: 50, textAlign: 'center', backgroundColor: 'gray'}}>
{standing.finalPlacement}
</Text>
<Text style={{padding: 8, width: 180}}>{standing.name}</Text>
<View style={{padding: 8, flex: 1}}>{standing.losses.map(loss => <Text key={standing.id + loss} style={{flexShrink: 1}}>{loss}</Text>)}</View>
</View>
))}
</ScrollView>);
render() {
return (<View>
<SegmentedControlTab values={['Standings', 'Brackets']} borderRadius={0} activeTabStyle={styles.tournamentInfoActiveTableStyle} tabStyle={styles.tournamentInfoTabsStyle} tabTextStyle={styles.tournamentInfoTabTextStyle} selectedIndex={this.state.selectedIndex} onTabPress={this.swapIndex} />
{this.state.selectedIndex === 0 ?
this.props.Events.fetchingStandingData ?
<Loading /> : <Standings standings={this.props.Events.standings} error={this.props.Events.standingsError} />
: null
}
{this.state.selectedIndex === 1 ?
this.props.Events.fetchingBracketData ?
<Loading /> : <Brackets error={this.props.Events.standingsError} brackets={this.props.Events.phases} onPress={this.onBracketPress} />
: null
}
</View>);
}
}