Merge remote-tracking branch 'origin/master' into SportPageCards

# Conflicts:
#	lib/monthly_calendar.dart
#	lib/screens/sport.dart
This commit is contained in:
Carlos Lopez-Rosario
2020-05-01 02:48:20 -04:00
12 changed files with 461 additions and 278 deletions

90
ios/Podfile Normal file
View File

@@ -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

34
ios/Podfile.lock Normal file
View File

@@ -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

View File

@@ -213,14 +213,9 @@
files = ( files = (
); );
inputPaths = ( 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"; name = "[CP] Embed Pods Frameworks";
outputPaths = ( outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework",
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;

View File

@@ -20,17 +20,18 @@ Map<DateTime, List<sport_schedule>> _events;
class _Calendar extends State<Calendar> with TickerProviderStateMixin { class _Calendar extends State<Calendar> with TickerProviderStateMixin {
int sportID; int sportID;
_Calendar(this. sportID); _Calendar(this.sportID);
AnimationController _animationController; AnimationController _animationController;
CalendarController _calController; CalendarController _calController;
static final sportUrl = 'https://charlotte49ers.com/services/adaptive_components.ashx?type=scoreboard&start=0&count=80'; static final sportUrl = 'https://charlotte49ers.com/services/adaptive_components.ashx?type=scoreboard&start=0&count=80';
Future<List<sport_schedule>> getEvents() async { Future<List<sport_schedule>> getEvents() async {
var url = '$sportUrl&sport_id=$sportID&name=&extra=%7B%7D'; var url = '$sportUrl&sport_id=$sportID&name=&extra=%7B%7D';
print(url.toString());
http.Response response = await http.get(url); http.Response response = await http.get(url);
Iterable games = json.decode(response.body); Iterable games = json.decode(response.body);
@@ -52,10 +53,8 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
var original = mapGrab[sportEvent]; var original = mapGrab[sportEvent];
if (original == null) { if (original == null) {
//print("null");
mapGrab[sportEvent] = [eventInfo[i]]; mapGrab[sportEvent] = [eventInfo[i]];
} else { } else {
//print(eventInfo[i].date);
mapGrab[sportEvent] = List.from(original)..addAll([eventInfo[i]]); mapGrab[sportEvent] = List.from(original)..addAll([eventInfo[i]]);
} }
} }
@@ -115,7 +114,8 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
_buildCalendar(), _buildCalendar(),
_eventLister(), const SizedBox(height: 8.0),
Expanded(child: _eventLister()),
], ],
), ),
); );
@@ -205,15 +205,20 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
markersBuilder: (context, date, events, holidays) { markersBuilder: (context, date, events, holidays) {
final miniBox = <Widget>[]; final miniBox = <Widget>[];
if (events.isNotEmpty) { if (events.isNotEmpty) {
miniBox.add( miniBox.add(
Positioned( Positioned(
right: 1, right: 0,top: 0, left: 0, bottom: 0,
bottom: 1, child: _buildEventsMarker(date, events[0].location_indicator, true, events),
child: _buildEventsMarker(date, events),
), ),
); );
if (events.length > 1)
miniBox.add(
Positioned(
right: 1, bottom: 1,
child: _buildEventsMarker(date, events[0].location_indicator, false, events),
)
);
} }
return miniBox; return miniBox;
@@ -232,27 +237,26 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
} }
//----- Creates event box display (mini box) ----- //----- Creates event box display (mini box) -----
Widget _buildEventsMarker(DateTime date, List events) { Widget _buildEventsMarker(DateTime date, String gameType, bool main, events) {
String eventNum;
if (main) {eventNum = "${date.day}";} else {eventNum = "${events.length}";}
//return Container(
return AnimatedContainer( return AnimatedContainer(
duration: const Duration(milliseconds: 300), duration: const Duration(milliseconds: 300),
margin: const EdgeInsets.all(4.0),
alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.rectangle, /*border: Border.all(
color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green
/*border: _calController.isSelected(date) //if selected date //color: Colors.black,
? Border.all(color: Colors.black, width: 1.5,) ),*/
: _calController.isToday(date) //if today's date color: _calController.isSelected(date)
? Border.all(color: Colors.black, width: 1.5,) ? Color.fromRGBO(179, 163, 105, 1) //UNCC Gold
: Border.all(color: Colors.black, width: 0,),*/ : _gameTypeColor(gameType, main), //UNCC Green
borderRadius: BorderRadius.circular(10.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)
? Colors.blue[400]
: Color.fromRGBO(0, 112, 60, 1), //UNCC Green
//: Colors.grey,
), ),
width: 16.0, width: 16.0,
@@ -260,7 +264,7 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
child: Center( child: Center(
child: Text( child: Text(
'${events.length}', eventNum,
style: TextStyle().copyWith( style: TextStyle().copyWith(
color: Colors.white, color: Colors.white,
fontSize: 12.0, fontSize: 12.0,
@@ -270,80 +274,134 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
); );
} }
//Logic on if Home or Away return the colors
Color _gameTypeColor(String gameType, bool main){
Color c;
if (gameType == "H"){
c = Color.fromRGBO(0, 112, 60, 1); //UNCC Green
} else {
c = Colors.grey;
}
if (!main){
c = Colors.black45;//Color.fromRGBO(179, 163, 105, 1);
}
return c;
}
//----- Creates event display ----- //----- 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() { Widget _eventLister() {
var _months = {1:'JAN', 2:'FEB', 3:'MAR', 4:'APR', 5:'MAY', 6:'JUN', return ListView(
7:'JUL', 8:'AUG', 9:'SEP', 10:'OCT', 11:'NOV', 12:'DEC'}; children: _selectedEvents.map((event) => Container(
return SizedBox( decoration: BoxDecoration(
height: 78, border: Border.all(
child: Column( color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green
children: _selectedEvents width: 0.8,
.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: <Widget>[
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 borderRadius: BorderRadius.circular(12.0),
subtitle: Wrap(children: <Widget>[ ),
//Should be either live time or time game will be, nothing for past games
]),
trailing: _homeAwayImageOrder( height: 70.0,
event.location_indicator.toString(), margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
event.image.toString(), false),
onTap: () => child: ListTile(
print('${event.date}'), //When event display is clicked leading: Image.network(
'https://charlotte49ers.com' + event.image.toString(),
width: 35.0,
), ),
)) title: Wrap(
.toList(), children: <Widget>[
), 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: 9.9, //10.3
),
),
trailing: Wrap(
//mainAxisSize: MainAxisSize.min,
children: <Widget>[
//---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,
)
),
],
),
onTap: () => print('$event tapped!'), //When event display is clicked
),
)).toList(),
); );
} }
} }

View File

@@ -48,7 +48,6 @@ class HorizontalNewsFeed extends StatelessWidget {
icon: Icon(Icons.navigate_next), icon: Icon(Icons.navigate_next),
onPressed: () => Navigator.of(context).pushNamed('/Sport', arguments: title.data), onPressed: () => Navigator.of(context).pushNamed('/Sport', arguments: title.data),
/*onPressed: () { //changed /*onPressed: () { //changed
Navigator.of(context).pushNamed('/Sport'); Navigator.of(context).pushNamed('/Sport');
print(Navigator.of(context).pushNamed('/Sport')); print(Navigator.of(context).pushNamed('/Sport'));
@@ -65,6 +64,7 @@ class HorizontalNewsFeed extends StatelessWidget {
} else { } else {
List<Article> articles = snapshot.data; List<Article> articles = snapshot.data;
return ListView.builder( return ListView.builder(
//shrinkWrap: true,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: articles.length, itemCount: articles.length,
itemBuilder: (ctx, idx) { itemBuilder: (ctx, idx) {

View File

@@ -23,7 +23,7 @@ class RouteGenerator {
case '/Schedule': case '/Schedule':
return MaterialPageRoute(builder: (_) => Schedule(args)); return MaterialPageRoute(builder: (_) => Schedule(args));
case '/Standing': case '/Standing':
return MaterialPageRoute(builder: (_) => Standing()); return MaterialPageRoute(builder: (_) => Standing(args));
case '/Chat': case '/Chat':
return MaterialPageRoute(builder: (_) => Chat()); return MaterialPageRoute(builder: (_) => Chat());
case '/Details': case '/Details':

View File

@@ -3,17 +3,17 @@ import '../monthly_calendar.dart';
import '../screens/sport.dart' as globals; import '../screens/sport.dart' as globals;
class Schedule extends StatelessWidget{ class Schedule extends StatelessWidget{
final int sportID; final List sport;
Schedule(this.sportID); Schedule(this.sport);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var calendar = Calendar(sportID); var calendar = Calendar(sport[0]);
return StatefulBuilder( return StatefulBuilder(
builder: (context, StateSetter setState) => Scaffold( builder: (context, StateSetter setState) => Scaffold(
appBar: AppBar( appBar: AppBar(
centerTitle: false, centerTitle: false,
title: Text("49ers"), title: Text("${sport[1]}"),
backgroundColor: Colors.green, backgroundColor: Colors.green,
), ),
body: Container ( body: Container (

View File

@@ -2,22 +2,21 @@ import 'package:flutter/material.dart';
import '../news/feed.dart'; import '../news/feed.dart';
class Sport extends StatelessWidget { class Sport extends StatelessWidget {
static final List<Item> colorList = <Item>[ static final List<Item> colorList = <Item>[
const Item('Football', Colors.green,[3]), const Item('Football', Colors.green,[3]),
const Item("Basketball", Colors.red,[5,13]), const Item("Basketball", Colors.red,[5,13]),
const Item("Soccer", Colors.pinkAccent,[9,17]), const Item("Soccer", Colors.pinkAccent,[9,17]),
const Item('Baseball', Colors.orange,[1]), const Item('Baseball', Colors.orange,[1]),
const Item('Volleyball', Colors.blue,[0]), const Item('Softball', Colors.yellow,[12]),
const Item('Softball', Colors.yellow,[0]), const Item('Volleyball', Colors.blue,[20]),
const Item('Tennis', Colors.yellowAccent,[0,0]), const Item('Tennis', Colors.yellowAccent,[10,18]),
]; ];
final feed = Feed(); // was var not final final feed = Feed(); // was var not final
bool genderSportSwitch = false; //determines if sport needs the gender switch
final String imageMale = 'images/male.png'; final String imageMale = 'images/male.png';
final String imageFemale = 'images/female.png'; final String imageFemale = 'images/female.png';
static bool genderSportSwitch = false; //determines if sport needs the gender switch
static bool genderSport = false; //determines which gender switch is set M - false / F - True static bool genderSport = false; //determines which gender switch is set M - false / F - True
static int sport_ID; static int sport_ID;
final String sport; final String sport;
@@ -70,9 +69,6 @@ class Sport extends StatelessWidget {
body: ListView( body: ListView(
children: <Widget>[ children: <Widget>[
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name), 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),
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name), sportFilter: _curSport.name),
], ],
), ),
drawer: Drawer( drawer: Drawer(
@@ -99,13 +95,13 @@ class Sport extends StatelessWidget {
ListTile( ListTile(
title: IconButton( title: IconButton(
icon: Icon(Icons.table_chart), icon: Icon(Icons.table_chart),
onPressed: () => Navigator.pushNamed(context, '/Standing', arguments: sport_ID), onPressed: () => Navigator.pushNamed(context, '/Standing', arguments: [sport_ID, _curSport.name]),
), ),
), ),
ListTile( ListTile(
title: IconButton( title: IconButton(
icon: Icon(Icons.calendar_today), icon: Icon(Icons.calendar_today),
onPressed: () => Navigator.pushNamed(context, '/Schedule',arguments: sport_ID), onPressed: () => Navigator.pushNamed(context, '/Schedule',arguments: [sport_ID, _curSport.name],),
), ),
), ),
], ],
@@ -115,8 +111,7 @@ class Sport extends StatelessWidget {
); );
} }
DropdownButtonHideUnderline buildDropdownButton( DropdownButtonHideUnderline buildDropdownButton(Item selectedSport, StateSetter setState) {
Item selectedSport, StateSetter setState) {
return DropdownButtonHideUnderline( return DropdownButtonHideUnderline(
child: DropdownButton<Item>( child: DropdownButton<Item>(
value: selectedSport, value: selectedSport,
@@ -159,8 +154,6 @@ class Sport extends StatelessWidget {
} }
print(sport_ID); print(sport_ID);
} }
} }
class Item { class Item {

View File

@@ -1,171 +1,54 @@
import 'package:capstone_hungry_hippos/models/School.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../team_standings.dart';
class Standing extends StatelessWidget { class Standing extends StatelessWidget {
final _schools = [ final int sport_id;
School("North Texas Mean Green",AssetImage('assets/school_logos/NorthTexas.png'), 14, 4), final String sport_name;
School("Louisiana Tech Bulldogs",AssetImage('assets/school_logos/LT.png'), 13, 5),
School("Western Kentucky Hilltoppers",AssetImage('assets/school_logos/wku.png'), 13, 5), Standing(List args)
School("Charlotte 49ers",AssetImage('assets/school_logos/uncc.png'), 10, 8), : sport_id = args[0],
School("Marshall Thundering Herd",AssetImage('assets/school_logos/Marshall.png'), 10, 8), sport_name = args[1];
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),
];
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return StatefulBuilder(
appBar: AppBar( builder: (context, StateSetter setState) => Scaffold(
centerTitle: false, appBar: AppBar(
title: Text("49ers"), centerTitle: false,
backgroundColor: Colors.green, title: Text("$sport_name Standings"),
), backgroundColor: Colors.green,
body: SingleChildScrollView( ),
child: Column( body: ListView(
children: <Widget>[ children: <Widget>[
Container( HorizontalStandings(sportName: sport_name,),
child: Text(
"W L",
style: TextStyle(fontWeight: FontWeight.bold),
),
alignment: Alignment(.85, 0),
height: 20,
color: Colors.grey,
),
SportLine(
s: _schools[0],
position: 1,
),
SportLine(
s: _schools[1],
position: 2,
),
SportLine(
s: _schools[2],
position: 3,
),
SportLine(
s: _schools[3],
position: 4,
),
SportLine(
s: _schools[4],
position: 5,
),
SportLine(
s: _schools[5],
position: 6,
),
SportLine(
s: _schools[6],
position: 7,
),
SportLine(
s: _schools[7],
position: 8,
),
SportLine(
s: _schools[8],
position: 9,
),
SportLine(
s: _schools[9],
position: 10,
),
SportLine(
s: _schools[10],
position: 11,
),
SportLine(
s: _schools[11],
position: 12,
),SportLine(
s: _schools[12],
position: 13,
),SportLine(
s: _schools[13],
position: 14,
),
], ],
), ),
drawer: Drawer(
child: ListView(
children: <Widget>[
DrawerHeader(
child: Text(
'Drawer Header',
style: TextStyle(
color: Colors.white,
fontSize: 24,
),
),
decoration: BoxDecoration(
color: Colors.green,
),
),
ListTile(
title: IconButton(
icon: Icon(Icons.home),
onPressed: () => Navigator.pushNamed(context, '/'),
),
),
],
),
),
), ),
); );
} }
} }
class SportLine extends StatelessWidget {
const SportLine({
Key key,
@required
this.position,
this.s
}) : super(key: key);
final School s;
final int position;
@override
Widget build(BuildContext context) {
int w = s.win;
int l = s.loss;
return Container(
color: evenOdd(position),
height: 60,
child: Row(
children: <Widget>[
Container(
height: 55,
width: 20,
//color: Colors.orange,
child: Center(
child: Text(
"$position",
style: TextStyle(fontWeight: FontWeight.bold),
)),
),
Container(
//color: Colors.blue,
width: 55,
child: Image(
image: s.logo,
),
),
Container(
width: 5,
//color: Colors.red,
),
Container(
//color: Colors.pinkAccent,
width: 220,
child: Text(s.name),
),
Container(
//color: Colors.orange,
width: 35,
child: Text(
"$w",
style: TextStyle(fontWeight: FontWeight.bold),
)),
Container(
//color: Colors.blue,
width: 35,
child: Text(
" $l",
style: TextStyle(fontWeight: FontWeight.bold),
))
],
)
);
}
Color evenOdd(int i) {
Color c = i % 2 == 0 ? Colors.black12 : Colors.white30;
return c;
}
}

122
lib/team_standings.dart Normal file
View File

@@ -0,0 +1,122 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'screens/sport.dart';
class HorizontalStandings extends StatelessWidget {
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",
],
};
final String sportName;
const HorizontalStandings({Key key, this.sportName}) : super(key: key);
Future<Widget> getStandingsTable(String url) async {
var response = await http.get(url);
var body = json.decode(response.body);
if (body['children'].length == 0) body['children'] = [body];
var res = Center(
child: Column(
children: <Widget>[
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<Widget>()
.toList();
row.insert(0, Text(team['team']['name']));
row.insert(
0,
Image.network(team['team']['logos'][0]['href'],
height: 40));
return TableRow(children: row);
})
.cast<TableRow>()
.toList(),
);
return Column(
children: <Widget>[
Text(
conference['shortName'],
style: TextStyle(fontSize: 16),
),
table,
],
);
})
.cast<Widget>()
.toList()),
],
),
);
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: <Widget>[
FutureBuilder<Widget>(
future: getStandingsTable(url),
builder: (context, snapshot) {
if (snapshot.hasError) return Text(snapshot.error.toString());
if (!snapshot.hasData) return CircularProgressIndicator();
return snapshot.data;
},
)
],
),
);
}
}

View File

@@ -259,6 +259,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.2.3" version: "2.2.3"
table_sticky_headers:
dependency: "direct main"
description:
name: table_sticky_headers
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:

View File

@@ -29,6 +29,7 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2 cupertino_icons: ^0.1.2
table_calendar: table_calendar:
table_sticky_headers:
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: