Standings - Conditioning on type of standings based on sport
This commit is contained in:
@@ -24,6 +24,8 @@ class Standing extends StatelessWidget {
|
|||||||
final List sport;
|
final List sport;
|
||||||
Standing(this.sport);
|
Standing(this.sport);
|
||||||
|
|
||||||
|
final teams = Team_Standings();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// *----- OLD CODE -------*
|
// *----- OLD CODE -------*
|
||||||
@@ -66,7 +68,7 @@ class Standing extends StatelessWidget {
|
|||||||
);*/
|
);*/
|
||||||
|
|
||||||
// *----- Testing CODE -------*
|
// *----- Testing CODE -------*
|
||||||
var standings = Team_Standings(sport[0]);
|
//var standings = Team_Standings(sport[0]);
|
||||||
return StatefulBuilder(
|
return StatefulBuilder(
|
||||||
builder: (context, StateSetter setState) => Scaffold(
|
builder: (context, StateSetter setState) => Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
@@ -75,9 +77,15 @@ class Standing extends StatelessWidget {
|
|||||||
backgroundColor: Colors.green,
|
backgroundColor: Colors.green,
|
||||||
),
|
),
|
||||||
|
|
||||||
body: Container (
|
/*body: Container (
|
||||||
child: standings,
|
//child: standings,
|
||||||
),
|
),*/
|
||||||
|
|
||||||
|
body: ListView(
|
||||||
|
children: <Widget>[
|
||||||
|
HorizontalStandings(teamStandings: teams),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
/*body: SingleChildScrollView (
|
/*body: SingleChildScrollView (
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|||||||
@@ -1,10 +1,81 @@
|
|||||||
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_standings_basketball.dart';
|
import 'screens/sport_standings_basketball.dart';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class Team_Standings extends StatefulWidget {
|
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 {
|
||||||
|
final Team_Standings teamStandings;
|
||||||
|
const HorizontalStandings({Key key, @required this.teamStandings,}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Center(
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
//_buildBasketballStandings(),
|
||||||
|
Expanded(
|
||||||
|
child: FutureBuilder(
|
||||||
|
future: teamStandings.getTeams(),
|
||||||
|
builder: (ctx, snapshot) {
|
||||||
|
if (!snapshot.hasData) {
|
||||||
|
return Center(child: CircularProgressIndicator());
|
||||||
|
} else {
|
||||||
|
return ListView.builder(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: snapshot.data.length,
|
||||||
|
itemBuilder: (ctx, idx) {
|
||||||
|
return DataTable(
|
||||||
|
columns: [
|
||||||
|
DataColumn(label: Text("")),
|
||||||
|
DataColumn(label: Text("Conference")),
|
||||||
|
DataColumn(label: Text("Overall")),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*class Team_Standings extends StatefulWidget {
|
||||||
final int sportID;
|
final int sportID;
|
||||||
Team_Standings(this.sportID);
|
Team_Standings(this.sportID);
|
||||||
|
|
||||||
@@ -47,7 +118,6 @@ class _Standings extends State<Team_Standings> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
_selectedTeams = [];
|
_selectedTeams = [];
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +127,7 @@ class _Standings extends State<Team_Standings> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
_buildBasketballStandings(),
|
_buildBasketballStandings(),
|
||||||
//Expanded(child: _eventLister()),
|
Expanded(child: _eventLister()),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -66,6 +136,7 @@ class _Standings extends State<Team_Standings> {
|
|||||||
Widget _buildBasketballStandings() {
|
Widget _buildBasketballStandings() {
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.all(15),
|
margin: EdgeInsets.all(15),
|
||||||
|
|
||||||
child: Table(
|
child: Table(
|
||||||
border: TableBorder(
|
border: TableBorder(
|
||||||
horizontalInside: BorderSide(
|
horizontalInside: BorderSide(
|
||||||
@@ -81,7 +152,7 @@ class _Standings extends State<Team_Standings> {
|
|||||||
color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green
|
color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
columnWidths: {0: FractionColumnWidth(.3), 1: FractionColumnWidth(.3), 2: FractionColumnWidth(.5)},
|
columnWidths: {0: FractionColumnWidth(.3), 1: FractionColumnWidth(.4), 2: FractionColumnWidth(.6)},
|
||||||
children: [
|
children: [
|
||||||
TableRow( children: [
|
TableRow( children: [
|
||||||
Column(children:[Text('')]),
|
Column(children:[Text('')]),
|
||||||
@@ -100,4 +171,4 @@ class _Standings extends State<Team_Standings> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
@@ -259,6 +259,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.3"
|
version: "2.2.3"
|
||||||
|
table_sticky_headers:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: table_sticky_headers
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.2"
|
||||||
term_glyph:
|
term_glyph:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ dependencies:
|
|||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^0.1.2
|
cupertino_icons: ^0.1.2
|
||||||
table_calendar:
|
table_calendar:
|
||||||
|
table_sticky_headers:
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user