Merge pull request #18 from allemangD/Standings

Standings
This commit is contained in:
clopezr1
2020-04-30 22:16:13 -04:00
committed by GitHub
12 changed files with 354 additions and 212 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 = (
);
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;

View File

@@ -20,17 +20,18 @@ Map<DateTime, List<sport_schedule>> _events;
class _Calendar extends State<Calendar> with TickerProviderStateMixin {
int sportID;
_Calendar(this. sportID);
_Calendar(this.sportID);
AnimationController _animationController;
CalendarController _calController;
static final sportUrl = 'https://charlotte49ers.com/services/adaptive_components.ashx?type=scoreboard&start=0&count=80';
Future<List<sport_schedule>> 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);
@@ -52,10 +53,8 @@ class _Calendar extends State<Calendar> 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]]);
}
}
@@ -206,15 +205,20 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
markersBuilder: (context, date, events, holidays) {
final miniBox = <Widget>[];
if (events.isNotEmpty) {
miniBox.add(
Positioned(
right: 1,
bottom: 1,
child: _buildEventsMarker(date, events),
right: 0,top: 0, left: 0, bottom: 0,
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;
@@ -233,27 +237,26 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
}
//----- 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(
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)
? Colors.blue[400]
: Color.fromRGBO(0, 112, 60, 1), //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,
@@ -261,7 +264,7 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
child: Center(
child: Text(
'${events.length}',
eventNum,
style: TextStyle().copyWith(
color: Colors.white,
fontSize: 12.0,
@@ -271,6 +274,20 @@ 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 -----
Widget _eventLister() {
return ListView(
@@ -290,7 +307,7 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
child: ListTile(
leading: Image.network(
'https://charlotte49ers.com' + event.image.toString(),
width: 50.0,
width: 35.0,
),
title: Wrap(
children: <Widget>[
@@ -322,7 +339,7 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
subtitle: Text(
event.sportTitle.toString() + " - " + event.location.toString(),
style: TextStyle(
fontSize: 10.3,
fontSize: 9.9, //10.3
),
),

View File

@@ -48,7 +48,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'));
@@ -65,6 +64,7 @@ class HorizontalNewsFeed extends StatelessWidget {
} else {
List<Article> articles = snapshot.data;
return ListView.builder(
//shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemCount: articles.length,
itemBuilder: (ctx, idx) {

View File

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

View File

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

View File

@@ -2,22 +2,21 @@ import 'package:flutter/material.dart';
import '../news/feed.dart';
class Sport extends StatelessWidget {
static final List<Item> colorList = <Item>[
const Item('Football', Colors.green,[3]),
const Item("Basketball", Colors.red,[5,13]),
const Item("Soccer", Colors.pinkAccent,[9,17]),
const Item('Baseball', Colors.orange,[1]),
const Item('Volleyball', Colors.blue,[0]),
const Item('Softball', Colors.yellow,[0]),
const Item('Tennis', Colors.yellowAccent,[0,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
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;
@@ -69,10 +68,7 @@ class Sport extends StatelessWidget {
),
body: ListView(
children: <Widget>[
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(
@@ -99,13 +95,13 @@ 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(
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],),
),
),
],
@@ -115,8 +111,7 @@ class Sport extends StatelessWidget {
);
}
DropdownButtonHideUnderline buildDropdownButton(
Item selectedSport, StateSetter setState) {
DropdownButtonHideUnderline buildDropdownButton(Item selectedSport, StateSetter setState) {
return DropdownButtonHideUnderline(
child: DropdownButton<Item>(
value: selectedSport,
@@ -159,8 +154,6 @@ class Sport extends StatelessWidget {
}
print(sport_ID);
}
}
class Item {

View File

@@ -1,171 +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;
Standing(List args)
: sport_id = args[0],
sport_name = args[1];
@override
Widget build(BuildContext context) {
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: <Widget>[
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,),
],
),
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"
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:

View File

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