show standings in a table
This commit is contained in:
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||
import '../news/feed.dart';
|
||||
|
||||
class Sport extends StatelessWidget {
|
||||
|
||||
static final List<Item> colorList = <Item>[
|
||||
const Item('Football', Colors.green,[3]),
|
||||
const Item("Basketball", Colors.red,[5,13]),
|
||||
@@ -15,9 +14,9 @@ class Sport extends StatelessWidget {
|
||||
|
||||
final feed = Feed(); // was var not final
|
||||
|
||||
bool genderSportSwitch = false; //determines if sport needs the gender switch
|
||||
final String imageMale = 'images/male.png';
|
||||
final String imageFemale = 'images/female.png';
|
||||
static bool genderSportSwitch = false; //determines if sport needs the gender switch
|
||||
static bool genderSport = false; //determines which gender switch is set M - false / F - True
|
||||
static int sport_ID;
|
||||
final String sport;
|
||||
@@ -70,9 +69,6 @@ class Sport extends StatelessWidget {
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name)),
|
||||
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name)),
|
||||
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name)),
|
||||
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name)),
|
||||
],
|
||||
),
|
||||
drawer: Drawer(
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class sport_standings_basketball {
|
||||
final int id;
|
||||
final String displayName;
|
||||
final String image;
|
||||
|
||||
/*final String position;
|
||||
|
||||
// -- Conference stats --
|
||||
final String conferenceRecord;
|
||||
final String gamesBehind;
|
||||
final String conferencePercentRecord;
|
||||
|
||||
// -- Overall stats --
|
||||
final String overallRecord;
|
||||
final String overallPercentRecord;
|
||||
final String homeRecord;
|
||||
final String awayRecord;
|
||||
final String gameStreak;*/
|
||||
|
||||
// -- Polls stats --
|
||||
//final String apRecord;
|
||||
//final String usaRecord;
|
||||
|
||||
sport_standings_basketball(
|
||||
this.id, {
|
||||
this.displayName,
|
||||
this.image,
|
||||
|
||||
/*this.position,
|
||||
|
||||
this.conferenceRecord,
|
||||
this.gamesBehind,
|
||||
this.conferencePercentRecord,
|
||||
|
||||
this.overallRecord,
|
||||
this.overallPercentRecord,
|
||||
this.homeRecord,
|
||||
this.awayRecord,
|
||||
this.gameStreak,*/
|
||||
|
||||
//this.apRecord,
|
||||
//this.usaRecord,
|
||||
});
|
||||
|
||||
factory sport_standings_basketball.fromJson(Map<String, dynamic> json) {
|
||||
return sport_standings_basketball(
|
||||
json['id'],
|
||||
displayName: json['standings']['entries']['team']['displayName'],
|
||||
image: json['standings']['entries']['team']['logos']['href'],
|
||||
|
||||
/*for (team in json['standings']['entries']) {
|
||||
var stats = new Map<String, dynamic>();
|
||||
for (stat in team['stats']) {
|
||||
stats[stat['type']] = stat;
|
||||
}
|
||||
|
||||
var team_widget = basketball_widget(
|
||||
position: stats['playoffseed']['displayValue'],
|
||||
|
||||
conferenceRecord: stats['vsconf']['displayValue'],
|
||||
gamesBehind: stats['vsconf_gamesbehind']['displayValue'],
|
||||
conferencePercentRecord: stats['vsconf_winpercent']['displayValue'],
|
||||
|
||||
|
||||
overallRecord: stats['total']['displayValue'],
|
||||
overallPercentRecord: stats['winpercent']['displayValue'],
|
||||
homeRecord: stats['home']['displayValue'],
|
||||
awayRecord: stats['road']['displayValue'],
|
||||
gameStreak: stats['streak']['displayValue'],
|
||||
|
||||
//apRecord: json['standings']['entries']['stats']['displayValue'],
|
||||
//usaRecord: json['standings']['entries']['stats']['displayValue'],
|
||||
)
|
||||
}*/
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class StandingsCard extends StatelessWidget {
|
||||
const StandingsCard({
|
||||
Key key,
|
||||
@required this.team,
|
||||
}) : super(key: key);
|
||||
|
||||
final sport_standings_basketball team;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Card(
|
||||
child: ListTile(
|
||||
leading: Image.network(
|
||||
team.image,
|
||||
width: 35.0,
|
||||
),
|
||||
title: Text(
|
||||
team.displayName,
|
||||
),
|
||||
//decoration: decoration,
|
||||
//child: body,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/*class sport_standings_football {
|
||||
final int id;
|
||||
final String displayName;
|
||||
final String image;
|
||||
|
||||
final String position;
|
||||
|
||||
// -- Conference stats --
|
||||
final String conferenceRecord;
|
||||
final String gamesBehind;
|
||||
final String conferencePercentRecord;
|
||||
|
||||
// -- Overall stats --
|
||||
final String overallRecord;
|
||||
final String overallPercentRecord;
|
||||
final String homeRecord;
|
||||
final String awayRecord;
|
||||
final String gameStreak;
|
||||
|
||||
// -- Polls stats --
|
||||
final String apRecord;
|
||||
final String usaRecord;
|
||||
|
||||
sport_standings_football(
|
||||
this.id, {
|
||||
this.displayName,
|
||||
this.image,
|
||||
|
||||
this.position,
|
||||
|
||||
this.conferenceRecord,
|
||||
this.gamesBehind,
|
||||
this.conferencePercentRecord,
|
||||
|
||||
this.overallRecord,
|
||||
this.overallPercentRecord,
|
||||
this.homeRecord,
|
||||
this.awayRecord,
|
||||
this.gameStreak,
|
||||
|
||||
this.apRecord,
|
||||
this.usaRecord,
|
||||
});
|
||||
|
||||
factory sport_standings_football.fromJson(Map<String, dynamic> json) {
|
||||
return sport_standings_football(
|
||||
json['id'],
|
||||
displayName: json['standings']['entries']['team']['displayName'],
|
||||
image: json['standings']['entries']['team']['logos']['href'],
|
||||
|
||||
for (team in json['standings']['entries']) {
|
||||
var stats = new Map<String, dynamic>();
|
||||
for (stat in team['stats']) {
|
||||
stats[stat['type']] = stat;
|
||||
}
|
||||
|
||||
var team_widget = basketball_widget(
|
||||
position: stats['playoffseed']['displayValue'],
|
||||
|
||||
conferenceRecord: stats['vsconf']['displayValue'],
|
||||
gamesBehind: stats['vsconf_gamesbehind']['displayValue'],
|
||||
conferencePercentRecord: stats['vsconf_winpercent']['displayValue'],
|
||||
|
||||
|
||||
overallRecord: stats['total']['displayValue'],
|
||||
overallPercentRecord: stats['winpercent']['displayValue'],
|
||||
homeRecord: stats['home']['displayValue'],
|
||||
awayRecord: stats['road']['displayValue'],
|
||||
gameStreak: stats['streak']['displayValue'],
|
||||
|
||||
//apRecord: json['standings']['entries']['stats']['displayValue'],
|
||||
//usaRecord: json['standings']['entries']['stats']['displayValue'],
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class StandingsCard extends StatelessWidget {
|
||||
const StandingsCard({
|
||||
Key key,
|
||||
@required this.team,
|
||||
}) : super(key: key);
|
||||
|
||||
final sport_standings_football team;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var decoration = BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: NetworkImage(
|
||||
team.image,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
var body = Column(
|
||||
verticalDirection: VerticalDirection.up,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
team.displayName,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
return Expanded(
|
||||
child: Card(
|
||||
child: ListTile(
|
||||
leading: Image.network(
|
||||
team.image,
|
||||
width: 35.0,
|
||||
),
|
||||
title: Text(
|
||||
team.displayName,
|
||||
),
|
||||
//decoration: decoration,
|
||||
//child: body,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}*/
|
||||
@@ -1,105 +1,29 @@
|
||||
import 'package:capstone_hungry_hippos/models/School.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../team_standings.dart';
|
||||
|
||||
class Standing extends StatelessWidget {
|
||||
/*final _schools = [
|
||||
School("North Texas Mean Green",AssetImage('assets/school_logos/NorthTexas.png'), 14, 4),
|
||||
School("Louisiana Tech Bulldogs",AssetImage('assets/school_logos/LT.png'), 13, 5),
|
||||
School("Western Kentucky Hilltoppers",AssetImage('assets/school_logos/wku.png'), 13, 5),
|
||||
School("Charlotte 49ers",AssetImage('assets/school_logos/uncc.png'), 10, 8),
|
||||
School("Marshall Thundering Herd",AssetImage('assets/school_logos/Marshall.png'), 10, 8),
|
||||
School("Florida Int'L Panthers",AssetImage('assets/school_logos/FIU.png'), 9, 9),
|
||||
School("UAB Blazers",AssetImage('assets/school_logos/UAB.png'), 9, 9),
|
||||
School("Old Dominion Monarchs",AssetImage('assets/school_logos/ODU.png'), 9, 9),
|
||||
School("Florida Atlantic Owl",AssetImage('assets/school_logos/FAU.png'), 8, 10),
|
||||
School("UTEP Miners",AssetImage('assets/school_logos/UTEP.png'), 8, 10),
|
||||
School("UTSA Roadrunners",AssetImage('assets/school_logos/UTSA.png'), 7, 11),
|
||||
School("Rice Owls",AssetImage('assets/school_logos/RiceOwls.png'), 7, 11),
|
||||
School("Southern Miss Golden Eagles",AssetImage('assets/school_logos/SouthernMiss.png'), 5, 13),
|
||||
School("Middle Tennessee Blue Raiders",AssetImage('assets/school_logos/MT.png'), 4, 14),
|
||||
];*/
|
||||
final int sport_id;
|
||||
final String sport_name;
|
||||
|
||||
final List sport;
|
||||
Standing(this.sport);
|
||||
|
||||
final teams = Team_Standings();
|
||||
Standing(List args)
|
||||
: sport_id = args[0],
|
||||
sport_name = args[1];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// *----- OLD CODE -------*
|
||||
/*return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: false,
|
||||
title: Text("49ers"),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: Text(
|
||||
"W L ",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
alignment: Alignment(.85, 0),
|
||||
height: 20,
|
||||
color: Colors.grey,
|
||||
),
|
||||
|
||||
SportLine(s: _schools[0], position: 1,),
|
||||
SportLine(s: _schools[1], position: 2,),
|
||||
SportLine(s: _schools[2], position: 3,),
|
||||
SportLine(s: _schools[3], position: 4,),
|
||||
SportLine(s: _schools[4], position: 5,),
|
||||
SportLine(s: _schools[5], position: 6,),
|
||||
SportLine(s: _schools[6], position: 7,),
|
||||
SportLine(s: _schools[7], position: 8,),
|
||||
SportLine(s: _schools[8], position: 9,),
|
||||
SportLine(s: _schools[9], position: 10,),
|
||||
SportLine(s: _schools[10], position: 11,),
|
||||
SportLine(s: _schools[11], position: 12,),
|
||||
SportLine(s: _schools[12], position: 13,),
|
||||
SportLine(s: _schools[13], position: 14,),
|
||||
],
|
||||
),
|
||||
),
|
||||
);*/
|
||||
|
||||
// *----- Testing CODE -------*
|
||||
//var standings = Team_Standings(sport[0]);
|
||||
return StatefulBuilder(
|
||||
builder: (context, StateSetter setState) => Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: false,
|
||||
title: Text("${sport[1]}" + " Standings"),
|
||||
title: Text("$sport_name Standings"),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
|
||||
/*body: Container (
|
||||
//child: standings,
|
||||
),*/
|
||||
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
HorizontalStandings(teamStandings: teams),
|
||||
HorizontalStandings(sportName: sport_name,),
|
||||
],
|
||||
),
|
||||
|
||||
/*body: SingleChildScrollView (
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: standings,
|
||||
alignment: Alignment(.85, 0),
|
||||
height: 20,
|
||||
color: Colors.grey,
|
||||
),
|
||||
],
|
||||
),
|
||||
),*/
|
||||
|
||||
drawer: Drawer(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
@@ -128,73 +52,3 @@ class Standing extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*class SportLine extends StatelessWidget {
|
||||
const SportLine({
|
||||
Key key,
|
||||
@required
|
||||
this.position,
|
||||
this.s
|
||||
}) : super(key: key);
|
||||
|
||||
final School s;
|
||||
final int position;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
int w = s.win;
|
||||
int l = s.loss;
|
||||
return Container(
|
||||
color: evenOdd(position),
|
||||
height: 60,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: 55,
|
||||
width: 20,
|
||||
//color: Colors.orange,
|
||||
child: Center(
|
||||
child: Text(
|
||||
"$position",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
)),
|
||||
),
|
||||
Container(
|
||||
//color: Colors.blue,
|
||||
width: 55,
|
||||
child: Image(
|
||||
image: s.logo,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 5,
|
||||
//color: Colors.red,
|
||||
),
|
||||
Container(
|
||||
//color: Colors.pinkAccent,
|
||||
width: 220,
|
||||
child: Text(s.name),
|
||||
),
|
||||
Container(
|
||||
//color: Colors.orange,
|
||||
width: 35,
|
||||
child: Text(
|
||||
"$w",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
)),
|
||||
Container(
|
||||
//color: Colors.blue,
|
||||
width: 35,
|
||||
child: Text(
|
||||
" $l",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
))
|
||||
],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Color evenOdd(int i) {
|
||||
Color c = i % 2 == 0 ? Colors.black12 : Colors.white30;
|
||||
return c;
|
||||
}
|
||||
}*/
|
||||
|
||||
@@ -1,194 +1,122 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import 'screens/sport.dart' as globals;
|
||||
import 'screens/sport_standings_basketball.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
class Team_Standings {
|
||||
int sport_ID;
|
||||
String sportUrl;
|
||||
|
||||
Future<List<sport_standings_basketball>> getTeams() async {
|
||||
print(globals.Sport.sport_ID);
|
||||
|
||||
switch(globals.Sport.sport_ID.toString()) {
|
||||
case "3" : { //football
|
||||
sportUrl = 'https://site.web.api.espn.com/apis/v2/sports/football/college-football/standings?region=us&lang=en&contentorigin=espn&group=12&level=3&sort=leaguewinpercent%3Adesc%2Cvsconf_wins%3Adesc%2Cvsconf_gamesbehind%3Aasc%2Cvsconf_playoffseed%3Aasc%2Cwins%3Adesc%2Closses%3Adesc%2Cplayoffseed%3Aasc%2Calpha%3Aasc';
|
||||
break;
|
||||
}
|
||||
case "5" : { //men basketball
|
||||
sportUrl = 'https://site.web.api.espn.com/apis/v2/sports/basketball/mens-college-basketball/standings?region=us&lang=en&contentorigin=espn&group=11&sort=playoffseed%3Aasc%2Cvsconf_winpercent%3Adesc%2Cvsconf_wins%3Adesc%2Cvsconf_losses%3Aasc%2Cvsconf_gamesbehind%3Aasc&includestats=playoffseed%2Cvsconf%2Cvsconf_gamesbehind%2Cvsconf_winpercent%2Ctotal%2Cwinpercent%2Chome%2Croad%2Cstreak%2Cvsaprankedteams%2Cvsusarankedteams';
|
||||
break;
|
||||
}
|
||||
case "13" : {
|
||||
sportUrl = 'https://site.web.api.espn.com/apis/v2/sports/basketball/womens-college-basketball/standings?region=us&lang=en&contentorigin=espn&sort=leaguewinpercent%3Adesc%2Cvsconf_winpercent%3Adesc%2Cvsconf_gamesbehind%3Aasc%2Cvsconf_playoffseed%3Aasc%2Cwins%3Adesc%2Closses%3Adesc%2Cplayoffseed%3Aasc%2Calpha%3Aasc&group=11';
|
||||
break;
|
||||
}
|
||||
}
|
||||
print(sportUrl.toString());
|
||||
|
||||
http.Response response = await http.get(sportUrl);
|
||||
Iterable games = json.decode(response.body);
|
||||
|
||||
return games.map((e) => sport_standings_basketball.fromJson(e)).toList();
|
||||
}
|
||||
}
|
||||
import 'screens/sport.dart';
|
||||
|
||||
class HorizontalStandings extends StatelessWidget {
|
||||
final Team_Standings teamStandings;
|
||||
const HorizontalStandings({Key key, @required this.teamStandings,}) : super(key: key);
|
||||
static final standingsUrls = {
|
||||
"football": [
|
||||
"https://site.web.api.espn.com/apis/v2/sports/football/college-football/standings?region=us&lang=en&contentorigin=espn&group=12&sort=leaguewinpercent%3Adesc%2Cvsconf_wins%3Adesc%2Cvsconf_gamesbehind%3Aasc%2Cvsconf_playoffseed%3Aasc%2Cwins%3Adesc%2Closses%3Adesc%2Cplayoffseed%3Aasc%2Calpha%3Aasc",
|
||||
],
|
||||
"basketball": [
|
||||
"https://site.web.api.espn.com/apis/v2/sports/basketball/mens-college-basketball/standings?region=us&lang=en&contentorigin=espn&group=11&sort=leaguewinpercent%3Adesc%2Cvsconf_wins%3Adesc%2Cvsconf_gamesbehind%3Aasc%2Cvsconf_playoffseed%3Aasc%2Cwins%3Adesc%2Closses%3Adesc%2Cplayoffseed%3Aasc%2Calpha%3Aasc",
|
||||
"https://site.web.api.espn.com/apis/v2/sports/basketball/womens-college-basketball/standings?region=us&lang=en&contentorigin=espn&group=11&sort=leaguewinpercent%3Adesc%2Cvsconf_wins%3Adesc%2Cvsconf_gamesbehind%3Aasc%2Cvsconf_playoffseed%3Aasc%2Cwins%3Adesc%2Closses%3Adesc%2Cplayoffseed%3Aasc%2Calpha%3Aasc",
|
||||
],
|
||||
};
|
||||
|
||||
final String sportName;
|
||||
|
||||
const HorizontalStandings({Key key, this.sportName}) : super(key: key);
|
||||
|
||||
Future<Widget> getStandingsTable(String url) async {
|
||||
var response = await http.get(url);
|
||||
var body = json.decode(response.body);
|
||||
if (body['children'].length == 0) body['children'] = [body];
|
||||
|
||||
var res = Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
"${body['name']}",
|
||||
style: TextStyle(fontSize: 24),
|
||||
),
|
||||
Column(
|
||||
children: body['children']
|
||||
.map((conference) {
|
||||
var teams = conference['standings']['entries'].map((team) {
|
||||
var stats = {};
|
||||
for (var stat in team['stats']) {
|
||||
stats[stat['name']] = stat;
|
||||
}
|
||||
|
||||
var source = team;
|
||||
|
||||
return {'stats': stats, 'source': source};
|
||||
}).toList();
|
||||
|
||||
var interested = {
|
||||
'football': ['vsConf', 'streak'],
|
||||
'basketball': ['Season','streak']
|
||||
}[sportName.toLowerCase()];
|
||||
|
||||
var table = Table(
|
||||
defaultVerticalAlignment:
|
||||
TableCellVerticalAlignment.middle,
|
||||
children: teams
|
||||
.map((data) {
|
||||
var stats = data['stats'];
|
||||
var team = data['source'];
|
||||
|
||||
var row = interested
|
||||
.map((e) => stats[e])
|
||||
.where((e) => e != null)
|
||||
.map((s) => Text("${s['displayValue']}"))
|
||||
.cast<Widget>()
|
||||
.toList();
|
||||
|
||||
row.insert(0, Text(team['team']['name']));
|
||||
row.insert(
|
||||
0,
|
||||
Image.network(team['team']['logos'][0]['href'],
|
||||
height: 40));
|
||||
|
||||
return TableRow(children: row);
|
||||
})
|
||||
.cast<TableRow>()
|
||||
.toList(),
|
||||
);
|
||||
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
conference['shortName'],
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
table,
|
||||
],
|
||||
);
|
||||
})
|
||||
.cast<Widget>()
|
||||
.toList()),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var sportUrl = standingsUrls[sportName.toLowerCase()];
|
||||
var idx = (Sport.genderSportSwitch && Sport.genderSport) ? 1 : 0;
|
||||
var url = sportUrl[idx];
|
||||
|
||||
return Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
if (globals.Sport.sport_ID.toString() == "5" || globals.Sport.sport_ID.toString() == "13") // M-W Basketball
|
||||
Expanded(
|
||||
child: FutureBuilder(
|
||||
future: teamStandings.getTeams(),
|
||||
builder: (ctx, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return Center(child: CircularProgressIndicator());
|
||||
} else {
|
||||
List<sport_standings_basketball> teams = snapshot.data;
|
||||
return ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: snapshot.data.length,
|
||||
itemBuilder: (ctx, idx) {
|
||||
return StandingsCard(
|
||||
team: teams[idx],
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
FutureBuilder<Widget>(
|
||||
future: getStandingsTable(url),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasError) return Text(snapshot.error.toString());
|
||||
if (!snapshot.hasData) return CircularProgressIndicator();
|
||||
|
||||
return snapshot.data;
|
||||
},
|
||||
),
|
||||
)
|
||||
/*else if (globals.Sport.sport_ID.toString() == "3") // Football
|
||||
Expanded(
|
||||
child: FutureBuilder(
|
||||
future: teamStandings.getTeams(),
|
||||
builder: (ctx, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return Center(child: CircularProgressIndicator());
|
||||
} else {
|
||||
List<sport_standings_football> teams = snapshot.data;
|
||||
return ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: snapshot.data.length,
|
||||
itemBuilder: (ctx, idx) {
|
||||
return StandingsCard(
|
||||
team: teams[idx],
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),*/
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//Delete later (not used)
|
||||
/*class Team_Standings extends StatefulWidget {
|
||||
final int sportID;
|
||||
Team_Standings(this.sportID);
|
||||
|
||||
@override
|
||||
_Standings createState() => _Standings(sportID);
|
||||
}
|
||||
|
||||
List _selectedTeams;
|
||||
|
||||
class _Standings extends State<Team_Standings> {
|
||||
int sportID;
|
||||
String sportUrl;
|
||||
_Standings(this.sportID);
|
||||
|
||||
Future<List<sport_standings_basketball>> getTeams() async {
|
||||
print(sportID);
|
||||
|
||||
switch(sportID.toString()) {
|
||||
case "3" : { //football
|
||||
sportUrl = 'https://site.web.api.espn.com/apis/v2/sports/football/college-football/standings?region=us&lang=en&contentorigin=espn&group=12&level=3&sort=leaguewinpercent%3Adesc%2Cvsconf_wins%3Adesc%2Cvsconf_gamesbehind%3Aasc%2Cvsconf_playoffseed%3Aasc%2Cwins%3Adesc%2Closses%3Adesc%2Cplayoffseed%3Aasc%2Calpha%3Aasc';
|
||||
break;
|
||||
}
|
||||
case "5" : { //men basketball
|
||||
sportUrl = 'https://site.web.api.espn.com/apis/v2/sports/basketball/mens-college-basketball/standings?region=us&lang=en&contentorigin=espn&group=11&sort=playoffseed%3Aasc%2Cvsconf_winpercent%3Adesc%2Cvsconf_wins%3Adesc%2Cvsconf_losses%3Aasc%2Cvsconf_gamesbehind%3Aasc&includestats=playoffseed%2Cvsconf%2Cvsconf_gamesbehind%2Cvsconf_winpercent%2Ctotal%2Cwinpercent%2Chome%2Croad%2Cstreak%2Cvsaprankedteams%2Cvsusarankedteams';
|
||||
break;
|
||||
}
|
||||
case "13" : {
|
||||
sportUrl = 'https://site.web.api.espn.com/apis/v2/sports/basketball/womens-college-basketball/standings?region=us&lang=en&contentorigin=espn&sort=leaguewinpercent%3Adesc%2Cvsconf_winpercent%3Adesc%2Cvsconf_gamesbehind%3Aasc%2Cvsconf_playoffseed%3Aasc%2Cwins%3Adesc%2Closses%3Adesc%2Cplayoffseed%3Aasc%2Calpha%3Aasc&group=11';
|
||||
break;
|
||||
}
|
||||
}
|
||||
print(sportUrl.toString());
|
||||
|
||||
http.Response response = await http.get(sportUrl);
|
||||
Iterable games = json.decode(response.body);
|
||||
|
||||
return games.map((e) => sport_standings_basketball.fromJson(e)).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_selectedTeams = [];
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
_buildBasketballStandings(),
|
||||
Expanded(child: _eventLister()),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBasketballStandings() {
|
||||
return Container(
|
||||
margin: EdgeInsets.all(15),
|
||||
|
||||
child: Table(
|
||||
border: TableBorder(
|
||||
horizontalInside: BorderSide(
|
||||
color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green
|
||||
),
|
||||
verticalInside: BorderSide(
|
||||
color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green
|
||||
),
|
||||
top: BorderSide(
|
||||
color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green
|
||||
),
|
||||
bottom: BorderSide(
|
||||
color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green
|
||||
),
|
||||
),
|
||||
columnWidths: {0: FractionColumnWidth(.3), 1: FractionColumnWidth(.4), 2: FractionColumnWidth(.6)},
|
||||
children: [
|
||||
TableRow( children: [
|
||||
Column(children:[Text('')]),
|
||||
Column(children:[Text('Conference')]),
|
||||
Column(children:[Text('Overall')]),
|
||||
]),
|
||||
TableRow( children: [
|
||||
Column(children:[Text('')]),
|
||||
Column(children:[Text('W-L GB PCT')]),
|
||||
Column(children:[Text('PCT HOME AWAY STRK')]),
|
||||
]),
|
||||
|
||||
// ** Make loop based on number of teams **
|
||||
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}*/
|
||||
Reference in New Issue
Block a user