show standings in a table
This commit is contained in:
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
|||||||
import '../news/feed.dart';
|
import '../news/feed.dart';
|
||||||
|
|
||||||
class Sport extends StatelessWidget {
|
class Sport extends StatelessWidget {
|
||||||
|
|
||||||
static final List<Item> colorList = <Item>[
|
static final List<Item> colorList = <Item>[
|
||||||
const Item('Football', Colors.green,[3]),
|
const Item('Football', Colors.green,[3]),
|
||||||
const Item("Basketball", Colors.red,[5,13]),
|
const Item("Basketball", Colors.red,[5,13]),
|
||||||
@@ -15,9 +14,9 @@ class Sport extends StatelessWidget {
|
|||||||
|
|
||||||
final feed = Feed(); // was var not final
|
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 imageMale = 'images/male.png';
|
||||||
final String imageFemale = 'images/female.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 bool genderSport = false; //determines which gender switch is set M - false / F - True
|
||||||
static int sport_ID;
|
static int sport_ID;
|
||||||
final String sport;
|
final String sport;
|
||||||
@@ -70,9 +69,6 @@ class Sport extends StatelessWidget {
|
|||||||
body: ListView(
|
body: ListView(
|
||||||
children: <Widget>[
|
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)),
|
|
||||||
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name)),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
drawer: Drawer(
|
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,200 +1,54 @@
|
|||||||
import 'package:capstone_hungry_hippos/models/School.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../team_standings.dart';
|
import '../team_standings.dart';
|
||||||
|
|
||||||
class Standing extends StatelessWidget {
|
class Standing extends StatelessWidget {
|
||||||
/*final _schools = [
|
final int sport_id;
|
||||||
School("North Texas Mean Green",AssetImage('assets/school_logos/NorthTexas.png'), 14, 4),
|
final String sport_name;
|
||||||
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 List sport;
|
Standing(List args)
|
||||||
Standing(this.sport);
|
: sport_id = args[0],
|
||||||
|
sport_name = args[1];
|
||||||
final teams = Team_Standings();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// *----- OLD CODE -------*
|
return StatefulBuilder(
|
||||||
/*return Scaffold(
|
builder: (context, StateSetter setState) => Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
title: Text("49ers"),
|
title: Text("$sport_name Standings"),
|
||||||
backgroundColor: Colors.green,
|
backgroundColor: Colors.green,
|
||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
body: ListView(
|
||||||
child: Column(
|
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
HorizontalStandings(sportName: sport_name,),
|
||||||
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,),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
drawer: Drawer(
|
||||||
);*/
|
child: ListView(
|
||||||
|
|
||||||
// *----- Testing CODE -------*
|
|
||||||
//var standings = Team_Standings(sport[0]);
|
|
||||||
return StatefulBuilder(
|
|
||||||
builder: (context, StateSetter setState) => Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
centerTitle: false,
|
|
||||||
title: Text("${sport[1]}" + " Standings"),
|
|
||||||
backgroundColor: Colors.green,
|
|
||||||
),
|
|
||||||
|
|
||||||
/*body: Container (
|
|
||||||
//child: standings,
|
|
||||||
),*/
|
|
||||||
|
|
||||||
body: ListView(
|
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
HorizontalStandings(teamStandings: teams),
|
DrawerHeader(
|
||||||
|
child: Text(
|
||||||
|
'Drawer Header',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 24,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.green,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: IconButton(
|
||||||
|
icon: Icon(Icons.home),
|
||||||
|
onPressed: () => Navigator.pushNamed(context, '/'),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
/*body: SingleChildScrollView (
|
|
||||||
child: Column(
|
|
||||||
children: <Widget>[
|
|
||||||
Container(
|
|
||||||
child: standings,
|
|
||||||
alignment: Alignment(.85, 0),
|
|
||||||
height: 20,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),*/
|
|
||||||
|
|
||||||
drawer: Drawer(
|
|
||||||
child: ListView(
|
|
||||||
children: <Widget>[
|
|
||||||
DrawerHeader(
|
|
||||||
child: Text(
|
|
||||||
'Drawer Header',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 24,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.green,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: IconButton(
|
|
||||||
icon: Icon(Icons.home),
|
|
||||||
onPressed: () => Navigator.pushNamed(context, '/'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*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:flutter/material.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
import 'screens/sport.dart' as globals;
|
import 'screens/sport.dart';
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class HorizontalStandings extends StatelessWidget {
|
class HorizontalStandings extends StatelessWidget {
|
||||||
final Team_Standings teamStandings;
|
static final standingsUrls = {
|
||||||
const HorizontalStandings({Key key, @required this.teamStandings,}) : super(key: key);
|
"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",
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
@override
|
final String sportName;
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Center(
|
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(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (globals.Sport.sport_ID.toString() == "5" || globals.Sport.sport_ID.toString() == "13") // M-W Basketball
|
Text(
|
||||||
Expanded(
|
"${body['name']}",
|
||||||
child: FutureBuilder(
|
style: TextStyle(fontSize: 24),
|
||||||
future: teamStandings.getTeams(),
|
),
|
||||||
builder: (ctx, snapshot) {
|
Column(
|
||||||
if (!snapshot.hasData) {
|
children: body['children']
|
||||||
return Center(child: CircularProgressIndicator());
|
.map((conference) {
|
||||||
} else {
|
var teams = conference['standings']['entries'].map((team) {
|
||||||
List<sport_standings_basketball> teams = snapshot.data;
|
var stats = {};
|
||||||
return ListView.builder(
|
for (var stat in team['stats']) {
|
||||||
scrollDirection: Axis.horizontal,
|
stats[stat['name']] = stat;
|
||||||
itemCount: snapshot.data.length,
|
|
||||||
itemBuilder: (ctx, idx) {
|
|
||||||
return StandingsCard(
|
|
||||||
team: teams[idx],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(
|
||||||
/*else if (globals.Sport.sport_ID.toString() == "3") // Football
|
conference['shortName'],
|
||||||
Expanded(
|
style: TextStyle(fontSize: 16),
|
||||||
child: FutureBuilder(
|
),
|
||||||
future: teamStandings.getTeams(),
|
table,
|
||||||
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],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
})
|
||||||
},
|
.cast<Widget>()
|
||||||
),
|
.toList()),
|
||||||
),*/
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Delete later (not used)
|
return res;
|
||||||
/*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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
var sportUrl = standingsUrls[sportName.toLowerCase()];
|
||||||
|
var idx = (Sport.genderSportSwitch && Sport.genderSport) ? 1 : 0;
|
||||||
|
var url = sportUrl[idx];
|
||||||
|
|
||||||
return Center(
|
return Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
_buildBasketballStandings(),
|
FutureBuilder<Widget>(
|
||||||
Expanded(child: _eventLister()),
|
future: getStandingsTable(url),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.hasError) return Text(snapshot.error.toString());
|
||||||
|
if (!snapshot.hasData) return CircularProgressIndicator();
|
||||||
|
|
||||||
|
return snapshot.data;
|
||||||
|
},
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
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