From b3fb054c450cb085901d37f89689221a55610635 Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Rosario Date: Fri, 17 Apr 2020 14:02:30 -0400 Subject: [PATCH 01/27] Route to sports takes an argument and goes to proper sport --- lib/news/feed.dart | 6 +++--- lib/route_generator.dart | 2 +- lib/screens/sport.dart | 33 ++++++++++++++++++++++++++------- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/lib/news/feed.dart b/lib/news/feed.dart index c5662ce..f1938c6 100644 --- a/lib/news/feed.dart +++ b/lib/news/feed.dart @@ -18,7 +18,7 @@ class Feed { class HorizontalNewsFeed extends StatelessWidget { final Feed newsFeed; - final Widget title; + final Text title; final double numCards; const HorizontalNewsFeed({ @@ -31,9 +31,9 @@ class HorizontalNewsFeed extends StatelessWidget { double heightIn(BuildContext context) { return MediaQuery.of(context).size.height / numCards; } - @override Widget build(BuildContext context) { + //print(title.data); return SizedBox( height: heightIn(context), child: Column( @@ -43,8 +43,8 @@ class HorizontalNewsFeed extends StatelessWidget { title: title, trailing: IconButton( icon: Icon(Icons.navigate_next), + onPressed: () => Navigator.of(context).pushNamed('/Sport', arguments: title.data), - onPressed: () => Navigator.of(context).pushNamed('/Sport'), /*onPressed: () { //changed Navigator.of(context).pushNamed('/Sport'); diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 7678fff..8c6ac8e 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -18,7 +18,7 @@ class RouteGenerator { return MaterialPageRoute(builder: (_) => Home()); case '/Sport': //We can put logic and stuff here for checking if logged in - return MaterialPageRoute(builder: (_) => Sport()); + return MaterialPageRoute(builder: (_) => Sport(args)); case '/Schedule': return MaterialPageRoute(builder: (_) => Schedule()); case '/Standing': diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index b141d4d..05311a8 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -4,26 +4,45 @@ import '../news/feed.dart'; class Sport extends StatelessWidget { static final List colorList = [ - const Item('FootBall', Colors.green), - const Item("BasketBall", Colors.red), + const Item('Football', Colors.green), + const Item("Basketball", Colors.red), const Item("Soccer", Colors.pinkAccent), const Item('Baseball', Colors.orange), + const Item('Volleyball', Colors.blue), + const Item('Softball', Colors.yellow), + const Item('Tennis', Colors.yellowAccent), ]; - Item _curSport = colorList[0]; - 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 genderSport = false; //determines which gender switch is set M - false / F - True - static int sport_ID; + final String sport; + Sport(this.sport); + + Item _curSport = colorList[0]; + @override Widget build(BuildContext context) { + Item _setDefault(){ + Item _curSport; + for (Item i in colorList){ + if (i.name == sport){ + _curSport = i; + break; + } + } + return _curSport; + } + _curSport = _setDefault(); Item selectedSport; + if (_curSport.name == "Soccer" || _curSport.name == "Basketball" || _curSport.name == "Tennis" ){ + genderSportSwitch = true; + } return StatefulBuilder( builder: (context, StateSetter setState) => Scaffold( @@ -34,7 +53,7 @@ class Sport extends StatelessWidget { //--Gender Switch-- Need to make condition to determine gender actions: [ - if (genderSportSwitch == true) + if (genderSportSwitch) Switch( value: genderSport, onChanged: (value) { @@ -183,4 +202,4 @@ class Item { final String name; final Color color; -} +} \ No newline at end of file From 9e3541c119e1df3bcd747b958691b8da6134d802 Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Rosario Date: Sat, 18 Apr 2020 10:37:40 -0400 Subject: [PATCH 02/27] Gender Switch now properly appears on the correct sports and changes the sport ID properly --- lib/screens/sport.dart | 90 ++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 61 deletions(-) diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index 05311a8..236ded4 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -4,13 +4,13 @@ import '../news/feed.dart'; class Sport extends StatelessWidget { static final List colorList = [ - const Item('Football', Colors.green), - const Item("Basketball", Colors.red), - const Item("Soccer", Colors.pinkAccent), - const Item('Baseball', Colors.orange), - const Item('Volleyball', Colors.blue), - const Item('Softball', Colors.yellow), - const Item('Tennis', Colors.yellowAccent), + const Item('Football', Colors.green,[3]), + const Item("Basketball", Colors.red,[5,13]), + const Item("Soccer", Colors.pinkAccent,[9,17]), + const Item('Baseball', Colors.orange,[1]), + const Item('Volleyball', Colors.blue,[0]), + const Item('Softball', Colors.yellow,[0]), + const Item('Tennis', Colors.yellowAccent,[0]), ]; final feed = Feed(); // was var not final @@ -20,7 +20,6 @@ class Sport extends StatelessWidget { final String imageFemale = 'images/female.png'; static bool genderSport = false; //determines which gender switch is set M - false / F - True static int sport_ID; - final String sport; Sport(this.sport); @@ -39,11 +38,9 @@ class Sport extends StatelessWidget { return _curSport; } _curSport = _setDefault(); + int sport_ID = _curSport.sportID[0]; Item selectedSport; - if (_curSport.name == "Soccer" || _curSport.name == "Basketball" || _curSport.name == "Tennis" ){ - genderSportSwitch = true; - } - + _genderSwitcherCheck(); return StatefulBuilder( builder: (context, StateSetter setState) => Scaffold( appBar: AppBar( @@ -58,15 +55,10 @@ class Sport extends StatelessWidget { value: genderSport, onChanged: (value) { setState(() { - if (value == false) { - genderSport = false; - } - else { - genderSport = true; - } - - print("value: " + value.toString()); - print("gender: " + genderSport.toString()); + genderSport = value; + if (_curSport.sportID.length > 1){ + sport_ID = genderSport ? _curSport.sportID[1] : _curSport.sportID[0]; + } }); }, inactiveThumbColor: Colors.lightBlue, @@ -142,45 +134,7 @@ class Sport extends StatelessWidget { onChanged: (Item value) { setState(() { _curSport = value; - - print("genderSport: " + genderSport.toString()); - - //Will set the sport id / Display gender switch - switch (_curSport.name) { //prints are temp - case 'FootBall': - genderSportSwitch = false; - sport_ID = 3; - break; - - case 'BasketBall': - genderSportSwitch = true; - - if (genderSport == false) { - sport_ID = 5; //Male - } - else { - sport_ID = 13; //Female - } - break; - - case 'Soccer': - genderSportSwitch = true; - - if (genderSport == false) { - sport_ID = 9; //Male - } - else { - sport_ID = 17; //Female - } - break; - - case 'Baseball': - genderSportSwitch = false; - - sport_ID = 1; - break; - } - print(sport_ID); + _genderSwitcherCheck(); }); }, items: colorList.map>((Item item) { @@ -195,11 +149,25 @@ class Sport extends StatelessWidget { ), ); } + + void _genderSwitcherCheck() { + if (_curSport.name == "Soccer" || _curSport.name == "Basketball" || _curSport.name == "Tennis" ){ + genderSportSwitch = true; + sport_ID = genderSport ? _curSport.sportID[1] : _curSport.sportID[0]; + } else { + genderSportSwitch = false; + sport_ID = _curSport.sportID[0]; + } + print(sport_ID); + } + + } class Item { - const Item(this.name, this.color); + const Item(this.name, this.color, this.sportID); final String name; final Color color; + final List sportID; } \ No newline at end of file From 39912bd37e70193bb3eac196ca32e098c5612fbf Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Rosario Date: Sat, 18 Apr 2020 11:10:13 -0400 Subject: [PATCH 03/27] Sports page passes game ID to Schedule/Calendar properly and generates correct calendar --- lib/monthly_calendar.dart | 10 ++++++++-- lib/route_generator.dart | 4 ++-- lib/screens/schedule.dart | 6 ++++-- lib/screens/sport.dart | 11 +++++------ 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/lib/monthly_calendar.dart b/lib/monthly_calendar.dart index e92d4a1..a1e0ca3 100644 --- a/lib/monthly_calendar.dart +++ b/lib/monthly_calendar.dart @@ -7,8 +7,11 @@ import 'screens/sport.dart' as globals; import 'dart:convert'; class Calendar extends StatefulWidget { + final int sportID; + Calendar(this.sportID); + @override - _Calendar createState() => _Calendar(); + _Calendar createState() => _Calendar(sportID); } //List _selectedEvents; //original that makes events work @@ -17,12 +20,15 @@ DateTime selectedDay; Map> _events; class _Calendar extends State with TickerProviderStateMixin { + int sportID; + _Calendar(this. sportID); + AnimationController _animationController; CalendarController _calController; - int sportID = globals.Sport.sport_ID; static final sportUrl = 'https://charlotte49ers.com/services/adaptive_components.ashx?type=scoreboard&start=0&count=80'; + Future> getEvents() async { var url = '$sportUrl&sport_id=$sportID&name=&extra=%7B%7D'; diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 8c6ac8e..3af16f5 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -12,7 +12,7 @@ class RouteGenerator { static Route generateRoute(RouteSettings settings) { final args = settings .arguments; //This is how we pass arguments and can be used in case - + print("args $args"); switch (settings.name) { case '/': return MaterialPageRoute(builder: (_) => Home()); @@ -20,7 +20,7 @@ class RouteGenerator { //We can put logic and stuff here for checking if logged in return MaterialPageRoute(builder: (_) => Sport(args)); case '/Schedule': - return MaterialPageRoute(builder: (_) => Schedule()); + return MaterialPageRoute(builder: (_) => Schedule(args)); case '/Standing': return MaterialPageRoute(builder: (_) => Standing()); case '/Chat': diff --git a/lib/screens/schedule.dart b/lib/screens/schedule.dart index 0a3f716..cd3efd7 100644 --- a/lib/screens/schedule.dart +++ b/lib/screens/schedule.dart @@ -1,12 +1,14 @@ import 'package:flutter/material.dart'; import '../monthly_calendar.dart'; - +import '../screens/sport.dart' as globals; class Schedule extends StatelessWidget{ - final calendar = Calendar(); + final int sportID; + Schedule(this.sportID); @override Widget build(BuildContext context) { + var calendar = Calendar(sportID); return StatefulBuilder( builder: (context, StateSetter setState) => Scaffold( appBar: AppBar( diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index 236ded4..8e547d2 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -38,7 +38,7 @@ class Sport extends StatelessWidget { return _curSport; } _curSport = _setDefault(); - int sport_ID = _curSport.sportID[0]; + sport_ID = _curSport.sportID[0]; Item selectedSport; _genderSwitcherCheck(); return StatefulBuilder( @@ -56,9 +56,7 @@ class Sport extends StatelessWidget { onChanged: (value) { setState(() { genderSport = value; - if (_curSport.sportID.length > 1){ - sport_ID = genderSport ? _curSport.sportID[1] : _curSport.sportID[0]; - } + _genderSwitcherCheck(); }); }, inactiveThumbColor: Colors.lightBlue, @@ -101,13 +99,13 @@ class Sport extends StatelessWidget { ListTile( title: IconButton( icon: Icon(Icons.table_chart), - onPressed: () => Navigator.pushNamed(context, '/Standing'), + onPressed: () => Navigator.pushNamed(context, '/Standing', arguments: sport_ID), ), ), ListTile( title: IconButton( icon: Icon(Icons.calendar_today), - onPressed: () => Navigator.pushNamed(context, '/Schedule'), + onPressed: () => Navigator.pushNamed(context, '/Schedule',arguments: sport_ID), ), ), ], @@ -135,6 +133,7 @@ class Sport extends StatelessWidget { setState(() { _curSport = value; _genderSwitcherCheck(); + print(sport_ID); }); }, items: colorList.map>((Item item) { From 273a738fe062392352122a18e30eb21844c36025 Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Rosario Date: Sat, 18 Apr 2020 11:10:59 -0400 Subject: [PATCH 04/27] no more calendar global use --- lib/monthly_calendar.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/monthly_calendar.dart b/lib/monthly_calendar.dart index a1e0ca3..57ca1b1 100644 --- a/lib/monthly_calendar.dart +++ b/lib/monthly_calendar.dart @@ -3,7 +3,6 @@ import 'package:http/http.dart' as http; import 'package:table_calendar/table_calendar.dart'; import 'screens/sport_schedule.dart'; -import 'screens/sport.dart' as globals; import 'dart:convert'; class Calendar extends StatefulWidget { @@ -65,7 +64,7 @@ class _Calendar extends State with TickerProviderStateMixin { @override void initState() { - final _selectedDay = DateTime.now(); + //final _selectedDay = DateTime.now(); //_selectedEvents = _events[_selectedDay] ?? []; _selectedEvents = []; From 8cf18dec0a35677483c6fa903dbe587792a3cdf7 Mon Sep 17 00:00:00 2001 From: kconnel7 Date: Wed, 22 Apr 2020 18:38:54 -0400 Subject: [PATCH 05/27] Monthly Calendar - Softball, Volleyball, Men/Women Tennis Works --- ios/Runner.xcodeproj/project.pbxproj | 5 ----- lib/monthly_calendar.dart | 6 ++++-- lib/screens/sport.dart | 9 ++++----- pubspec.lock | 24 ++++++++++++------------ 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 226967c..f91fa61 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -213,14 +213,9 @@ files = ( ); inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../Flutter/Flutter.framework", - "${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/lib/monthly_calendar.dart b/lib/monthly_calendar.dart index 57ca1b1..ab5d310 100644 --- a/lib/monthly_calendar.dart +++ b/lib/monthly_calendar.dart @@ -31,6 +31,8 @@ class _Calendar extends State with TickerProviderStateMixin { Future> getEvents() async { var url = '$sportUrl&sport_id=$sportID&name=&extra=%7B%7D'; + print(url.toString()); + http.Response response = await http.get(url); Iterable games = json.decode(response.body); @@ -290,7 +292,7 @@ class _Calendar extends State with TickerProviderStateMixin { child: ListTile( leading: Image.network( 'https://charlotte49ers.com' + event.image.toString(), - width: 50.0, + width: 35.0, ), title: Wrap( children: [ @@ -322,7 +324,7 @@ class _Calendar extends State with TickerProviderStateMixin { subtitle: Text( event.sportTitle.toString() + " - " + event.location.toString(), style: TextStyle( - fontSize: 10.3, + fontSize: 9.9, //10.3 ), ), diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index 8e547d2..049ba2b 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -8,9 +8,9 @@ class Sport extends StatelessWidget { const Item("Basketball", Colors.red,[5,13]), const Item("Soccer", Colors.pinkAccent,[9,17]), const Item('Baseball', Colors.orange,[1]), - const Item('Volleyball', Colors.blue,[0]), - const Item('Softball', Colors.yellow,[0]), - const Item('Tennis', Colors.yellowAccent,[0]), + const Item('Softball', Colors.yellow,[12]), + const Item('Volleyball', Colors.blue,[20]), + const Item('Tennis', Colors.yellowAccent,[10,18]), ]; final feed = Feed(); // was var not final @@ -115,8 +115,7 @@ class Sport extends StatelessWidget { ); } - DropdownButtonHideUnderline buildDropdownButton( - Item selectedSport, StateSetter setState) { + DropdownButtonHideUnderline buildDropdownButton(Item selectedSport, StateSetter setState) { return DropdownButtonHideUnderline( child: DropdownButton( value: selectedSport, diff --git a/pubspec.lock b/pubspec.lock index dd1117d..7fc9f02 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,21 +7,21 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "2.0.13" + version: "2.0.11" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted - version: "1.6.0" + version: "1.5.2" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.4.0" bloc: dependency: transitive description: @@ -35,21 +35,21 @@ packages: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "1.0.5" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.1.2" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.12" + version: "1.14.11" convert: dependency: transitive description: @@ -63,7 +63,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.3" cupertino_icons: dependency: "direct main" description: @@ -113,7 +113,7 @@ packages: name: image url: "https://pub.dartlang.org" source: hosted - version: "2.1.12" + version: "2.1.4" intl: dependency: transitive description: @@ -176,7 +176,7 @@ packages: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.0.5" rxdart: dependency: transitive description: @@ -230,7 +230,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.5.5" stack_trace: dependency: transitive description: @@ -272,7 +272,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.15" + version: "0.2.11" typed_data: dependency: transitive description: @@ -293,7 +293,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "3.6.1" + version: "3.5.0" sdks: dart: ">=2.6.0 <3.0.0" flutter: ">=1.12.13+hotfix.4 <2.0.0" From 5bc25f8074811193682ec1ac7f1c285b1e2c194f Mon Sep 17 00:00:00 2001 From: clopezr1 Date: Thu, 23 Apr 2020 15:08:49 -0400 Subject: [PATCH 06/27] The event notification now appears over the entire date instead of mini --- lib/monthly_calendar.dart | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/monthly_calendar.dart b/lib/monthly_calendar.dart index ab5d310..7d755d2 100644 --- a/lib/monthly_calendar.dart +++ b/lib/monthly_calendar.dart @@ -212,8 +212,7 @@ class _Calendar extends State with TickerProviderStateMixin { if (events.isNotEmpty) { miniBox.add( Positioned( - right: 1, - bottom: 1, + right: 0,top: 0, left: 0, bottom: 0, child: _buildEventsMarker(date, events), ), ); @@ -254,7 +253,7 @@ class _Calendar extends State with TickerProviderStateMixin { //if selected date && home game / else away game color: _calController.isSelected(date) ? Colors.blue[400] - : Color.fromRGBO(0, 112, 60, 1), //UNCC Green + : _homeAwayColor(), //UNCC Green //: Colors.grey, ), @@ -273,6 +272,24 @@ class _Calendar extends State with TickerProviderStateMixin { ); } + bool homeAway = true; + + Color _homeAwayColor(){ + //TODO: Here should be the logic on if Home or Away return the colors + // Do whatever you need to do to check home/away + // my guess is if the game says vs its home + // if game says at its away + + Color c; + if (homeAway){ // could also be if(game == "H") or something + c = Color.fromRGBO(0, 112, 60, 1); + } else { + c = Colors.grey; + } + return c; + } + + //----- Creates event display ----- Widget _eventLister() { return ListView( From 74aa580f28bfac67563fae56225ffe4b67a86ff7 Mon Sep 17 00:00:00 2001 From: clopezr1 Date: Thu, 23 Apr 2020 15:10:14 -0400 Subject: [PATCH 07/27] says day on events --- lib/monthly_calendar.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/monthly_calendar.dart b/lib/monthly_calendar.dart index 7d755d2..9e5ea05 100644 --- a/lib/monthly_calendar.dart +++ b/lib/monthly_calendar.dart @@ -262,7 +262,7 @@ class _Calendar extends State with TickerProviderStateMixin { child: Center( child: Text( - '${events.length}', + '${date.day}', style: TextStyle().copyWith( color: Colors.white, fontSize: 12.0, @@ -280,6 +280,7 @@ class _Calendar extends State with TickerProviderStateMixin { // my guess is if the game says vs its home // if game says at its away + Color c; if (homeAway){ // could also be if(game == "H") or something c = Color.fromRGBO(0, 112, 60, 1); From ff26f31dc82fd153488a91b1b68d95abf4986282 Mon Sep 17 00:00:00 2001 From: clopezr1 Date: Thu, 23 Apr 2020 16:22:33 -0400 Subject: [PATCH 08/27] Color of Mini indicator is Based on location --- ios/Runner.xcodeproj/project.pbxproj | 5 +++++ lib/monthly_calendar.dart | 14 ++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index f91fa61..226967c 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -213,9 +213,14 @@ files = ( ); inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", + "${PODS_ROOT}/../Flutter/Flutter.framework", + "${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/lib/monthly_calendar.dart b/lib/monthly_calendar.dart index 9e5ea05..13051b8 100644 --- a/lib/monthly_calendar.dart +++ b/lib/monthly_calendar.dart @@ -213,7 +213,7 @@ class _Calendar extends State with TickerProviderStateMixin { miniBox.add( Positioned( right: 0,top: 0, left: 0, bottom: 0, - child: _buildEventsMarker(date, events), + child: _buildEventsMarker(date, events[0].location_indicator), ), ); } @@ -234,7 +234,7 @@ class _Calendar extends State with TickerProviderStateMixin { } //----- Creates event box display (mini box) ----- - Widget _buildEventsMarker(DateTime date, List events) { + Widget _buildEventsMarker(DateTime date, String location) { return AnimatedContainer( duration: const Duration(milliseconds: 300), @@ -253,7 +253,7 @@ class _Calendar extends State with TickerProviderStateMixin { //if selected date && home game / else away game color: _calController.isSelected(date) ? Colors.blue[400] - : _homeAwayColor(), //UNCC Green + : _homeAwayColor(location), //UNCC Green //: Colors.grey, ), @@ -272,17 +272,15 @@ class _Calendar extends State with TickerProviderStateMixin { ); } - bool homeAway = true; - - Color _homeAwayColor(){ + Color _homeAwayColor(String location){ //TODO: Here should be the logic on if Home or Away return the colors // Do whatever you need to do to check home/away // my guess is if the game says vs its home // if game says at its away - + //print(i.location_indicator); Color c; - if (homeAway){ // could also be if(game == "H") or something + if (location == "H"){ // could also be if(game == "H") or something c = Color.fromRGBO(0, 112, 60, 1); } else { c = Colors.grey; From fe3b69f3503b73644a28428a54e9d57a7e66a7dc Mon Sep 17 00:00:00 2001 From: clopezr1 Date: Thu, 23 Apr 2020 16:32:29 -0400 Subject: [PATCH 09/27] Tennis Fix --- lib/screens/sport.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index 8e547d2..6411d02 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -10,7 +10,7 @@ class Sport extends StatelessWidget { const Item('Baseball', Colors.orange,[1]), const Item('Volleyball', Colors.blue,[0]), const Item('Softball', Colors.yellow,[0]), - const Item('Tennis', Colors.yellowAccent,[0]), + const Item('Tennis', Colors.yellowAccent,[0,0]), ]; final feed = Feed(); // was var not final From 3a8397b89e2bc59cdd5ecb6b6399d2613e0e5905 Mon Sep 17 00:00:00 2001 From: clopezr1 Date: Thu, 23 Apr 2020 17:49:34 -0400 Subject: [PATCH 10/27] Calendar shows what sport, and little box for games with more than 1 game --- lib/monthly_calendar.dart | 24 ++++++++++++++++++------ lib/screens/schedule.dart | 8 ++++---- lib/screens/sport.dart | 2 +- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/monthly_calendar.dart b/lib/monthly_calendar.dart index 13051b8..9777fc7 100644 --- a/lib/monthly_calendar.dart +++ b/lib/monthly_calendar.dart @@ -208,14 +208,20 @@ class _Calendar extends State with TickerProviderStateMixin { markersBuilder: (context, date, events, holidays) { final miniBox = []; - if (events.isNotEmpty) { miniBox.add( Positioned( right: 0,top: 0, left: 0, bottom: 0, - child: _buildEventsMarker(date, events[0].location_indicator), + child: _buildEventsMarker(date, events[0].location_indicator, true, events), ), ); + if (events.length > 1) + miniBox.add( + Positioned( + right: 1, bottom: 1, + child: _buildEventsMarker(date, events[0].location_indicator, false, events), + ) + ); } return miniBox; @@ -234,7 +240,10 @@ class _Calendar extends State with TickerProviderStateMixin { } //----- Creates event box display (mini box) ----- - Widget _buildEventsMarker(DateTime date, String location) { + Widget _buildEventsMarker(DateTime date, String location, bool main, events) { + String s; + if (main) {s = "${date.day}";} else {s = "${events.length}";} + return AnimatedContainer( duration: const Duration(milliseconds: 300), @@ -253,7 +262,7 @@ class _Calendar extends State with TickerProviderStateMixin { //if selected date && home game / else away game color: _calController.isSelected(date) ? Colors.blue[400] - : _homeAwayColor(location), //UNCC Green + : _homeAwayColor(location, main), //UNCC Green //: Colors.grey, ), @@ -262,7 +271,7 @@ class _Calendar extends State with TickerProviderStateMixin { child: Center( child: Text( - '${date.day}', + s, style: TextStyle().copyWith( color: Colors.white, fontSize: 12.0, @@ -272,7 +281,7 @@ class _Calendar extends State with TickerProviderStateMixin { ); } - Color _homeAwayColor(String location){ + Color _homeAwayColor(String location, bool main){ //TODO: Here should be the logic on if Home or Away return the colors // Do whatever you need to do to check home/away // my guess is if the game says vs its home @@ -285,6 +294,9 @@ class _Calendar extends State with TickerProviderStateMixin { } else { c = Colors.grey; } + if (!main){ + c = Colors.black45;//Color.fromRGBO(179, 163, 105, 1); + } return c; } diff --git a/lib/screens/schedule.dart b/lib/screens/schedule.dart index cd3efd7..b7dc1aa 100644 --- a/lib/screens/schedule.dart +++ b/lib/screens/schedule.dart @@ -3,17 +3,17 @@ import '../monthly_calendar.dart'; import '../screens/sport.dart' as globals; class Schedule extends StatelessWidget{ - final int sportID; - Schedule(this.sportID); + final List sport; + Schedule(this.sport); @override Widget build(BuildContext context) { - var calendar = Calendar(sportID); + var calendar = Calendar(sport[0]); return StatefulBuilder( builder: (context, StateSetter setState) => Scaffold( appBar: AppBar( centerTitle: false, - title: Text("49ers"), + title: Text("${sport[1]}"), backgroundColor: Colors.green, ), body: Container ( diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index 049ba2b..52e33a0 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -105,7 +105,7 @@ class Sport extends StatelessWidget { ListTile( title: IconButton( icon: Icon(Icons.calendar_today), - onPressed: () => Navigator.pushNamed(context, '/Schedule',arguments: sport_ID), + onPressed: () => Navigator.pushNamed(context, '/Schedule',arguments: [sport_ID, _curSport.name],), ), ), ], From 7ba8fcb09c00476e39a453dd2375affd6dbc2cbe Mon Sep 17 00:00:00 2001 From: clopezr1 Date: Thu, 23 Apr 2020 18:22:36 -0400 Subject: [PATCH 11/27] selected is gold --- lib/monthly_calendar.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/monthly_calendar.dart b/lib/monthly_calendar.dart index 9777fc7..649775f 100644 --- a/lib/monthly_calendar.dart +++ b/lib/monthly_calendar.dart @@ -261,7 +261,7 @@ class _Calendar extends State with TickerProviderStateMixin { //if selected date && home game / else away game color: _calController.isSelected(date) - ? Colors.blue[400] + ? Color.fromRGBO(179, 163, 105, 1) : _homeAwayColor(location, main), //UNCC Green //: Colors.grey, ), From c6d811331dd664630a8823a83811e5d40a5fe3df Mon Sep 17 00:00:00 2001 From: kconnel7 Date: Sat, 25 Apr 2020 16:10:26 -0400 Subject: [PATCH 12/27] Monthly Calendar - All Sports work & Changed layout to look better --- ios/Podfile | 90 ++++++++++++++++++++++++++++ ios/Podfile.lock | 34 +++++++++++ ios/Runner.xcodeproj/project.pbxproj | 5 -- lib/monthly_calendar.dart | 53 +++++++--------- 4 files changed, 144 insertions(+), 38 deletions(-) create mode 100644 ios/Podfile create mode 100644 ios/Podfile.lock diff --git a/ios/Podfile b/ios/Podfile new file mode 100644 index 0000000..0ee4a53 --- /dev/null +++ b/ios/Podfile @@ -0,0 +1,90 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def parse_KV_file(file, separator='=') + file_abs_path = File.expand_path(file) + if !File.exists? file_abs_path + return []; + end + generated_key_values = {} + skip_line_start_symbols = ["#", "/"] + File.foreach(file_abs_path) do |line| + next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } + plugin = line.split(pattern=separator) + if plugin.length == 2 + podname = plugin[0].strip() + path = plugin[1].strip() + podpath = File.expand_path("#{path}", file_abs_path) + generated_key_values[podname] = podpath + else + puts "Invalid plugin specification: #{line}" + end + end + generated_key_values +end + +target 'Runner' do + use_frameworks! + use_modular_headers! + + # Flutter Pod + + copied_flutter_dir = File.join(__dir__, 'Flutter') + copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework') + copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec') + unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path) + # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet. + # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration. + # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist. + + generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig') + unless File.exist?(generated_xcode_build_settings_path) + raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path) + cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR']; + + unless File.exist?(copied_framework_path) + FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir) + end + unless File.exist?(copied_podspec_path) + FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir) + end + end + + # Keep pod path relative so it can be checked into Podfile.lock. + pod 'Flutter', :path => 'Flutter' + + # Plugin Pods + + # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock + # referring to absolute paths on developers' machines. + system('rm -rf .symlinks') + system('mkdir -p .symlinks/plugins') + plugin_pods = parse_KV_file('../.flutter-plugins') + plugin_pods.each do |name, path| + symlink = File.join('.symlinks', 'plugins', name) + File.symlink(path, symlink) + pod name, :path => File.join(symlink, 'ios') + end +end + +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true + +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['ENABLE_BITCODE'] = 'NO' + end + end +end diff --git a/ios/Podfile.lock b/ios/Podfile.lock new file mode 100644 index 0000000..f7203c7 --- /dev/null +++ b/ios/Podfile.lock @@ -0,0 +1,34 @@ +PODS: + - Flutter (1.0.0) + - shared_preferences (0.0.1): + - Flutter + - shared_preferences_macos (0.0.1): + - Flutter + - shared_preferences_web (0.0.1): + - Flutter + +DEPENDENCIES: + - Flutter (from `Flutter`) + - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) + - shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`) + - shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`) + +EXTERNAL SOURCES: + Flutter: + :path: Flutter + shared_preferences: + :path: ".symlinks/plugins/shared_preferences/ios" + shared_preferences_macos: + :path: ".symlinks/plugins/shared_preferences_macos/ios" + shared_preferences_web: + :path: ".symlinks/plugins/shared_preferences_web/ios" + +SPEC CHECKSUMS: + Flutter: 0e3d915762c693b495b44d77113d4970485de6ec + shared_preferences: 430726339841afefe5142b9c1f50cb6bd7793e01 + shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087 + shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9 + +PODFILE CHECKSUM: 083258d7f5e80b42ea9bfee905fe93049bc04c64 + +COCOAPODS: 1.7.5 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 226967c..f91fa61 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -213,14 +213,9 @@ files = ( ); inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../Flutter/Flutter.framework", - "${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/lib/monthly_calendar.dart b/lib/monthly_calendar.dart index 649775f..0641a5a 100644 --- a/lib/monthly_calendar.dart +++ b/lib/monthly_calendar.dart @@ -27,7 +27,6 @@ class _Calendar extends State with TickerProviderStateMixin { static final sportUrl = 'https://charlotte49ers.com/services/adaptive_components.ashx?type=scoreboard&start=0&count=80'; - Future> getEvents() async { var url = '$sportUrl&sport_id=$sportID&name=&extra=%7B%7D'; @@ -54,10 +53,8 @@ class _Calendar extends State with TickerProviderStateMixin { var original = mapGrab[sportEvent]; if (original == null) { - //print("null"); mapGrab[sportEvent] = [eventInfo[i]]; } else { - //print(eventInfo[i].date); mapGrab[sportEvent] = List.from(original)..addAll([eventInfo[i]]); } } @@ -240,30 +237,26 @@ class _Calendar extends State with TickerProviderStateMixin { } //----- Creates event box display (mini box) ----- - Widget _buildEventsMarker(DateTime date, String location, bool main, events) { - String s; - if (main) {s = "${date.day}";} else {s = "${events.length}";} + Widget _buildEventsMarker(DateTime date, String gameType, bool main, events) { + String eventNum; + if (main) {eventNum = "${date.day}";} else {eventNum = "${events.length}";} + //return Container( return AnimatedContainer( duration: const Duration(milliseconds: 300), + margin: const EdgeInsets.all(4.0), + alignment: Alignment.center, + decoration: BoxDecoration( - shape: BoxShape.rectangle, - - /*border: _calController.isSelected(date) //if selected date - ? Border.all(color: Colors.black, width: 1.5,) - : _calController.isToday(date) //if today's date - ? Border.all(color: Colors.black, width: 1.5,) - : Border.all(color: Colors.black, width: 0,),*/ - - //color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green - //color: Colors.grey, - - //if selected date && home game / else away game - color: _calController.isSelected(date) - ? Color.fromRGBO(179, 163, 105, 1) - : _homeAwayColor(location, main), //UNCC Green - //: Colors.grey, + /*border: Border.all( + color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green + //color: Colors.black, + ),*/ + color: _calController.isSelected(date) + ? Color.fromRGBO(179, 163, 105, 1) //UNCC Gold + : _gameTypeColor(gameType, main), //UNCC Green + borderRadius: BorderRadius.circular(10.0) ), width: 16.0, @@ -271,7 +264,7 @@ class _Calendar extends State with TickerProviderStateMixin { child: Center( child: Text( - s, + eventNum, style: TextStyle().copyWith( color: Colors.white, fontSize: 12.0, @@ -281,16 +274,11 @@ class _Calendar extends State with TickerProviderStateMixin { ); } - Color _homeAwayColor(String location, bool main){ - //TODO: Here should be the logic on if Home or Away return the colors - // Do whatever you need to do to check home/away - // my guess is if the game says vs its home - // if game says at its away - //print(i.location_indicator); - + //Logic on if Home or Away return the colors + Color _gameTypeColor(String gameType, bool main){ Color c; - if (location == "H"){ // could also be if(game == "H") or something - c = Color.fromRGBO(0, 112, 60, 1); + if (gameType == "H"){ + c = Color.fromRGBO(0, 112, 60, 1); //UNCC Green } else { c = Colors.grey; } @@ -300,7 +288,6 @@ class _Calendar extends State with TickerProviderStateMixin { return c; } - //----- Creates event display ----- Widget _eventLister() { return ListView( From 18c8ed39f4a23997901e6c8d2fa8f9f5d719f06a Mon Sep 17 00:00:00 2001 From: kconnel7 Date: Wed, 29 Apr 2020 22:32:14 -0400 Subject: [PATCH 13/27] Standings --- lib/monthly_calendar.dart | 2 +- lib/screens/sport_standings_basketball.dart | 79 +++++++++++++++++++++ lib/screens/sport_standings_football.dart | 64 +++++++++++++++++ lib/screens/standing.dart | 71 +++++------------- lib/screens/test_standings.dart | 26 +++++++ 5 files changed, 186 insertions(+), 56 deletions(-) create mode 100644 lib/screens/sport_standings_basketball.dart create mode 100644 lib/screens/sport_standings_football.dart create mode 100644 lib/screens/test_standings.dart diff --git a/lib/monthly_calendar.dart b/lib/monthly_calendar.dart index 0641a5a..eb16c58 100644 --- a/lib/monthly_calendar.dart +++ b/lib/monthly_calendar.dart @@ -20,7 +20,7 @@ Map> _events; class _Calendar extends State with TickerProviderStateMixin { int sportID; - _Calendar(this. sportID); + _Calendar(this.sportID); AnimationController _animationController; CalendarController _calController; diff --git a/lib/screens/sport_standings_basketball.dart b/lib/screens/sport_standings_basketball.dart new file mode 100644 index 0000000..949a7be --- /dev/null +++ b/lib/screens/sport_standings_basketball.dart @@ -0,0 +1,79 @@ +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 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(); + 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'], + ) + }*/ + ); + } +} \ No newline at end of file diff --git a/lib/screens/sport_standings_football.dart b/lib/screens/sport_standings_football.dart new file mode 100644 index 0000000..03ec2eb --- /dev/null +++ b/lib/screens/sport_standings_football.dart @@ -0,0 +1,64 @@ +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 + 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; + + sport_standings_football( + this.id, { + this.date, + this.location_indicator, + this.location, + + this.idSport, + this.sportTitle, + this.gender, + + this.opponentTitle, + this.image, + + this.status, + this.team_score, + this.opponent_score, + this.postscore, + }); + + 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'], + + idSport: json['sport']['id'], + sportTitle: json['sport']['title'], + gender: json['sport']['gender'], + + opponentTitle: json['opponent']['title'], + image: json['opponent']['image'], + + status: json['result']['status'], + + team_score: json['result']['team_score'], + opponent_score: json['result']['opponent_score'], + postscore: json['result']['postscore'], + ); + } +} \ No newline at end of file diff --git a/lib/screens/standing.dart b/lib/screens/standing.dart index 8a57a29..fb1c0c6 100644 --- a/lib/screens/standing.dart +++ b/lib/screens/standing.dart @@ -32,67 +32,28 @@ class Standing extends StatelessWidget { children: [ Container( child: Text( - "W L", + "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, - ), + + 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,), ], ), ), diff --git a/lib/screens/test_standings.dart b/lib/screens/test_standings.dart new file mode 100644 index 0000000..794d0e9 --- /dev/null +++ b/lib/screens/test_standings.dart @@ -0,0 +1,26 @@ +/*import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; + +import 'dart:convert'; + +class Standings extends StatefulWidget { + @override + _Standings createState() => _Standings(); +} + +List _selectedTeams; + +class _Standings extends State { + static final sportUrl = 'https://charlotte49ers.com/services/adaptive_components.ashx?type=scoreboard&start=0&count=80'; + + Future> getEvents() async { + var url = '$sportUrl&sport_id=$sportID&name=&extra=%7B%7D'; + + print(url.toString()); + + http.Response response = await http.get(url); + Iterable games = json.decode(response.body); + + return games.map((json) => sport_standings_basketball.fromJson(json)).toList(); + //return games.map((e) => sport_schedule.fromJson(e)).toList(); + }*/ \ No newline at end of file From 015fbd9dc92cc68f6d784986b94ce456cfedb503 Mon Sep 17 00:00:00 2001 From: kconnel7 Date: Wed, 29 Apr 2020 23:18:09 -0400 Subject: [PATCH 14/27] Standings - Conditioning to find sport urls --- lib/screens/sport_standings_basketball.dart | 8 +-- lib/screens/test_standings.dart | 26 ---------- lib/team_standings.dart | 56 +++++++++++++++++++++ 3 files changed, 60 insertions(+), 30 deletions(-) delete mode 100644 lib/screens/test_standings.dart create mode 100644 lib/team_standings.dart diff --git a/lib/screens/sport_standings_basketball.dart b/lib/screens/sport_standings_basketball.dart index 949a7be..945bd33 100644 --- a/lib/screens/sport_standings_basketball.dart +++ b/lib/screens/sport_standings_basketball.dart @@ -5,7 +5,7 @@ class sport_standings_basketball { final String displayName; final String image; - final String position; + /*final String position; // -- Conference stats -- final String conferenceRecord; @@ -17,7 +17,7 @@ class sport_standings_basketball { final String overallPercentRecord; final String homeRecord; final String awayRecord; - final String gameStreak; + final String gameStreak;*/ // -- Polls stats -- //final String apRecord; @@ -28,7 +28,7 @@ class sport_standings_basketball { this.displayName, this.image, - this.position, + /*this.position, this.conferenceRecord, this.gamesBehind, @@ -38,7 +38,7 @@ class sport_standings_basketball { this.overallPercentRecord, this.homeRecord, this.awayRecord, - this.gameStreak, + this.gameStreak,*/ //this.apRecord, //this.usaRecord, diff --git a/lib/screens/test_standings.dart b/lib/screens/test_standings.dart deleted file mode 100644 index 794d0e9..0000000 --- a/lib/screens/test_standings.dart +++ /dev/null @@ -1,26 +0,0 @@ -/*import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; - -import 'dart:convert'; - -class Standings extends StatefulWidget { - @override - _Standings createState() => _Standings(); -} - -List _selectedTeams; - -class _Standings extends State { - static final sportUrl = 'https://charlotte49ers.com/services/adaptive_components.ashx?type=scoreboard&start=0&count=80'; - - Future> getEvents() async { - var url = '$sportUrl&sport_id=$sportID&name=&extra=%7B%7D'; - - print(url.toString()); - - http.Response response = await http.get(url); - Iterable games = json.decode(response.body); - - return games.map((json) => sport_standings_basketball.fromJson(json)).toList(); - //return games.map((e) => sport_schedule.fromJson(e)).toList(); - }*/ \ No newline at end of file diff --git a/lib/team_standings.dart b/lib/team_standings.dart new file mode 100644 index 0000000..cd7c434 --- /dev/null +++ b/lib/team_standings.dart @@ -0,0 +1,56 @@ +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; + +import 'screens/sport_standings_basketball.dart'; +import 'dart:convert'; + +class Standings extends StatefulWidget { + final int sportID; + Standings(this.sportID); + + @override + _Standings createState() => _Standings(sportID); +} + +List _selectedTeams; + +class _Standings extends State { + int sportID; + String sportUrl; + _Standings(this.sportID); + + Future> getEvents() 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((json) => sport_standings_basketball.fromJson(json)).toList(); + } + @override + Widget build(BuildContext context) { + return Center( + child: Column( + children: [ + + ], + ), + ); + } +} \ No newline at end of file From 9fc67ee039d6a8aac288671e3ce384913c46b841 Mon Sep 17 00:00:00 2001 From: kconnel7 Date: Thu, 30 Apr 2020 03:18:06 -0400 Subject: [PATCH 15/27] Standings - Layout to standings table --- lib/news/feed.dart | 1 - lib/route_generator.dart | 2 +- lib/screens/sport.dart | 4 +-- lib/screens/standing.dart | 70 ++++++++++++++++++++++++++++++++++++--- lib/team_standings.dart | 57 ++++++++++++++++++++++++++++--- 5 files changed, 119 insertions(+), 15 deletions(-) diff --git a/lib/news/feed.dart b/lib/news/feed.dart index f1938c6..18702f8 100644 --- a/lib/news/feed.dart +++ b/lib/news/feed.dart @@ -45,7 +45,6 @@ class HorizontalNewsFeed extends StatelessWidget { icon: Icon(Icons.navigate_next), onPressed: () => Navigator.of(context).pushNamed('/Sport', arguments: title.data), - /*onPressed: () { //changed Navigator.of(context).pushNamed('/Sport'); print(Navigator.of(context).pushNamed('/Sport')); diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 3af16f5..e0caca6 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -22,7 +22,7 @@ class RouteGenerator { case '/Schedule': return MaterialPageRoute(builder: (_) => Schedule(args)); case '/Standing': - return MaterialPageRoute(builder: (_) => Standing()); + return MaterialPageRoute(builder: (_) => Standing(args)); case '/Chat': return MaterialPageRoute(builder: (_) => Chat()); case '/Details': diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index 52e33a0..8a1bbba 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -99,7 +99,7 @@ class Sport extends StatelessWidget { ListTile( title: IconButton( icon: Icon(Icons.table_chart), - onPressed: () => Navigator.pushNamed(context, '/Standing', arguments: sport_ID), + onPressed: () => Navigator.pushNamed(context, '/Standing', arguments: [sport_ID, _curSport.name]), ), ), ListTile( @@ -158,8 +158,6 @@ class Sport extends StatelessWidget { } print(sport_ID); } - - } class Item { diff --git a/lib/screens/standing.dart b/lib/screens/standing.dart index fb1c0c6..cfd614f 100644 --- a/lib/screens/standing.dart +++ b/lib/screens/standing.dart @@ -1,8 +1,10 @@ import 'package:capstone_hungry_hippos/models/School.dart'; import 'package:flutter/material.dart'; +import '../team_standings.dart'; + class Standing extends StatelessWidget { - final _schools = [ + /*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), @@ -17,11 +19,15 @@ class Standing extends StatelessWidget { 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(this.sport); @override Widget build(BuildContext context) { - return Scaffold( + // *----- OLD CODE -------* + /*return Scaffold( appBar: AppBar( centerTitle: false, title: Text("49ers"), @@ -57,11 +63,65 @@ class Standing extends StatelessWidget { ], ), ), + );*/ + + // *----- 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: SingleChildScrollView ( + child: Column( + children: [ + Container( + child: standings, + alignment: Alignment(.85, 0), + height: 20, + color: Colors.grey, + ), + ], + ), + ),*/ + + drawer: Drawer( + child: ListView( + children: [ + 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 { +/*class SportLine extends StatelessWidget { const SportLine({ Key key, @required @@ -129,4 +189,4 @@ class SportLine extends StatelessWidget { Color c = i % 2 == 0 ? Colors.black12 : Colors.white30; return c; } -} +}*/ diff --git a/lib/team_standings.dart b/lib/team_standings.dart index cd7c434..4f31a03 100644 --- a/lib/team_standings.dart +++ b/lib/team_standings.dart @@ -4,9 +4,9 @@ import 'package:http/http.dart' as http; import 'screens/sport_standings_basketball.dart'; import 'dart:convert'; -class Standings extends StatefulWidget { +class Team_Standings extends StatefulWidget { final int sportID; - Standings(this.sportID); + Team_Standings(this.sportID); @override _Standings createState() => _Standings(sportID); @@ -14,12 +14,12 @@ class Standings extends StatefulWidget { List _selectedTeams; -class _Standings extends State { +class _Standings extends State { int sportID; String sportUrl; _Standings(this.sportID); - Future> getEvents() async { + Future> getTeams() async { print(sportID); switch(sportID.toString()) { @@ -41,13 +41,60 @@ class _Standings extends State { http.Response response = await http.get(sportUrl); Iterable games = json.decode(response.body); - return games.map((json) => sport_standings_basketball.fromJson(json)).toList(); + 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: [ + _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(.3), 2: FractionColumnWidth(.5)}, + 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 ** ], ), From b02efa9cc8503b7eea354df82a7272543353c602 Mon Sep 17 00:00:00 2001 From: kconnel7 Date: Thu, 30 Apr 2020 05:13:32 -0400 Subject: [PATCH 16/27] Standings - Conditioning on type of standings based on sport --- lib/screens/standing.dart | 16 ++++++-- lib/team_standings.dart | 81 ++++++++++++++++++++++++++++++++++++--- pubspec.lock | 7 ++++ pubspec.yaml | 1 + 4 files changed, 96 insertions(+), 9 deletions(-) diff --git a/lib/screens/standing.dart b/lib/screens/standing.dart index cfd614f..99eee24 100644 --- a/lib/screens/standing.dart +++ b/lib/screens/standing.dart @@ -24,6 +24,8 @@ class Standing extends StatelessWidget { final List sport; Standing(this.sport); + final teams = Team_Standings(); + @override Widget build(BuildContext context) { // *----- OLD CODE -------* @@ -66,7 +68,7 @@ class Standing extends StatelessWidget { );*/ // *----- Testing CODE -------* - var standings = Team_Standings(sport[0]); + //var standings = Team_Standings(sport[0]); return StatefulBuilder( builder: (context, StateSetter setState) => Scaffold( appBar: AppBar( @@ -75,9 +77,15 @@ class Standing extends StatelessWidget { backgroundColor: Colors.green, ), - body: Container ( - child: standings, - ), + /*body: Container ( + //child: standings, + ),*/ + + body: ListView( + children: [ + HorizontalStandings(teamStandings: teams), + ], + ), /*body: SingleChildScrollView ( child: Column( diff --git a/lib/team_standings.dart b/lib/team_standings.dart index 4f31a03..8a63735 100644 --- a/lib/team_standings.dart +++ b/lib/team_standings.dart @@ -1,10 +1,81 @@ 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 extends StatefulWidget { +class Team_Standings { + int sport_ID; + String sportUrl; + + Future> 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: [ + //_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; Team_Standings(this.sportID); @@ -47,7 +118,6 @@ class _Standings extends State { @override void initState() { _selectedTeams = []; - super.initState(); } @@ -57,7 +127,7 @@ class _Standings extends State { child: Column( children: [ _buildBasketballStandings(), - //Expanded(child: _eventLister()), + Expanded(child: _eventLister()), ], ), ); @@ -66,6 +136,7 @@ class _Standings extends State { Widget _buildBasketballStandings() { return Container( margin: EdgeInsets.all(15), + child: Table( border: TableBorder( horizontalInside: BorderSide( @@ -81,7 +152,7 @@ class _Standings extends State { 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: [ TableRow( children: [ Column(children:[Text('')]), @@ -100,4 +171,4 @@ class _Standings extends State { ), ); } -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 7fc9f02..b39c496 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -259,6 +259,13 @@ packages: url: "https://pub.dartlang.org" source: hosted 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: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 323c7ae..8177a56 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -29,6 +29,7 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.2 table_calendar: + table_sticky_headers: dev_dependencies: flutter_test: From 4d66b774fb42f7405022586e1eb49990fbf7d1c1 Mon Sep 17 00:00:00 2001 From: kconnel7 Date: Thu, 30 Apr 2020 10:50:35 -0400 Subject: [PATCH 17/27] 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); From 79886504aee1dd86efd6913fb4c21e40e39f4aec Mon Sep 17 00:00:00 2001 From: David Allemang Date: Thu, 30 Apr 2020 17:18:15 -0400 Subject: [PATCH 18/27] filter article list to only contain correct sports --- lib/news/feed.dart | 7 +++++-- lib/screens/favorites_reorder.dart | 1 - lib/screens/home_widget.dart | 1 + pubspec.lock | 24 ++++++++++++------------ 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/news/feed.dart b/lib/news/feed.dart index f1938c6..b367e55 100644 --- a/lib/news/feed.dart +++ b/lib/news/feed.dart @@ -20,11 +20,13 @@ class HorizontalNewsFeed extends StatelessWidget { final Feed newsFeed; final Text title; final double numCards; + final String sportFilter; const HorizontalNewsFeed({ Key key, @required this.newsFeed, @required this.title, + @required this.sportFilter, this.numCards = 3.25, }) : super(key: key); @@ -33,7 +35,8 @@ class HorizontalNewsFeed extends StatelessWidget { } @override Widget build(BuildContext context) { - //print(title.data); + var page = newsFeed.getPage(1, size: 100).then((page) => page.where((article) => article.sport.toLowerCase().contains(sportFilter.toLowerCase())).toList()); + return SizedBox( height: heightIn(context), child: Column( @@ -55,7 +58,7 @@ class HorizontalNewsFeed extends StatelessWidget { ), Expanded( child: FutureBuilder( - future: newsFeed.getPage(1), + future: page, builder: (ctx, snapshot) { if (!snapshot.hasData) { return Center(child: CircularProgressIndicator()); diff --git a/lib/screens/favorites_reorder.dart b/lib/screens/favorites_reorder.dart index 3c6ad9a..6e2d388 100644 --- a/lib/screens/favorites_reorder.dart +++ b/lib/screens/favorites_reorder.dart @@ -10,7 +10,6 @@ class Favorites { 'Basketball', 'Baseball', 'Soccer', - 'Tennis', 'Volleyball' ]; diff --git a/lib/screens/home_widget.dart b/lib/screens/home_widget.dart index 1a7f475..a9c919f 100644 --- a/lib/screens/home_widget.dart +++ b/lib/screens/home_widget.dart @@ -96,6 +96,7 @@ Future> _buildList() async { return HorizontalNewsFeed( newsFeed: feed, title: Text(sport), + sportFilter: sport, ); }).toList(); } diff --git a/pubspec.lock b/pubspec.lock index dd1117d..7fc9f02 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,21 +7,21 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "2.0.13" + version: "2.0.11" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted - version: "1.6.0" + version: "1.5.2" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.4.0" bloc: dependency: transitive description: @@ -35,21 +35,21 @@ packages: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "1.0.5" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.1.2" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.12" + version: "1.14.11" convert: dependency: transitive description: @@ -63,7 +63,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.3" cupertino_icons: dependency: "direct main" description: @@ -113,7 +113,7 @@ packages: name: image url: "https://pub.dartlang.org" source: hosted - version: "2.1.12" + version: "2.1.4" intl: dependency: transitive description: @@ -176,7 +176,7 @@ packages: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.0.5" rxdart: dependency: transitive description: @@ -230,7 +230,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.5.5" stack_trace: dependency: transitive description: @@ -272,7 +272,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.15" + version: "0.2.11" typed_data: dependency: transitive description: @@ -293,7 +293,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "3.6.1" + version: "3.5.0" sdks: dart: ">=2.6.0 <3.0.0" flutter: ">=1.12.13+hotfix.4 <2.0.0" From a21b86bf78f03891340f7d7c1964895c2555399a Mon Sep 17 00:00:00 2001 From: David Allemang Date: Thu, 30 Apr 2020 20:24:59 -0400 Subject: [PATCH 19/27] show standings in a table --- lib/screens/sport.dart | 6 +- lib/screens/sport_standings_basketball.dart | 107 -------- lib/screens/sport_standings_football.dart | 128 ---------- lib/screens/standing.dart | 216 +++------------- lib/team_standings.dart | 264 +++++++------------- 5 files changed, 132 insertions(+), 589 deletions(-) delete mode 100644 lib/screens/sport_standings_basketball.dart delete mode 100644 lib/screens/sport_standings_football.dart diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index 8a1bbba..a3d5795 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import '../news/feed.dart'; class Sport extends StatelessWidget { - static final List colorList = [ 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: [ 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( diff --git a/lib/screens/sport_standings_basketball.dart b/lib/screens/sport_standings_basketball.dart deleted file mode 100644 index ef5d74d..0000000 --- a/lib/screens/sport_standings_basketball.dart +++ /dev/null @@ -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 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(); - 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, - ), - ), - ); - } -} \ No newline at end of file diff --git a/lib/screens/sport_standings_football.dart b/lib/screens/sport_standings_football.dart deleted file mode 100644 index e833493..0000000 --- a/lib/screens/sport_standings_football.dart +++ /dev/null @@ -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 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(); - 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: [ - 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/screens/standing.dart b/lib/screens/standing.dart index 99eee24..87252ce 100644 --- a/lib/screens/standing.dart +++ b/lib/screens/standing.dart @@ -1,200 +1,54 @@ -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( + return StatefulBuilder( + builder: (context, StateSetter setState) => Scaffold( + appBar: AppBar( + centerTitle: false, + title: Text("$sport_name Standings"), + backgroundColor: Colors.green, + ), + body: ListView( children: [ - 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,), + HorizontalStandings(sportName: sport_name,), ], ), - ), - );*/ - - // *----- 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( + drawer: Drawer( + child: ListView( children: [ - 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: [ - Container( - child: standings, - alignment: Alignment(.85, 0), - height: 20, - color: Colors.grey, - ), - ], - ), - ),*/ - - drawer: Drawer( - child: ListView( - children: [ - 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: [ - 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; - } -}*/ diff --git a/lib/team_standings.dart b/lib/team_standings.dart index be4b453..ad18b70 100644 --- a/lib/team_standings.dart +++ b/lib/team_standings.dart @@ -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> 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", + ], + }; - @override - Widget build(BuildContext context) { - return Center( + final String sportName; + + const HorizontalStandings({Key key, this.sportName}) : super(key: key); + + Future 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: [ - 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], - ); + 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() + .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() + .toList(), ); - } - }, - ), - ) - /*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], - ); - } + + return Column( + children: [ + Text( + conference['shortName'], + style: TextStyle(fontSize: 16), + ), + table, + ], ); - } - }, - ), - ),*/ + }) + .cast() + .toList()), ], ), ); - } -} -//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 { - int sportID; - String sportUrl; - _Standings(this.sportID); - - Future> 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(); + 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: [ - _buildBasketballStandings(), - Expanded(child: _eventLister()), + FutureBuilder( + 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 ** - - ], - ), - ); - } -}*/ \ No newline at end of file +} From 3e0efc8aff09818952320bff3088d8de7a3df1fd Mon Sep 17 00:00:00 2001 From: David Allemang Date: Thu, 30 Apr 2020 20:27:17 -0400 Subject: [PATCH 20/27] fix sport page articles bug --- lib/screens/sport.dart | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index 6411d02..43502bd 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -69,10 +69,7 @@ class Sport extends StatelessWidget { ), body: ListView( children: [ - 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), sportFilter: _curSport.name,), ], ), drawer: Drawer( From 2209d1b99245e2db3bfe899fc859727f3eac92e7 Mon Sep 17 00:00:00 2001 From: David Allemang Date: Thu, 30 Apr 2020 20:31:01 -0400 Subject: [PATCH 21/27] missed a piece in the merge --- lib/screens/sport.dart | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index 105b261..25a15e3 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -7,15 +7,9 @@ class Sport extends StatelessWidget { const Item("Basketball", Colors.red,[5,13]), const Item("Soccer", Colors.pinkAccent,[9,17]), const Item('Baseball', Colors.orange,[1]), -<<<<<<< HEAD const Item('Softball', Colors.yellow,[12]), const Item('Volleyball', Colors.blue,[20]), const Item('Tennis', Colors.yellowAccent,[10,18]), -======= - const Item('Volleyball', Colors.blue,[0]), - const Item('Softball', Colors.yellow,[0]), - const Item('Tennis', Colors.yellowAccent,[0,0]), ->>>>>>> filter-sport-articles ]; final feed = Feed(); // was var not final From f71bd6ad2179ca28c2625df5be9f46a1aeb775e3 Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Rosario Date: Thu, 30 Apr 2020 21:19:23 -0400 Subject: [PATCH 22/27] logic for game card --- lib/models/game_cards.dart | 181 +++++++++++++++++++++++++++++++++++++ lib/monthly_calendar.dart | 177 ++++++++++++++---------------------- lib/screens/sport.dart | 8 +- 3 files changed, 253 insertions(+), 113 deletions(-) create mode 100644 lib/models/game_cards.dart diff --git a/lib/models/game_cards.dart b/lib/models/game_cards.dart new file mode 100644 index 0000000..1cde687 --- /dev/null +++ b/lib/models/game_cards.dart @@ -0,0 +1,181 @@ +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; +import '../screens/sport_schedule.dart'; +import 'dart:convert'; + +class GameCard extends StatefulWidget { + final int sportID; + + GameCard(this.sportID); + + @override + _SportsCard createState() => _SportsCard(sportID); +} + +//List _selectedEvents; //original that makes events work +List + _selectedEvents; //Removing the allows it to still work. Proceed with caution +DateTime selectedDay; +Map> _events; + +class _SportsCard extends State with TickerProviderStateMixin { + int sportID; + + _SportsCard(this.sportID); + + AnimationController _animationController; + + static final sportUrl = + 'https://charlotte49ers.com/services/adaptive_components.ashx?type=scoreboard&start=0&count=80'; + + Future> getEvents() async { + var url = '$sportUrl&sport_id=$sportID&name=&extra=%7B%7D'; + + http.Response response = await http.get(url); + Iterable games = json.decode(response.body); + + return games + .map((json) => sport_schedule.fromJson(json)) + .toList(); + //return games.map((e) => sport_schedule.fromJson(e)).toList(); + } + + Future>> getGames() async { + Map> mapGrab = {}; + + List eventInfo = await getEvents(); + + for (int i = 0; i < eventInfo.length; i++) { + var sportEvent = DateTime(eventInfo[i].date.year, eventInfo[i].date.month, + eventInfo[i].date.day); + var original = mapGrab[sportEvent]; + + if (original == null) { + //print("null"); + mapGrab[sportEvent] = [eventInfo[i]]; + } else { + //print(eventInfo[i].date); + mapGrab[sportEvent] = List.from(original)..addAll([eventInfo[i]]); + } + } + return mapGrab; + } + + @override + void initState() { + //final _selectedDay = DateTime.now(); + + //_selectedEvents = _events[_selectedDay] ?? []; + _selectedEvents = []; + _animationController = AnimationController( + vsync: this, + duration: const Duration(milliseconds: 400), + ); + + _animationController.forward(); + + WidgetsBinding.instance.addPostFrameCallback((_) { + getGames().then((val) => setState(() { + _events = val; + })); + }); + + super.initState(); + } + + @override + void dispose() { + _animationController.dispose(); + super.dispose(); + } + + //----- Builds event Lister ----- + @override + Widget build(BuildContext context) { + return Center( + child: Container( + child: Expanded(child: _eventLister()), + ), + ); + } + + //----- Creates event display ----- + + Text _pastGameScore( + String homeAway, String winLoss, String uncc, String opponent) { + if (homeAway == "H" || homeAway == "T") { + return (Text('$uncc - $opponent')); + } else { + return (Text('$opponent - $uncc')); + } + } + + Image _homeAwayImageOrder(String h, String opposingTeam, bool l) { + if ((h == "H") == l) { + return (Image( + image: AssetImage('assets/school_logos/uncc.png'), + width: 50, + )); + } else { + return (Image.network( + 'https://charlotte49ers.com' + opposingTeam, + width: 50.0, + )); + } + } + + Widget _eventLister() { + var _months = {1:'JAN', 2:'FEB', 3:'MAR', 4:'APR', 5:'MAY', 6:'JUN', + 7:'JUL', 8:'AUG', 9:'SEP', 10:'OCT', 11:'NOV', 12:'DEC'}; + return SizedBox( + height: 62, + child: Column( + children: _selectedEvents + .map((event) => Container( + decoration: BoxDecoration( + border: Border.all( + color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green + width: 0.8, + ), + borderRadius: BorderRadius.circular(12.0), + ), + height: 70.0, + margin: + const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0), + child: ListTile( + leading: _homeAwayImageOrder( + event.location_indicator.toString(), + event.image.toString(), true), + title: Wrap( + children: [ + if (event.status.toString() == "null") // no game yet + Text( + '${_months[event.date.month]} ${event.date.day.toString()}') + else + _pastGameScore( + event.location_indicator.toString(), + event.status.toString(), + event.team_score.toString(), + event.opponent_score.toString()), + ], + ), + + //Type of sport - Location + subtitle: Wrap(children: [ + //Should be either live time or time game will be, nothing for past games + ]), + + trailing: _homeAwayImageOrder( + event.location_indicator.toString(), + event.image.toString(), false), + onTap: () => + print('${event.date}'), //When event display is clicked + ), + )) + .toList(), + ), + ); + } +} + + diff --git a/lib/monthly_calendar.dart b/lib/monthly_calendar.dart index 57ca1b1..78ed940 100644 --- a/lib/monthly_calendar.dart +++ b/lib/monthly_calendar.dart @@ -115,8 +115,7 @@ class _Calendar extends State with TickerProviderStateMixin { child: Column( children: [ _buildCalendar(), - const SizedBox(height: 8.0), - Expanded(child: _eventLister()), + _eventLister(), ], ), ); @@ -272,119 +271,79 @@ class _Calendar extends State with TickerProviderStateMixin { } //----- Creates event display ----- + Text _pastGameScore( + String homeAway, String winLoss, String uncc, String opponent) { + if (homeAway == "H" || homeAway == "T") { + return (Text('$uncc - $opponent')); + } else { + return (Text('$opponent - $uncc')); + } + } + + Image _homeAwayImageOrder(String h, String opposingTeam, bool l) { + if ((h == "H") == l) { + return (Image( + image: AssetImage('assets/school_logos/uncc.png'), + width: 50, + )); + } else { + return (Image.network( + 'https://charlotte49ers.com' + opposingTeam, + width: 50.0, + )); + } + } + Widget _eventLister() { - return ListView( - children: _selectedEvents.map((event) => Container( - decoration: BoxDecoration( - border: Border.all( - color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green - width: 0.8, - ), - - borderRadius: BorderRadius.circular(12.0), - ), - - height: 70.0, - margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0), - - child: ListTile( - leading: Image.network( - 'https://charlotte49ers.com' + event.image.toString(), - width: 50.0, - ), - title: Wrap( - children: [ - if (event.location_indicator.toString() == "H") - Text( - 'vs. ', - style: TextStyle( //home game - fontSize: 11.6, - ), - ) - else - Text( - 'at ', - style: TextStyle( //away game - fontSize: 11.6, - ), - ), - - Text( - event.opponentTitle.toString(), - style: TextStyle( - fontSize: 11.6, - ), - ) //opponent name - ], - ), - - //Type of sport - Location - subtitle: Text( - event.sportTitle.toString() + " - " + event.location.toString(), - style: TextStyle( - fontSize: 10.3, + var _months = {1:'JAN', 2:'FEB', 3:'MAR', 4:'APR', 5:'MAY', 6:'JUN', + 7:'JUL', 8:'AUG', 9:'SEP', 10:'OCT', 11:'NOV', 12:'DEC'}; + return SizedBox( + height: 78, + child: Column( + children: _selectedEvents + .map((event) => Container( + decoration: BoxDecoration( + border: Border.all( + color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green + width: 0.8, ), + borderRadius: BorderRadius.circular(12.0), ), + height: 70.0, + margin: + const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0), + child: ListTile( + leading: _homeAwayImageOrder( + event.location_indicator.toString(), + event.image.toString(), true), + title: Wrap( + children: [ + if (event.status.toString() == "null") // no game yet + Text( + '${_months[event.date.month]} ${event.date.day.toString()}') + else + _pastGameScore( + event.location_indicator.toString(), + event.status.toString(), + event.team_score.toString(), + event.opponent_score.toString()), + ], + ), - trailing: Wrap( - //mainAxisSize: MainAxisSize.min, + //Type of sport - Location + subtitle: Wrap(children: [ + //Should be either live time or time game will be, nothing for past games + ]), - children: [ - //---Score--- - //Game hasn't occured - if (event.status.toString() == "null") - Text("TBD"), - - //---Scores--- - if (event.status.toString() == "W" || event.status.toString() == "L" || event.status.toString() == "T") //Finished games - Text(event.team_score.toString() + " - " + event.opponent_score.toString() + " ") - - else if (event.status.toString() == "N" && event.team_score.toString() != "null" && event.opponent_score.toString() != "null") //Games that don't count - Text(event.team_score.toString() + " - " + event.opponent_score.toString() + " "), - - //---Game Status--- - if (event.status.toString() == "W") //Win - Text( - (" " + event.status.toString() + " "), - style: TextStyle( - color: Colors.white, - backgroundColor: Color.fromRGBO(0, 112, 60, 1), - ) - ), - - if (event.status.toString() == "L" || event.status.toString() == "T") //Lose-Tie - Text( - (" " + event.status.toString() + " "), - textAlign: TextAlign.center, - style: TextStyle( - color: Colors.black, - backgroundColor: Colors.grey, - ) - ), - - if (event.status.toString() == "N" && event.postscore.toString() != "Canceled") //N - Text( - (" " + event.status.toString() + " "), - textAlign: TextAlign.center, - style: TextStyle( - color: Colors.black, - backgroundColor: Colors.grey, - ) - ) - else if (event.team_score.toString() == "null" && event.opponent_score.toString() == "null" - && event.status.toString() == "N") //Game was canceled - Text( - "Canceled", - style: TextStyle( - color: Colors.red, - ) - ), - - ], + trailing: _homeAwayImageOrder( + event.location_indicator.toString(), + event.image.toString(), false), + onTap: () => + print('${event.date}'), //When event display is clicked ), - onTap: () => print('$event tapped!'), //When event display is clicked - ), - )).toList(), + )) + .toList(), + ), ); } } \ No newline at end of file diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index 6411d02..3710833 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -69,10 +69,10 @@ class Sport extends StatelessWidget { ), body: ListView( children: [ - 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), sportFilter: _curSport.name,), + HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name), sportFilter: _curSport.name), + HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name), sportFilter: _curSport.name), + HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name), sportFilter: _curSport.name), ], ), drawer: Drawer( From a2950f699796ca619cc1d247c65c502c9dd00763 Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Rosario Date: Fri, 1 May 2020 02:45:54 -0400 Subject: [PATCH 23/27] logic for game card --- assets/school_logos/UNC-Charlotte (1).png | Bin 0 -> 9154 bytes lib/models/game_cards.dart | 257 ++++++++++------------ lib/route_generator.dart | 3 + lib/screens/sport_schedule.dart | 114 ++++++++++ 4 files changed, 228 insertions(+), 146 deletions(-) create mode 100644 assets/school_logos/UNC-Charlotte (1).png diff --git a/assets/school_logos/UNC-Charlotte (1).png b/assets/school_logos/UNC-Charlotte (1).png new file mode 100644 index 0000000000000000000000000000000000000000..bd01193eb3bb39468132962e092f44b489599135 GIT binary patch literal 9154 zcmV;zBR$-SP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>DBUed8K~#8N?OX?V zRMobggwUlcO*%q=BtS@=mXJmW5PApcC6I*l9#TkVGBfGD_YO#}N>dcU2qGd?MWjdv zDT)IAZ>=*Eir)L~#mm+E?#ueV{UtfG_c>?(dzF8!y(gjuX^;kKkiSp>kti>9&XoMr znZtCK8sudqCw^2|UZTw}WyvlX8%w+g=`J_OKP!dVO9!VbrHE6Bk*~J7Ta!F8cJJQG z4!VyUDuMIl9Jp{2y%g{4&5=6_) z(3618PmrN9ZDNpaNP|2t2M-=>Riv{0+L9u%$ln&CiG$!ZdkA)XT#a^tBMC$cSOkhu ztd{>=nLA&q8`dE8GGRikeu>KVGrKSX(2oF|Wd;+I7C5lpA2oHmptsB%A`c1XMTt?F z==4SI#@yz*p$$?miFgSKLL`#RkKG+&%@xw2du2Z(x z4Q&vX+9c;q(;{>L5`_`9Y>I_bdLt{&3_smGhdrl1hsbRh8n2*iMI}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zPoH*H&szm$k<;jy>$zkfA{$C`yxw)+?QpPQ)P!Hde9xHhiL3CzPgalkq zY)3#aFBJZt6>rdUVS;~hW78x}LJBMqUTFma_AAv8XXfGbnmo~nu;kx-O6TdaH3 zf4>x{r<+y9j|!{M4Bwd>C;vWCAp@UB35eC6Kb{*S!`rK5SV+w?Mv7pC6iT8NN%UEM zoXzD5wcVZy&4}2VteFn+@$vukSN{JiB_qSXQ+4Vjab^72c{TB4!ir*KNmUxh{CCn^ zD=Jj>Ii*TlRdu3kV7bP1R%P0Fi~N+3j=G@@(jX1eAPw>#FCx+Z001)uGuUhlkpKVy M07*qoM6N<$f?=_U%m4rY literal 0 HcmV?d00001 diff --git a/lib/models/game_cards.dart b/lib/models/game_cards.dart index 1cde687..cee780a 100644 --- a/lib/models/game_cards.dart +++ b/lib/models/game_cards.dart @@ -1,49 +1,27 @@ import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; +import 'package:table_calendar/table_calendar.dart'; + import '../screens/sport_schedule.dart'; import 'dart:convert'; -class GameCard extends StatefulWidget { - final int sportID; - - GameCard(this.sportID); - - @override - _SportsCard createState() => _SportsCard(sportID); -} - -//List _selectedEvents; //original that makes events work -List - _selectedEvents; //Removing the allows it to still work. Proceed with caution -DateTime selectedDay; -Map> _events; - -class _SportsCard extends State with TickerProviderStateMixin { - int sportID; - - _SportsCard(this.sportID); - - AnimationController _animationController; +class GameCardFeed{ static final sportUrl = 'https://charlotte49ers.com/services/adaptive_components.ashx?type=scoreboard&start=0&count=80'; - - Future> getEvents() async { + Future> getEvents(int sportID) async { var url = '$sportUrl&sport_id=$sportID&name=&extra=%7B%7D'; - http.Response response = await http.get(url); Iterable games = json.decode(response.body); - return games .map((json) => sport_schedule.fromJson(json)) .toList(); //return games.map((e) => sport_schedule.fromJson(e)).toList(); } - - Future>> getGames() async { + Future> getGames(int sportID) async { Map> mapGrab = {}; - List eventInfo = await getEvents(); + List eventInfo = await getEvents(sportID); for (int i = 0; i < eventInfo.length; i++) { var sportEvent = DateTime(eventInfo[i].date.year, eventInfo[i].date.month, @@ -55,127 +33,114 @@ class _SportsCard extends State with TickerProviderStateMixin { mapGrab[sportEvent] = [eventInfo[i]]; } else { //print(eventInfo[i].date); - mapGrab[sportEvent] = List.from(original)..addAll([eventInfo[i]]); + mapGrab[sportEvent] = List.from(original) + ..addAll([eventInfo[i]]); } } - return mapGrab; - } - - @override - void initState() { - //final _selectedDay = DateTime.now(); - - //_selectedEvents = _events[_selectedDay] ?? []; - _selectedEvents = []; - _animationController = AnimationController( - vsync: this, - duration: const Duration(milliseconds: 400), - ); - - _animationController.forward(); - - WidgetsBinding.instance.addPostFrameCallback((_) { - getGames().then((val) => setState(() { - _events = val; - })); - }); - - super.initState(); - } - - @override - void dispose() { - _animationController.dispose(); - super.dispose(); - } - - //----- Builds event Lister ----- - @override - Widget build(BuildContext context) { - return Center( - child: Container( - child: Expanded(child: _eventLister()), - ), - ); - } - - //----- Creates event display ----- - - Text _pastGameScore( - String homeAway, String winLoss, String uncc, String opponent) { - if (homeAway == "H" || homeAway == "T") { - return (Text('$uncc - $opponent')); - } else { - return (Text('$opponent - $uncc')); - } - } - - Image _homeAwayImageOrder(String h, String opposingTeam, bool l) { - if ((h == "H") == l) { - return (Image( - image: AssetImage('assets/school_logos/uncc.png'), - width: 50, - )); - } else { - return (Image.network( - 'https://charlotte49ers.com' + opposingTeam, - width: 50.0, - )); - } - } - - Widget _eventLister() { - var _months = {1:'JAN', 2:'FEB', 3:'MAR', 4:'APR', 5:'MAY', 6:'JUN', - 7:'JUL', 8:'AUG', 9:'SEP', 10:'OCT', 11:'NOV', 12:'DEC'}; - return SizedBox( - height: 62, - child: Column( - children: _selectedEvents - .map((event) => Container( - decoration: BoxDecoration( - border: Border.all( - color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green - width: 0.8, - ), - borderRadius: BorderRadius.circular(12.0), - ), - height: 70.0, - margin: - const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0), - child: ListTile( - leading: _homeAwayImageOrder( - event.location_indicator.toString(), - event.image.toString(), true), - title: Wrap( - children: [ - if (event.status.toString() == "null") // no game yet - Text( - '${_months[event.date.month]} ${event.date.day.toString()}') - else - _pastGameScore( - event.location_indicator.toString(), - event.status.toString(), - event.team_score.toString(), - event.opponent_score.toString()), - ], - ), - - //Type of sport - Location - subtitle: Wrap(children: [ - //Should be either live time or time game will be, nothing for past games - ]), - - trailing: _homeAwayImageOrder( - event.location_indicator.toString(), - event.image.toString(), false), - onTap: () => - print('${event.date}'), //When event display is clicked - ), - )) - .toList(), - ), - ); + List list = []; + mapGrab.forEach((k, v) => list.add(ScheduleObject(k, v))); + return list; } } +class HorizontalGameCards extends StatelessWidget { + final GameCardFeed gameCard; + final double numCards; + final int sportID; + const HorizontalGameCards({ + Key key, + @required this.gameCard, + this.numCards = 8, + this.sportID, + }) : super(key: key); + + double heightIn(BuildContext context) { + return MediaQuery.of(context).size.height / numCards; + } + + @override + Widget build(BuildContext context) { + var card = gameCard.getGames(sportID); + var events = []; + return SizedBox( + height: heightIn(context),//heightIn(context), + child: FutureBuilder( + future: card, + // ignore: missing_return + builder: (ctx, snapshot) { + print(snapshot); + if (!snapshot.hasData) { + return Center(child: CircularProgressIndicator()); + } else { + events = snapshot.data; + + return ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: events.length, + itemBuilder: (context, index) { + return GameCard( + gameCard: events[index].sportSched[0], + ); + }, + ); + } + }, + ), + ); + } + } + +class ScheduleObject { + DateTime d; + List sportSched; + ScheduleObject(this.d, this.sportSched); +} + + + + + + +class GameCardTest extends StatelessWidget{ + final int sportID; + GameCardTest(this.sportID); + + @override + Widget build(BuildContext context) { + final feed = GameCardFeed(); + return StatefulBuilder( + builder: (context, StateSetter setState) => Scaffold( + appBar: AppBar( + centerTitle: false, + title: Text("49ers"), + backgroundColor: Colors.green, + ), + body: HorizontalGameCards(gameCard: feed, sportID: sportID,), + drawer: Drawer( + child: ListView( + children: [ + 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, '/'), + ), + ), + ], + ), + ) + )); + } +} \ No newline at end of file diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 3af16f5..d0d2c0b 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -1,3 +1,4 @@ +import 'package:capstone_hungry_hippos/models/game_cards.dart'; import 'package:capstone_hungry_hippos/screens/chat.dart'; import 'package:capstone_hungry_hippos/screens/schedule.dart'; import 'package:capstone_hungry_hippos/screens/standing.dart'; @@ -31,6 +32,8 @@ class RouteGenerator { return MaterialPageRoute(builder: (_) => FavoritesManager()); case '/Twitter': return MaterialPageRoute(builder: (_) => TwitterFeed()); + case '/gamecardtest': + return MaterialPageRoute(builder: (_) => GameCardTest(args)); default: return _errorRoute(); } diff --git a/lib/screens/sport_schedule.dart b/lib/screens/sport_schedule.dart index 5dcb470..a7684b4 100644 --- a/lib/screens/sport_schedule.dart +++ b/lib/screens/sport_schedule.dart @@ -62,3 +62,117 @@ class sport_schedule { ); } } + +class GameCard extends StatelessWidget { + const GameCard({ + Key key, + @required this.gameCard, + this.numCards = 1.75, + }) : super(key: key); + + final sport_schedule gameCard; + final double numCards; + + double widthIn(BuildContext context) { + return MediaQuery.of(context).size.width / numCards; + } + + Text _pastGameScore( + String homeAway, String winLoss, String uncc, String opponent) { + if (homeAway == "H" || homeAway == "T") { + return (Text('$uncc - $opponent')); + } else { + return (Text('$opponent - $uncc')); + } + } + + Image _homeAwayImageOrder(String h, String opposingTeam, bool l, BuildContext ctx) { + if ((h == "H") == l) { + return (Image.network( + 'https://fiusports.com/images/logos/UNC-Charlotte.png?width=80&height=80&mode=max' + )); + } else { + return (Image.network( + 'https://charlotte49ers.com' + opposingTeam, + )); + } + } + + @override + Widget build(BuildContext ctx) { + var _months = { + 1: 'JAN', + 2: 'FEB', + 3: 'MAR', + 4: 'APR', + 5: 'MAY', + 6: 'JUN', + 7: 'JUL', + 8: 'AUG', + 9: 'SEP', + 10: 'OCT', + 11: 'NOV', + 12: 'DEC' + }; + var decoration = BoxDecoration( + border: Border.all( + color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green + width: .5, + ), + borderRadius: BorderRadius.circular(12.0), + ); + + var body = Column( + verticalDirection: VerticalDirection.up, + children: [ + Container( + color: Colors.white, + child: ListTile( + leading: SizedBox( + //width: widthIn(ctx)/3 - 5, + child: Container(decoration: decoration,child: _homeAwayImageOrder( + gameCard.location_indicator, + gameCard.image, + true, ctx))), + title: SizedBox( + //width: widthIn(ctx)/3 - 5, + child: Container(decoration: decoration,child: Wrap( + children: [ + if (gameCard.status == "null") // no game yet + Text( + '${_months[gameCard.date.month]} ${gameCard.date.day}') + else + _pastGameScore( + gameCard.location_indicator, + gameCard.status, + gameCard.team_score, + gameCard.opponent_score,), + ], + )) + ), + trailing: SizedBox( + //width: widthIn(ctx)/3 - 5, + child: Container(decoration: decoration,child: _homeAwayImageOrder( + gameCard.location_indicator, + gameCard.image, + false, ctx))), + onTap: () => print('${gameCard.date}'), + ), + ), + ], + ); + + + return SizedBox( + width: widthIn(ctx), + child: Card( + semanticContainer: true, + clipBehavior: Clip.antiAliasWithSaveLayer, + child: Container( + decoration: decoration, + child: body, + ), + ), + ); + } +} From 465eb96f4bb14fd7ce507ab82127aea5205c20c7 Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Rosario Date: Fri, 1 May 2020 11:19:17 -0400 Subject: [PATCH 24/27] logic for game card --- lib/models/game_cards.dart | 49 ---------------------------- lib/route_generator.dart | 3 -- lib/screens/sport.dart | 13 +++++--- lib/screens/sport_schedule.dart | 58 +++++++++++++++++++++++---------- 4 files changed, 48 insertions(+), 75 deletions(-) diff --git a/lib/models/game_cards.dart b/lib/models/game_cards.dart index cee780a..156d767 100644 --- a/lib/models/game_cards.dart +++ b/lib/models/game_cards.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; -import 'package:table_calendar/table_calendar.dart'; import '../screens/sport_schedule.dart'; import 'dart:convert'; @@ -95,52 +94,4 @@ class ScheduleObject { DateTime d; List sportSched; ScheduleObject(this.d, this.sportSched); -} - - - - - - -class GameCardTest extends StatelessWidget{ - final int sportID; - GameCardTest(this.sportID); - - @override - Widget build(BuildContext context) { - final feed = GameCardFeed(); - return StatefulBuilder( - builder: (context, StateSetter setState) => Scaffold( - appBar: AppBar( - centerTitle: false, - title: Text("49ers"), - backgroundColor: Colors.green, - ), - body: HorizontalGameCards(gameCard: feed, sportID: sportID,), - drawer: Drawer( - child: ListView( - children: [ - 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, '/'), - ), - ), - ], - ), - ) - )); - } } \ No newline at end of file diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 4ffc765..e0caca6 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -1,4 +1,3 @@ -import 'package:capstone_hungry_hippos/models/game_cards.dart'; import 'package:capstone_hungry_hippos/screens/chat.dart'; import 'package:capstone_hungry_hippos/screens/schedule.dart'; import 'package:capstone_hungry_hippos/screens/standing.dart'; @@ -32,8 +31,6 @@ class RouteGenerator { return MaterialPageRoute(builder: (_) => FavoritesManager()); case '/Twitter': return MaterialPageRoute(builder: (_) => TwitterFeed()); - case '/gamecardtest': - return MaterialPageRoute(builder: (_) => GameCardTest(args)); default: return _errorRoute(); } diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index 25a15e3..201374b 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import '../news/feed.dart'; +import '../models/game_cards.dart'; class Sport extends StatelessWidget { static final List colorList = [ @@ -13,6 +14,7 @@ class Sport extends StatelessWidget { ]; final feed = Feed(); // was var not final + final gameCard = GameCardFeed(); final String imageMale = 'images/male.png'; final String imageFemale = 'images/female.png'; @@ -43,9 +45,9 @@ class Sport extends StatelessWidget { return StatefulBuilder( builder: (context, StateSetter setState) => Scaffold( appBar: AppBar( - centerTitle: false, - title: buildDropdownButton(selectedSport, setState), - backgroundColor: _curSport.color, + centerTitle: false, + title: buildDropdownButton(selectedSport, setState), + backgroundColor: _curSport.color, //--Gender Switch-- Need to make condition to determine gender actions: [ @@ -54,8 +56,8 @@ class Sport extends StatelessWidget { value: genderSport, onChanged: (value) { setState(() { - genderSport = value; - _genderSwitcherCheck(); + genderSport = value; + _genderSwitcherCheck(); }); }, inactiveThumbColor: Colors.lightBlue, @@ -68,6 +70,7 @@ class Sport extends StatelessWidget { ), body: ListView( children: [ + HorizontalGameCards(gameCard: gameCard, sportID: sport_ID,), HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name), sportFilter: _curSport.name,), ], ), diff --git a/lib/screens/sport_schedule.dart b/lib/screens/sport_schedule.dart index a7684b4..47e5308 100644 --- a/lib/screens/sport_schedule.dart +++ b/lib/screens/sport_schedule.dart @@ -67,7 +67,7 @@ class GameCard extends StatelessWidget { const GameCard({ Key key, @required this.gameCard, - this.numCards = 1.75, + this.numCards = 2.25, }) : super(key: key); final sport_schedule gameCard; @@ -89,7 +89,7 @@ class GameCard extends StatelessWidget { Image _homeAwayImageOrder(String h, String opposingTeam, bool l, BuildContext ctx) { if ((h == "H") == l) { return (Image.network( - 'https://fiusports.com/images/logos/UNC-Charlotte.png?width=80&height=80&mode=max' + 'https://fiusports.com/images/logos/UNC-Charlotte.png?width=80&height=80&mode=max', )); } else { return (Image.network( @@ -97,6 +97,16 @@ class GameCard extends StatelessWidget { )); } } + + Color winLoss(String wl){ + if (wl == "W") { + return Colors.green; + } else if (wl == "L") { + return Colors.red; + } else { + return Colors.grey; + } + } @override Widget build(BuildContext ctx) { @@ -116,12 +126,12 @@ class GameCard extends StatelessWidget { }; var decoration = BoxDecoration( border: Border.all( - color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green - width: .5, + color: winLoss(gameCard.status), //UNCC Green + width: 1.2, ), - borderRadius: BorderRadius.circular(12.0), + borderRadius: BorderRadius.circular(2), ); - + var logoWidth = 4.5; var body = Column( verticalDirection: VerticalDirection.up, children: [ @@ -129,18 +139,19 @@ class GameCard extends StatelessWidget { color: Colors.white, child: ListTile( leading: SizedBox( - //width: widthIn(ctx)/3 - 5, - child: Container(decoration: decoration,child: _homeAwayImageOrder( + width: widthIn(ctx)/logoWidth, + child: _homeAwayImageOrder( gameCard.location_indicator, gameCard.image, - true, ctx))), - title: SizedBox( - //width: widthIn(ctx)/3 - 5, - child: Container(decoration: decoration,child: Wrap( + true, ctx)), + title: FittedBox( + fit: BoxFit.contain, + child: Wrap( children: [ if (gameCard.status == "null") // no game yet Text( - '${_months[gameCard.date.month]} ${gameCard.date.day}') + '${_months[gameCard.date.month]} ${gameCard.date.day}' + ) else _pastGameScore( gameCard.location_indicator, @@ -148,15 +159,26 @@ class GameCard extends StatelessWidget { gameCard.team_score, gameCard.opponent_score,), ], - )) + ) + ), + subtitle: FittedBox( + fit: BoxFit.contain, + child: Wrap( + children: [ + if (gameCard.status != "null") // no game yet + Text( + '${_months[gameCard.date.month]} ${gameCard.date.day}', textAlign: TextAlign.center, + ), + ], + ) ), trailing: SizedBox( - //width: widthIn(ctx)/3 - 5, - child: Container(decoration: decoration,child: _homeAwayImageOrder( + width: widthIn(ctx)/logoWidth, + child: _homeAwayImageOrder( gameCard.location_indicator, gameCard.image, - false, ctx))), - onTap: () => print('${gameCard.date}'), + false, ctx)), + onTap: () => print('${gameCard.status}'), ), ), ], From 0c1158c27ba4ba04d16eb2f6302f364d28b5736d Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Rosario Date: Fri, 1 May 2020 11:22:55 -0400 Subject: [PATCH 25/27] All green --- lib/screens/sport.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index 201374b..5a1c3ec 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -5,12 +5,12 @@ import '../models/game_cards.dart'; class Sport extends StatelessWidget { static final List colorList = [ const Item('Football', Colors.green,[3]), - const Item("Basketball", Colors.red,[5,13]), - const Item("Soccer", Colors.pinkAccent,[9,17]), - const Item('Baseball', Colors.orange,[1]), - const Item('Softball', Colors.yellow,[12]), - const Item('Volleyball', Colors.blue,[20]), - const Item('Tennis', Colors.yellowAccent,[10,18]), + const Item("Basketball", Colors.green,[5,13]), + const Item("Soccer", Colors.green,[9,17]), + const Item('Baseball', Colors.green,[1]), + const Item('Softball', Colors.green,[12]), + const Item('Volleyball', Colors.green,[20]), + const Item('Tennis', Colors.green,[10,18]), ]; final feed = Feed(); // was var not final From 0d95b669603b3bae0ec25c9037fc2f20a3a9cbff Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Rosario Date: Fri, 1 May 2020 13:25:45 -0400 Subject: [PATCH 26/27] Vertical Articles for sport Page --- lib/models/game_cards.dart | 4 +-- lib/news/article.dart | 56 +++++++++++++++++++++++++++++++++ lib/news/feed.dart | 40 +++++++++++++++++++++++ lib/screens/sport.dart | 7 +++-- lib/screens/sport_schedule.dart | 10 +++--- pubspec.lock | 24 +++++++------- 6 files changed, 120 insertions(+), 21 deletions(-) diff --git a/lib/models/game_cards.dart b/lib/models/game_cards.dart index 156d767..f36156d 100644 --- a/lib/models/game_cards.dart +++ b/lib/models/game_cards.dart @@ -63,12 +63,12 @@ class HorizontalGameCards extends StatelessWidget { var card = gameCard.getGames(sportID); var events = []; return SizedBox( - height: heightIn(context),//heightIn(context), + height: heightIn(context), child: FutureBuilder( future: card, // ignore: missing_return builder: (ctx, snapshot) { - print(snapshot); + //print(snapshot); if (!snapshot.hasData) { return Center(child: CircularProgressIndicator()); } else { diff --git a/lib/news/article.dart b/lib/news/article.dart index 033f85b..9019538 100644 --- a/lib/news/article.dart +++ b/lib/news/article.dart @@ -90,3 +90,59 @@ class ArticleCard extends StatelessWidget { ); } } + +class ArticleCardVert extends StatelessWidget { + const ArticleCardVert({ + Key key, + @required this.article, + this.numCards = 2.1, + }) : super(key: key); + + final Article article; + final double numCards; + + double heightIn(BuildContext context) { + return (MediaQuery.of(context).size.height * 7/8) / numCards; + } + + @override + Widget build(BuildContext context) { + var decoration = BoxDecoration( + image: DecorationImage( + image: NetworkImage( + article.thumbUrl, + ), + fit: BoxFit.cover, + ), + ); + + var body = Column( + verticalDirection: VerticalDirection.up, + children: [ + Container( + color: Colors.white, + child: ListTile( + title: Text( + article.mediumHeadline, + overflow: TextOverflow.ellipsis, + maxLines: 2, + ), + ), + ), + ], + ); + + + return SizedBox( + height: heightIn(context), + child: Card( + semanticContainer: true, + clipBehavior: Clip.antiAliasWithSaveLayer, + child: Container( + decoration: decoration, + child: body, + ), + ), + ); + } +} diff --git a/lib/news/feed.dart b/lib/news/feed.dart index 62aaea5..d4a27db 100644 --- a/lib/news/feed.dart +++ b/lib/news/feed.dart @@ -82,3 +82,43 @@ class HorizontalNewsFeed extends StatelessWidget { ); } } + + +class VerticalNewsFeed extends StatelessWidget { + final Feed newsFeed; + final String sportFilter; + + const VerticalNewsFeed({ + Key key, + @required this.newsFeed, + @required this.sportFilter, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + var page = newsFeed.getPage(1, size: 100).then((page) => page.where((article) => article.sport.toLowerCase().contains(sportFilter.toLowerCase())).toList()); + var size = MediaQuery.of(context).size; + return SizedBox( + height: size.height * (7/8), + child: FutureBuilder( + future: page, + builder: (ctx, snapshot) { + if (!snapshot.hasData) { + return Center(child: CircularProgressIndicator()); + } else { + List
articles = snapshot.data; + return ListView.builder( + //shrinkWrap: true, + scrollDirection: Axis.vertical, + itemCount: articles.length, + itemBuilder: (ctx, idx) { + return ArticleCardVert( + article: articles[idx], + ); + }, + ); + } + }, + )); + } +} diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index 5a1c3ec..c53c82a 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -69,9 +69,10 @@ class Sport extends StatelessWidget { ] ), body: ListView( + physics: const NeverScrollableScrollPhysics(), children: [ HorizontalGameCards(gameCard: gameCard, sportID: sport_ID,), - HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name), sportFilter: _curSport.name,), + VerticalNewsFeed(newsFeed: feed, sportFilter: _curSport.name), ], ), drawer: Drawer( @@ -131,7 +132,7 @@ class Sport extends StatelessWidget { setState(() { _curSport = value; _genderSwitcherCheck(); - print(sport_ID); + //print(sport_ID); }); }, items: colorList.map>((Item item) { @@ -155,7 +156,7 @@ class Sport extends StatelessWidget { genderSportSwitch = false; sport_ID = _curSport.sportID[0]; } - print(sport_ID); + //print(sport_ID); } } diff --git a/lib/screens/sport_schedule.dart b/lib/screens/sport_schedule.dart index 47e5308..71a93a5 100644 --- a/lib/screens/sport_schedule.dart +++ b/lib/screens/sport_schedule.dart @@ -148,7 +148,7 @@ class GameCard extends StatelessWidget { fit: BoxFit.contain, child: Wrap( children: [ - if (gameCard.status == "null") // no game yet + if (gameCard.status == null) // no game yet Text( '${_months[gameCard.date.month]} ${gameCard.date.day}' ) @@ -165,10 +165,12 @@ class GameCard extends StatelessWidget { fit: BoxFit.contain, child: Wrap( children: [ - if (gameCard.status != "null") // no game yet + if (gameCard.status != null) // no game yet Text( '${_months[gameCard.date.month]} ${gameCard.date.day}', textAlign: TextAlign.center, - ), + ) + else + Text('${gameCard.date.hour}:${gameCard.date.minute} PM'), ], ) ), @@ -178,7 +180,7 @@ class GameCard extends StatelessWidget { gameCard.location_indicator, gameCard.image, false, ctx)), - onTap: () => print('${gameCard.status}'), + onTap: () => print('${gameCard.date} ${gameCard.status}'), ), ), ], diff --git a/pubspec.lock b/pubspec.lock index b39c496..76f0d96 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,21 +7,21 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "2.0.11" + version: "2.0.13" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted - version: "1.5.2" + version: "1.6.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" + version: "2.4.1" bloc: dependency: transitive description: @@ -35,21 +35,21 @@ packages: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "2.0.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.1.3" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" + version: "1.14.12" convert: dependency: transitive description: @@ -63,7 +63,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.1.4" cupertino_icons: dependency: "direct main" description: @@ -113,7 +113,7 @@ packages: name: image url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.12" intl: dependency: transitive description: @@ -176,7 +176,7 @@ packages: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.1.3" rxdart: dependency: transitive description: @@ -230,7 +230,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.7.0" stack_trace: dependency: transitive description: @@ -279,7 +279,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.11" + version: "0.2.15" typed_data: dependency: transitive description: @@ -300,7 +300,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "3.5.0" + version: "3.6.1" sdks: dart: ">=2.6.0 <3.0.0" flutter: ">=1.12.13+hotfix.4 <2.0.0" From c2d376b2b551730ec5f98453a717a3244f886d2d Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Rosario Date: Fri, 1 May 2020 13:59:06 -0400 Subject: [PATCH 27/27] GREEN --- lib/screens/sport.dart | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index c53c82a..cc28258 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -4,13 +4,13 @@ import '../models/game_cards.dart'; class Sport extends StatelessWidget { static final List colorList = [ - const Item('Football', Colors.green,[3]), - const Item("Basketball", Colors.green,[5,13]), - const Item("Soccer", Colors.green,[9,17]), - const Item('Baseball', Colors.green,[1]), - const Item('Softball', Colors.green,[12]), - const Item('Volleyball', Colors.green,[20]), - const Item('Tennis', Colors.green,[10,18]), + const Item('Football',[3]), + const Item("Basketball",[5,13]), + const Item("Soccer",[9,17]), + const Item('Baseball',[1]), + const Item('Softball',[12]), + const Item('Volleyball',[20]), + const Item('Tennis',[10,18]), ]; final feed = Feed(); // was var not final @@ -47,7 +47,7 @@ class Sport extends StatelessWidget { appBar: AppBar( centerTitle: false, title: buildDropdownButton(selectedSport, setState), - backgroundColor: _curSport.color, + backgroundColor: Colors.green, //--Gender Switch-- Need to make condition to determine gender actions: [ @@ -161,9 +161,7 @@ class Sport extends StatelessWidget { } class Item { - const Item(this.name, this.color, this.sportID); - + const Item(this.name, this.sportID); final String name; - final Color color; final List sportID; } \ No newline at end of file