Stylistic fixes, etc
This commit is contained in:
parent
c02ad19f2b
commit
2554789f5f
10 changed files with 283 additions and 108 deletions
|
|
@ -9,6 +9,7 @@
|
|||
import moment from 'moment';
|
||||
import React from 'react';
|
||||
import {ScrollView, StyleSheet, Image, Text, View, TouchableOpacity, Dimensions} from 'react-native';
|
||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||
import Markdown, {PluginContainer} from 'react-native-markdown-renderer';
|
||||
import SegmentedControlTab from 'react-native-segmented-control-tab';
|
||||
import SettingsList, {Header, Item} from 'react-native-settings-list';
|
||||
|
|
@ -21,16 +22,116 @@ import EventsStore from '../stores/TournamentEventStore';
|
|||
import MemeleeViewController from './MemeleeViewController';
|
||||
|
||||
const w = Dimensions.get('screen').width;
|
||||
/* <View style={styles.tournamentInfoButtonsRow}>
|
||||
<TouchableOpacity style={styles.tournamentRegistrationButton} onPress={this.registerForTournament}>
|
||||
<Text style={styles.tournamentRegistrationButtonText}>Register</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity style={styles.tournamentBookmarkButton} onPress={this.registerForTournament}>
|
||||
<Text style={styles.tournamentRegistrationButtonText}>Bookmark</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
*/
|
||||
|
||||
const determineTabs = (tournament) => {
|
||||
const slugs = parseSlugs(tournament, null);
|
||||
const tabs = [
|
||||
// Actually can't do this without using what's pretty clearly a private API. :(
|
||||
// {slug: 'attendees', name: 'Attendees', screen: Constants.Screens.Attendees, adminOnly: false, data: []}
|
||||
{slug: 'attendees', icon: 'link', name: 'Attendees', url: 'https://smash.gg/tournament/' + slugs.tournament + '/attendees/players', adminOnly: false}
|
||||
];
|
||||
|
||||
if(
|
||||
tournament.gettingThere || tournament.lat || tournament.lng || tournament.mapsPlaceId || tournament.venueName ||
|
||||
tournament.venueAddress || tournament.city || tournament.addrState || tournament.countryCode || tournament.postalCode
|
||||
) tabs.push({
|
||||
slug: 'location',
|
||||
name: 'Location',
|
||||
icon: 'map-marker',
|
||||
screen: Constants.Screens.Location,
|
||||
adminOnly: false,
|
||||
data: {
|
||||
gettingThere: tournament.gettingThere,
|
||||
map: {
|
||||
lat: tournament.lat,
|
||||
lng: tournament.lng,
|
||||
mapsPlaceId: tournament.mapsPlaceId,
|
||||
},
|
||||
venue: {
|
||||
name: tournament.venueName,
|
||||
address: tournament.venueAddress,
|
||||
city: tournament.city,
|
||||
state: tournament.addrState,
|
||||
country: tournament.countryCode,
|
||||
postalCode: tournament.postalCode
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
tabs.push({
|
||||
slug: 'contact',
|
||||
name: 'Contact',
|
||||
icon: 'email',
|
||||
screen: Constants.Screens.Contact,
|
||||
adminOnly: false,
|
||||
data: {
|
||||
email: tournament.contactEmail,
|
||||
info: tournament.contactInfo,
|
||||
phone: tournament.contactPhone,
|
||||
twitter: tournament.contactTwitter
|
||||
}
|
||||
});
|
||||
|
||||
if(tournament.rules && tournament.rules !== '') {
|
||||
if(tournament.rules.startsWith('http://') || tournament.rules.startsWith('https://')) {
|
||||
tabs.push({slug: 'rules', icon: 'link', name: 'Rules', url: tournament.rules, adminOnly: false});
|
||||
} else {
|
||||
tabs.push({slug: 'rules', name: 'Rules', icon: 'file-document-box', info: tournament.rules, adminOnly: false});
|
||||
}
|
||||
}
|
||||
|
||||
if(tournament.prizes && tournament.prizes !== '') {
|
||||
if(tournament.prizes.startsWith('http://') || tournament.prizes.startsWith('https://')) {
|
||||
tabs.push({slug: 'prizes', name: 'Prizes', icon: 'trophy', url: tournament.prizes, adminOnly: false});
|
||||
} else {
|
||||
tabs.push({slug: 'prizes', name: 'Prizes', icon: 'trophy', info: tournament.prizes, adminOnly: false});
|
||||
}
|
||||
}
|
||||
|
||||
if(tournament.publishing && tournament.publishing.fantasy)
|
||||
tabs.push({
|
||||
slug: 'fantasy',
|
||||
name: 'Fantasy',
|
||||
icon: 'chart-timeline',
|
||||
url: 'https://smash.gg/tournament/' + slugs.tournament + '/fantasy/',
|
||||
adminOnly: false
|
||||
});
|
||||
|
||||
const generatedTabs = tournament.generatedTabs;
|
||||
if(generatedTabs) {
|
||||
const objs = Object.keys(generatedTabs).map(key => generatedTabs[key]);
|
||||
|
||||
objs.forEach(tab => {
|
||||
Object.keys(tab).map(key => ({
|
||||
slug: key,
|
||||
name: tab[key].name,
|
||||
adminOnly: tab[key].adminOnly,
|
||||
icon: 'link',
|
||||
url: 'https://smash.gg/tournament/' + slugs.tournament + '/' + key
|
||||
})).filter(tab => !tab.adminOnly || tab.adminOnly === false).forEach(tab => tabs.push(tab));
|
||||
});
|
||||
}
|
||||
|
||||
const links = tournament.links;
|
||||
if(links) {
|
||||
Object.keys(tournament.links).forEach(key => {
|
||||
tabs.push({
|
||||
slug: key,
|
||||
icon: 'link',
|
||||
name: key[0].toUpperCase() + key.substring(1),
|
||||
url: links[key]
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return tabs;
|
||||
}
|
||||
|
||||
const SIcon = (icon) => (
|
||||
<View style={{height:30, marginLeft:10, alignSelf:'center'}}>
|
||||
<Icon name={icon} size={26} color={styles.tournamentPromoIconColors.eventsCount} />
|
||||
</View>
|
||||
);
|
||||
|
||||
export default class TournamentInfoViewController extends MemeleeViewController {
|
||||
state = {
|
||||
|
|
@ -39,50 +140,9 @@ export default class TournamentInfoViewController extends MemeleeViewController
|
|||
};
|
||||
|
||||
componentWillMount = () => {
|
||||
const tabs = [
|
||||
{slug: 'attendees', name: 'Attendees', screen: Constants.Screens.Attendees, adminOnly: false},
|
||||
{slug: 'location', name: 'Location', screen: Constants.Screens.Location, adminOnly: false},
|
||||
{slug: 'contact', name: 'Contact', screen: Constants.Screens.Contact, adminOnly: false}
|
||||
];
|
||||
|
||||
if(this.props.tournament.rules && this.props.tournament.rules !== '') {
|
||||
if(this.props.tournament.rules.startsWith('http://') || this.props.tournament.rules.startsWith('https://')) {
|
||||
tabs.push({slug: 'rules', name: 'Rules', url: this.props.tournament.rules, adminOnly: false});
|
||||
} else {
|
||||
tabs.push({slug: 'rules', name: 'Rules', info: this.props.tournament.rules, adminOnly: false});
|
||||
}
|
||||
}
|
||||
|
||||
if(this.props.tournament.prizes && this.props.tournament.prizes !== '') {
|
||||
if(this.props.tournament.prizes.startsWith('http://') || this.props.tournament.prizes.startsWith('https://')) {
|
||||
tabs.push({slug: 'prizes', name: 'Prizes', url: this.props.tournament.prizes, adminOnly: false});
|
||||
} else {
|
||||
tabs.push({slug: 'prizes', name: 'Prizes', info: this.props.tournament.prizes, adminOnly: false});
|
||||
}
|
||||
}
|
||||
|
||||
if(this.props.tournament.publishing && this.props.tournament.publishing.fantasy)
|
||||
tabs.push({
|
||||
slug: 'fantasy',
|
||||
name: 'Fantasy',
|
||||
url: 'https://smash.gg/tournament/' + parseSlugs(this.props.tournament, null).tournament + '/fantasy/',
|
||||
adminOnly: false
|
||||
});
|
||||
|
||||
const generatedTabs = this.props.tournament.generatedTabs;
|
||||
if(generatedTabs) {
|
||||
const objs = Object.keys(generatedTabs).map(key => generatedTabs[key]);
|
||||
|
||||
objs.forEach(tab => {
|
||||
Object.keys(tab).map(key => ({
|
||||
slug: key,
|
||||
name: tab[key].name,
|
||||
adminOnly: tab[key].adminOnly
|
||||
})).filter(tab => !tab.adminOnly || tab.adminOnly === false).forEach(tab => tabs.push(tab));
|
||||
});
|
||||
}
|
||||
|
||||
this.setState({tabs: tabs});
|
||||
this.setState({
|
||||
tabs: determineTabs(this.props.tournament)
|
||||
});
|
||||
}
|
||||
|
||||
onEventTapped = (evt) => {
|
||||
|
|
@ -100,7 +160,7 @@ export default class TournamentInfoViewController extends MemeleeViewController
|
|||
return this.props.navigator.push({
|
||||
screen: tab.screen,
|
||||
title: tab.name,
|
||||
passProps: {data: []},
|
||||
passProps: {data: tab.data},
|
||||
navigatorStyle: {tabBarHidden: true}
|
||||
});
|
||||
|
||||
|
|
@ -146,7 +206,7 @@ export default class TournamentInfoViewController extends MemeleeViewController
|
|||
</View>
|
||||
|
||||
<SettingsList style={styles.tournamentEventsWrapper} borderWidth={s.borderBottomWidth} borderColor={s.borderBottomColor}>
|
||||
{this.state.tabs.map(tab => <Item key={tab.slug} {...ss} title={tab.name} onPress={() => this.handleTab(tab)} />)}
|
||||
{this.state.tabs.map(tab => <Item icon={SIcon(tab.icon)} key={tab.slug} {...ss} title={tab.name} onPress={() => this.handleTab(tab)} />)}
|
||||
</SettingsList>
|
||||
</View>
|
||||
) : null}
|
||||
|
|
|
|||
Reference in a new issue