From 8cf18dec0a35677483c6fa903dbe587792a3cdf7 Mon Sep 17 00:00:00 2001 From: kconnel7 Date: Wed, 22 Apr 2020 18:38:54 -0400 Subject: [PATCH 01/15] 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 02/15] 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 03/15] 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 04/15] 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 3a8397b89e2bc59cdd5ecb6b6399d2613e0e5905 Mon Sep 17 00:00:00 2001 From: clopezr1 Date: Thu, 23 Apr 2020 17:49:34 -0400 Subject: [PATCH 05/15] 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 06/15] 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 07/15] 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 08/15] 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 09/15] 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 10/15] 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 11/15] 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 12/15] 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 a21b86bf78f03891340f7d7c1964895c2555399a Mon Sep 17 00:00:00 2001 From: David Allemang Date: Thu, 30 Apr 2020 20:24:59 -0400 Subject: [PATCH 13/15] 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 14/15] 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 15/15] 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