From 4d66b774fb42f7405022586e1eb49990fbf7d1c1 Mon Sep 17 00:00:00 2001 From: kconnel7 Date: Thu, 30 Apr 2020 10:50:35 -0400 Subject: [PATCH] Standings - No table currently / Future Builder works but has an error (RenderFlex children have non-zero flex but incoming height constraints are unbounded.) --- lib/news/feed.dart | 1 + lib/screens/sport_standings_basketball.dart | 28 ++++ lib/screens/sport_standings_football.dart | 152 ++++++++++++++------ lib/team_standings.dart | 70 +++++---- 4 files changed, 182 insertions(+), 69 deletions(-) diff --git a/lib/news/feed.dart b/lib/news/feed.dart index 18702f8..619c34d 100644 --- a/lib/news/feed.dart +++ b/lib/news/feed.dart @@ -61,6 +61,7 @@ class HorizontalNewsFeed extends StatelessWidget { } else { List
articles = snapshot.data; return ListView.builder( + //shrinkWrap: true, scrollDirection: Axis.horizontal, itemCount: articles.length, itemBuilder: (ctx, idx) { diff --git a/lib/screens/sport_standings_basketball.dart b/lib/screens/sport_standings_basketball.dart index 945bd33..ef5d74d 100644 --- a/lib/screens/sport_standings_basketball.dart +++ b/lib/screens/sport_standings_basketball.dart @@ -76,4 +76,32 @@ class sport_standings_basketball { }*/ ); } +} + +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, + ), + ), + ); + } } \ No newline at end of file diff --git a/lib/screens/sport_standings_football.dart b/lib/screens/sport_standings_football.dart index 03ec2eb..e833493 100644 --- a/lib/screens/sport_standings_football.dart +++ b/lib/screens/sport_standings_football.dart @@ -1,64 +1,128 @@ import 'package:flutter/material.dart'; -class sport_standings_football { - final int id; //id for each game - final DateTime date; //date: 2020-09-05T00:00:00 - final String location_indicator; //location_indicator: H-Home / A-Away - final String location; //location: Knoxville, Tenn., Charlotte, NC - - // -- sport json -- - final int idSport; //id: Each sport different number - final String sportTitle; //title: Football, Men's Soccer - final String gender; //gender: M - F - - // -- opponent json -- - final String opponentTitle; //title: Tennessee, Norfolk State +/*class sport_standings_football { + final int id; + final String displayName; final String image; - // -- result json -- - final String status; //status: W - T - L - final String team_score; //team_score: - final String opponent_score; //opponent_score: - final String postscore; + 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.date, - this.location_indicator, - this.location, - - this.idSport, - this.sportTitle, - this.gender, - - this.opponentTitle, + this.displayName, this.image, - this.status, - this.team_score, - this.opponent_score, - this.postscore, + 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 json) { return sport_standings_football( json['id'], - date: DateTime.parse(json['date']), - location_indicator: json['location_indicator'], - location: json['location'], + displayName: json['standings']['entries']['team']['displayName'], + image: json['standings']['entries']['team']['logos']['href'], - idSport: json['sport']['id'], - sportTitle: json['sport']['title'], - gender: json['sport']['gender'], + for (team in json['standings']['entries']) { + var stats = new Map(); + for (stat in team['stats']) { + stats[stat['type']] = stat; + } - opponentTitle: json['opponent']['title'], - image: json['opponent']['image'], + var team_widget = basketball_widget( + position: stats['playoffseed']['displayValue'], - status: json['result']['status'], + conferenceRecord: stats['vsconf']['displayValue'], + gamesBehind: stats['vsconf_gamesbehind']['displayValue'], + conferencePercentRecord: stats['vsconf_winpercent']['displayValue'], - team_score: json['result']['team_score'], - opponent_score: json['result']['opponent_score'], - postscore: json['result']['postscore'], + + 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'], + ) + } ); } -} \ No newline at end of file +} + +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: [ + 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, + ), + ), + ); + } +}*/ \ No newline at end of file diff --git a/lib/team_standings.dart b/lib/team_standings.dart index 8a63735..be4b453 100644 --- a/lib/team_standings.dart +++ b/lib/team_standings.dart @@ -44,37 +44,57 @@ class HorizontalStandings extends StatelessWidget { return Center( child: Column( children: [ - //_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")), - ], - ); - }, - ); - } - }, - ), - ), + 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 teams = snapshot.data; + return ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: snapshot.data.length, + itemBuilder: (ctx, idx) { + return StandingsCard( + team: teams[idx], + ); + } + ); + } + }, + ), + ) + /*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 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);