Merge remote-tracking branch 'origin/master' into game_details_buttons
This commit is contained in:
BIN
assets/school_logos/UNC-Charlotte (1).png
Normal file
BIN
assets/school_logos/UNC-Charlotte (1).png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.9 KiB |
90
ios/Podfile
Normal file
90
ios/Podfile
Normal 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
34
ios/Podfile.lock
Normal 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
|
||||||
97
lib/models/game_cards.dart
Normal file
97
lib/models/game_cards.dart
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
|
import '../screens/sport_schedule.dart';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
class GameCardFeed{
|
||||||
|
|
||||||
|
static final sportUrl =
|
||||||
|
'https://charlotte49ers.com/services/adaptive_components.ashx?type=scoreboard&start=0&count=80';
|
||||||
|
Future<List<sport_schedule>> getEvents(int sportID) async {
|
||||||
|
var url = '$sportUrl&sport_id=$sportID&name=&extra=%7B%7D';
|
||||||
|
http.Response response = await http.get(url);
|
||||||
|
Iterable games = json.decode(response.body);
|
||||||
|
return games
|
||||||
|
.map<sport_schedule>((json) => sport_schedule.fromJson(json))
|
||||||
|
.toList();
|
||||||
|
//return games.map((e) => sport_schedule.fromJson(e)).toList();
|
||||||
|
}
|
||||||
|
Future<List<ScheduleObject>> getGames(int sportID) async {
|
||||||
|
Map<DateTime, List<sport_schedule>> mapGrab = {};
|
||||||
|
|
||||||
|
List<sport_schedule> eventInfo = await getEvents(sportID);
|
||||||
|
|
||||||
|
for (int i = 0; i < eventInfo.length; i++) {
|
||||||
|
var sportEvent = DateTime(eventInfo[i].date.year, eventInfo[i].date.month,
|
||||||
|
eventInfo[i].date.day);
|
||||||
|
var original = mapGrab[sportEvent];
|
||||||
|
|
||||||
|
if (original == null) {
|
||||||
|
//print("null");
|
||||||
|
mapGrab[sportEvent] = [eventInfo[i]];
|
||||||
|
} else {
|
||||||
|
//print(eventInfo[i].date);
|
||||||
|
mapGrab[sportEvent] = List.from(original)
|
||||||
|
..addAll([eventInfo[i]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<ScheduleObject> list = [];
|
||||||
|
mapGrab.forEach((k, v) => list.add(ScheduleObject(k, v)));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class HorizontalGameCards extends StatelessWidget {
|
||||||
|
final GameCardFeed gameCard;
|
||||||
|
final double numCards;
|
||||||
|
final int sportID;
|
||||||
|
|
||||||
|
const HorizontalGameCards({
|
||||||
|
Key key,
|
||||||
|
@required this.gameCard,
|
||||||
|
this.numCards = 8,
|
||||||
|
this.sportID,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
double heightIn(BuildContext context) {
|
||||||
|
return MediaQuery.of(context).size.height / numCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
var card = gameCard.getGames(sportID);
|
||||||
|
var events = [];
|
||||||
|
return SizedBox(
|
||||||
|
height: heightIn(context),
|
||||||
|
child: FutureBuilder(
|
||||||
|
future: card,
|
||||||
|
// ignore: missing_return
|
||||||
|
builder: (ctx, snapshot) {
|
||||||
|
//print(snapshot);
|
||||||
|
if (!snapshot.hasData) {
|
||||||
|
return Center(child: CircularProgressIndicator());
|
||||||
|
} else {
|
||||||
|
events = snapshot.data;
|
||||||
|
|
||||||
|
return ListView.builder(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: events.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return GameCard(
|
||||||
|
gameCard: events[index].sportSched[0],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ScheduleObject {
|
||||||
|
DateTime d;
|
||||||
|
List<sport_schedule> sportSched;
|
||||||
|
ScheduleObject(this.d, this.sportSched);
|
||||||
|
}
|
||||||
@@ -3,12 +3,14 @@ import 'package:http/http.dart' as http;
|
|||||||
import 'package:table_calendar/table_calendar.dart';
|
import 'package:table_calendar/table_calendar.dart';
|
||||||
|
|
||||||
import 'screens/sport_schedule.dart';
|
import 'screens/sport_schedule.dart';
|
||||||
import 'screens/sport.dart' as globals;
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class Calendar extends StatefulWidget {
|
class Calendar extends StatefulWidget {
|
||||||
|
final int sportID;
|
||||||
|
Calendar(this.sportID);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_Calendar createState() => _Calendar();
|
_Calendar createState() => _Calendar(sportID);
|
||||||
}
|
}
|
||||||
|
|
||||||
//List<sport_schedule> _selectedEvents; //original that makes events work
|
//List<sport_schedule> _selectedEvents; //original that makes events work
|
||||||
@@ -17,15 +19,19 @@ DateTime selectedDay;
|
|||||||
Map<DateTime, List<sport_schedule>> _events;
|
Map<DateTime, List<sport_schedule>> _events;
|
||||||
|
|
||||||
class _Calendar extends State<Calendar> with TickerProviderStateMixin {
|
class _Calendar extends State<Calendar> with TickerProviderStateMixin {
|
||||||
|
int sportID;
|
||||||
|
_Calendar(this.sportID);
|
||||||
|
|
||||||
AnimationController _animationController;
|
AnimationController _animationController;
|
||||||
CalendarController _calController;
|
CalendarController _calController;
|
||||||
|
|
||||||
int sportID = globals.Sport.sport_ID;
|
|
||||||
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);
|
||||||
|
|
||||||
@@ -47,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]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,7 +63,7 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
final _selectedDay = DateTime.now();
|
//final _selectedDay = DateTime.now();
|
||||||
|
|
||||||
//_selectedEvents = _events[_selectedDay] ?? [];
|
//_selectedEvents = _events[_selectedDay] ?? [];
|
||||||
_selectedEvents = [];
|
_selectedEvents = [];
|
||||||
@@ -201,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;
|
||||||
@@ -228,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,
|
||||||
@@ -256,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,
|
||||||
@@ -266,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 -----
|
//----- Creates event display -----
|
||||||
Widget _eventLister() {
|
Widget _eventLister() {
|
||||||
return ListView(
|
return ListView(
|
||||||
@@ -285,7 +307,7 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
|
|||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: Image.network(
|
leading: Image.network(
|
||||||
'https://charlotte49ers.com' + event.image.toString(),
|
'https://charlotte49ers.com' + event.image.toString(),
|
||||||
width: 50.0,
|
width: 35.0,
|
||||||
),
|
),
|
||||||
title: Wrap(
|
title: Wrap(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@@ -317,7 +339,7 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
|
|||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
event.sportTitle.toString() + " - " + event.location.toString(),
|
event.sportTitle.toString() + " - " + event.location.toString(),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 10.3,
|
fontSize: 9.9, //10.3
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|||||||
@@ -90,3 +90,59 @@ class ArticleCard extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ArticleCardVert extends StatelessWidget {
|
||||||
|
const ArticleCardVert({
|
||||||
|
Key key,
|
||||||
|
@required this.article,
|
||||||
|
this.numCards = 2.1,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final Article article;
|
||||||
|
final double numCards;
|
||||||
|
|
||||||
|
double heightIn(BuildContext context) {
|
||||||
|
return (MediaQuery.of(context).size.height * 7/8) / numCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
var decoration = BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: NetworkImage(
|
||||||
|
article.thumbUrl,
|
||||||
|
),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
var body = Column(
|
||||||
|
verticalDirection: VerticalDirection.up,
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
color: Colors.white,
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(
|
||||||
|
article.mediumHeadline,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
maxLines: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
return SizedBox(
|
||||||
|
height: heightIn(context),
|
||||||
|
child: Card(
|
||||||
|
semanticContainer: true,
|
||||||
|
clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||||
|
child: Container(
|
||||||
|
decoration: decoration,
|
||||||
|
child: body,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,22 +18,25 @@ class Feed {
|
|||||||
|
|
||||||
class HorizontalNewsFeed extends StatelessWidget {
|
class HorizontalNewsFeed extends StatelessWidget {
|
||||||
final Feed newsFeed;
|
final Feed newsFeed;
|
||||||
final Widget title;
|
final Text title;
|
||||||
final double numCards;
|
final double numCards;
|
||||||
|
final String sportFilter;
|
||||||
|
|
||||||
const HorizontalNewsFeed({
|
const HorizontalNewsFeed({
|
||||||
Key key,
|
Key key,
|
||||||
@required this.newsFeed,
|
@required this.newsFeed,
|
||||||
@required this.title,
|
@required this.title,
|
||||||
|
@required this.sportFilter,
|
||||||
this.numCards = 3.25,
|
this.numCards = 3.25,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
double heightIn(BuildContext context) {
|
double heightIn(BuildContext context) {
|
||||||
return MediaQuery.of(context).size.height / numCards;
|
return MediaQuery.of(context).size.height / numCards;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
var page = newsFeed.getPage(1, size: 100).then((page) => page.where((article) => article.sport.toLowerCase().contains(sportFilter.toLowerCase())).toList());
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: heightIn(context),
|
height: heightIn(context),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -43,8 +46,7 @@ class HorizontalNewsFeed extends StatelessWidget {
|
|||||||
title: title,
|
title: title,
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
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'),
|
|
||||||
|
|
||||||
/*onPressed: () { //changed
|
/*onPressed: () { //changed
|
||||||
Navigator.of(context).pushNamed('/Sport');
|
Navigator.of(context).pushNamed('/Sport');
|
||||||
@@ -55,13 +57,14 @@ class HorizontalNewsFeed extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: FutureBuilder(
|
child: FutureBuilder(
|
||||||
future: newsFeed.getPage(1),
|
future: page,
|
||||||
builder: (ctx, snapshot) {
|
builder: (ctx, snapshot) {
|
||||||
if (!snapshot.hasData) {
|
if (!snapshot.hasData) {
|
||||||
return Center(child: CircularProgressIndicator());
|
return Center(child: CircularProgressIndicator());
|
||||||
} 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) {
|
||||||
@@ -79,3 +82,43 @@ class HorizontalNewsFeed extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class VerticalNewsFeed extends StatelessWidget {
|
||||||
|
final Feed newsFeed;
|
||||||
|
final String sportFilter;
|
||||||
|
|
||||||
|
const VerticalNewsFeed({
|
||||||
|
Key key,
|
||||||
|
@required this.newsFeed,
|
||||||
|
@required this.sportFilter,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
var page = newsFeed.getPage(1, size: 100).then((page) => page.where((article) => article.sport.toLowerCase().contains(sportFilter.toLowerCase())).toList());
|
||||||
|
var size = MediaQuery.of(context).size;
|
||||||
|
return SizedBox(
|
||||||
|
height: size.height * (7/8),
|
||||||
|
child: FutureBuilder(
|
||||||
|
future: page,
|
||||||
|
builder: (ctx, snapshot) {
|
||||||
|
if (!snapshot.hasData) {
|
||||||
|
return Center(child: CircularProgressIndicator());
|
||||||
|
} else {
|
||||||
|
List<Article> articles = snapshot.data;
|
||||||
|
return ListView.builder(
|
||||||
|
//shrinkWrap: true,
|
||||||
|
scrollDirection: Axis.vertical,
|
||||||
|
itemCount: articles.length,
|
||||||
|
itemBuilder: (ctx, idx) {
|
||||||
|
return ArticleCardVert(
|
||||||
|
article: articles[idx],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,17 +12,17 @@ class RouteGenerator {
|
|||||||
static Route<dynamic> generateRoute(RouteSettings settings) {
|
static Route<dynamic> generateRoute(RouteSettings settings) {
|
||||||
final args = settings
|
final args = settings
|
||||||
.arguments; //This is how we pass arguments and can be used in case
|
.arguments; //This is how we pass arguments and can be used in case
|
||||||
|
print("args $args");
|
||||||
switch (settings.name) {
|
switch (settings.name) {
|
||||||
case '/':
|
case '/':
|
||||||
return MaterialPageRoute(builder: (_) => Home());
|
return MaterialPageRoute(builder: (_) => Home());
|
||||||
case '/Sport':
|
case '/Sport':
|
||||||
//We can put logic and stuff here for checking if logged in
|
//We can put logic and stuff here for checking if logged in
|
||||||
return MaterialPageRoute(builder: (_) => Sport());
|
return MaterialPageRoute(builder: (_) => Sport(args));
|
||||||
case '/Schedule':
|
case '/Schedule':
|
||||||
return MaterialPageRoute(builder: (_) => Schedule());
|
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':
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ class Favorites {
|
|||||||
'Basketball',
|
'Basketball',
|
||||||
'Baseball',
|
'Baseball',
|
||||||
'Soccer',
|
'Soccer',
|
||||||
'Tennis',
|
|
||||||
'Volleyball'
|
'Volleyball'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ Future<List<HorizontalNewsFeed>> _buildList() async {
|
|||||||
return HorizontalNewsFeed(
|
return HorizontalNewsFeed(
|
||||||
newsFeed: feed,
|
newsFeed: feed,
|
||||||
title: Text(sport),
|
title: Text(sport),
|
||||||
|
sportFilter: sport,
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../monthly_calendar.dart';
|
import '../monthly_calendar.dart';
|
||||||
|
import '../screens/sport.dart' as globals;
|
||||||
class Schedule extends StatelessWidget{
|
class Schedule extends StatelessWidget{
|
||||||
|
|
||||||
final calendar = Calendar();
|
final List sport;
|
||||||
|
Schedule(this.sport);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
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 (
|
||||||
|
|||||||
@@ -1,53 +1,63 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../news/feed.dart';
|
import '../news/feed.dart';
|
||||||
|
import '../models/game_cards.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),
|
const Item('Football',[3]),
|
||||||
const Item("BasketBall", Colors.red),
|
const Item("Basketball",[5,13]),
|
||||||
const Item("Soccer", Colors.pinkAccent),
|
const Item("Soccer",[9,17]),
|
||||||
const Item('Baseball', Colors.orange),
|
const Item('Baseball',[1]),
|
||||||
|
const Item('Softball',[12]),
|
||||||
|
const Item('Volleyball',[20]),
|
||||||
|
const Item('Tennis',[10,18]),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
final feed = Feed(); // was var not final
|
||||||
|
final gameCard = GameCardFeed();
|
||||||
|
|
||||||
|
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;
|
||||||
|
Sport(this.sport);
|
||||||
|
|
||||||
Item _curSport = colorList[0];
|
Item _curSport = colorList[0];
|
||||||
|
|
||||||
final feed = Feed(); // was var not final
|
|
||||||
|
|
||||||
bool genderSportSwitch = false; //determines if sport needs the gender switch
|
|
||||||
final String imageMale = 'images/male.png';
|
|
||||||
final String imageFemale = 'images/female.png';
|
|
||||||
static bool genderSport = false; //determines which gender switch is set M - false / F - True
|
|
||||||
|
|
||||||
static int sport_ID;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Item _setDefault(){
|
||||||
|
Item _curSport;
|
||||||
|
for (Item i in colorList){
|
||||||
|
if (i.name == sport){
|
||||||
|
_curSport = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _curSport;
|
||||||
|
}
|
||||||
|
_curSport = _setDefault();
|
||||||
|
sport_ID = _curSport.sportID[0];
|
||||||
Item selectedSport;
|
Item selectedSport;
|
||||||
|
_genderSwitcherCheck();
|
||||||
return StatefulBuilder(
|
return StatefulBuilder(
|
||||||
builder: (context, StateSetter setState) => Scaffold(
|
builder: (context, StateSetter setState) => Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
title: buildDropdownButton(selectedSport, setState),
|
title: buildDropdownButton(selectedSport, setState),
|
||||||
backgroundColor: _curSport.color,
|
backgroundColor: Colors.green,
|
||||||
|
|
||||||
//--Gender Switch-- Need to make condition to determine gender
|
//--Gender Switch-- Need to make condition to determine gender
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
if (genderSportSwitch == true)
|
if (genderSportSwitch)
|
||||||
Switch(
|
Switch(
|
||||||
value: genderSport,
|
value: genderSport,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (value == false) {
|
genderSport = value;
|
||||||
genderSport = false;
|
_genderSwitcherCheck();
|
||||||
}
|
|
||||||
else {
|
|
||||||
genderSport = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
print("value: " + value.toString());
|
|
||||||
print("gender: " + genderSport.toString());
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
inactiveThumbColor: Colors.lightBlue,
|
inactiveThumbColor: Colors.lightBlue,
|
||||||
@@ -59,11 +69,10 @@ class Sport extends StatelessWidget {
|
|||||||
]
|
]
|
||||||
),
|
),
|
||||||
body: ListView(
|
body: ListView(
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name)),
|
HorizontalGameCards(gameCard: gameCard, sportID: sport_ID,),
|
||||||
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name)),
|
VerticalNewsFeed(newsFeed: feed, sportFilter: _curSport.name),
|
||||||
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name)),
|
|
||||||
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name)),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
drawer: Drawer(
|
drawer: Drawer(
|
||||||
@@ -90,13 +99,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'),
|
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'),
|
onPressed: () => Navigator.pushNamed(context, '/Schedule',arguments: [sport_ID, _curSport.name],),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -106,8 +115,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,
|
||||||
@@ -123,45 +131,8 @@ class Sport extends StatelessWidget {
|
|||||||
onChanged: (Item value) {
|
onChanged: (Item value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_curSport = value;
|
_curSport = value;
|
||||||
|
_genderSwitcherCheck();
|
||||||
print("genderSport: " + genderSport.toString());
|
//print(sport_ID);
|
||||||
|
|
||||||
//Will set the sport id / Display gender switch
|
|
||||||
switch (_curSport.name) { //prints are temp
|
|
||||||
case 'FootBall':
|
|
||||||
genderSportSwitch = false;
|
|
||||||
sport_ID = 3;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'BasketBall':
|
|
||||||
genderSportSwitch = true;
|
|
||||||
|
|
||||||
if (genderSport == false) {
|
|
||||||
sport_ID = 5; //Male
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sport_ID = 13; //Female
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'Soccer':
|
|
||||||
genderSportSwitch = true;
|
|
||||||
|
|
||||||
if (genderSport == false) {
|
|
||||||
sport_ID = 9; //Male
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sport_ID = 17; //Female
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'Baseball':
|
|
||||||
genderSportSwitch = false;
|
|
||||||
|
|
||||||
sport_ID = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
print(sport_ID);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
items: colorList.map<DropdownMenuItem<Item>>((Item item) {
|
items: colorList.map<DropdownMenuItem<Item>>((Item item) {
|
||||||
@@ -176,11 +147,21 @@ class Sport extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _genderSwitcherCheck() {
|
||||||
|
if (_curSport.name == "Soccer" || _curSport.name == "Basketball" || _curSport.name == "Tennis" ){
|
||||||
|
genderSportSwitch = true;
|
||||||
|
sport_ID = genderSport ? _curSport.sportID[1] : _curSport.sportID[0];
|
||||||
|
} else {
|
||||||
|
genderSportSwitch = false;
|
||||||
|
sport_ID = _curSport.sportID[0];
|
||||||
|
}
|
||||||
|
//print(sport_ID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Item {
|
class Item {
|
||||||
const Item(this.name, this.color);
|
const Item(this.name, this.sportID);
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
final Color color;
|
final List<int> sportID;
|
||||||
}
|
}
|
||||||
@@ -62,3 +62,141 @@ class sport_schedule {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class GameCard extends StatelessWidget {
|
||||||
|
const GameCard({
|
||||||
|
Key key,
|
||||||
|
@required this.gameCard,
|
||||||
|
this.numCards = 2.25,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final sport_schedule gameCard;
|
||||||
|
final double numCards;
|
||||||
|
|
||||||
|
double widthIn(BuildContext context) {
|
||||||
|
return MediaQuery.of(context).size.width / numCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
Text _pastGameScore(
|
||||||
|
String homeAway, String winLoss, String uncc, String opponent) {
|
||||||
|
if (homeAway == "H" || homeAway == "T") {
|
||||||
|
return (Text('$uncc - $opponent'));
|
||||||
|
} else {
|
||||||
|
return (Text('$opponent - $uncc'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Image _homeAwayImageOrder(String h, String opposingTeam, bool l, BuildContext ctx) {
|
||||||
|
if ((h == "H") == l) {
|
||||||
|
return (Image.network(
|
||||||
|
'https://fiusports.com/images/logos/UNC-Charlotte.png?width=80&height=80&mode=max',
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
return (Image.network(
|
||||||
|
'https://charlotte49ers.com' + opposingTeam,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Color winLoss(String wl){
|
||||||
|
if (wl == "W") {
|
||||||
|
return Colors.green;
|
||||||
|
} else if (wl == "L") {
|
||||||
|
return Colors.red;
|
||||||
|
} else {
|
||||||
|
return Colors.grey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext ctx) {
|
||||||
|
var _months = {
|
||||||
|
1: 'JAN',
|
||||||
|
2: 'FEB',
|
||||||
|
3: 'MAR',
|
||||||
|
4: 'APR',
|
||||||
|
5: 'MAY',
|
||||||
|
6: 'JUN',
|
||||||
|
7: 'JUL',
|
||||||
|
8: 'AUG',
|
||||||
|
9: 'SEP',
|
||||||
|
10: 'OCT',
|
||||||
|
11: 'NOV',
|
||||||
|
12: 'DEC'
|
||||||
|
};
|
||||||
|
var decoration = BoxDecoration(
|
||||||
|
border: Border.all(
|
||||||
|
color: winLoss(gameCard.status), //UNCC Green
|
||||||
|
width: 1.2,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(2),
|
||||||
|
);
|
||||||
|
var logoWidth = 4.5;
|
||||||
|
var body = Column(
|
||||||
|
verticalDirection: VerticalDirection.up,
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
color: Colors.white,
|
||||||
|
child: ListTile(
|
||||||
|
leading: SizedBox(
|
||||||
|
width: widthIn(ctx)/logoWidth,
|
||||||
|
child: _homeAwayImageOrder(
|
||||||
|
gameCard.location_indicator,
|
||||||
|
gameCard.image,
|
||||||
|
true, ctx)),
|
||||||
|
title: FittedBox(
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
child: Wrap(
|
||||||
|
children: <Widget>[
|
||||||
|
if (gameCard.status == null) // no game yet
|
||||||
|
Text(
|
||||||
|
'${_months[gameCard.date.month]} ${gameCard.date.day}'
|
||||||
|
)
|
||||||
|
else
|
||||||
|
_pastGameScore(
|
||||||
|
gameCard.location_indicator,
|
||||||
|
gameCard.status,
|
||||||
|
gameCard.team_score,
|
||||||
|
gameCard.opponent_score,),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
),
|
||||||
|
subtitle: FittedBox(
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
child: Wrap(
|
||||||
|
children: <Widget>[
|
||||||
|
if (gameCard.status != null) // no game yet
|
||||||
|
Text(
|
||||||
|
'${_months[gameCard.date.month]} ${gameCard.date.day}', textAlign: TextAlign.center,
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Text('${gameCard.date.hour}:${gameCard.date.minute} PM'),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
),
|
||||||
|
trailing: SizedBox(
|
||||||
|
width: widthIn(ctx)/logoWidth,
|
||||||
|
child: _homeAwayImageOrder(
|
||||||
|
gameCard.location_indicator,
|
||||||
|
gameCard.image,
|
||||||
|
false, ctx)),
|
||||||
|
onTap: () => print('${gameCard.date} ${gameCard.status}'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
return SizedBox(
|
||||||
|
width: widthIn(ctx),
|
||||||
|
child: Card(
|
||||||
|
semanticContainer: true,
|
||||||
|
clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||||
|
child: Container(
|
||||||
|
decoration: decoration,
|
||||||
|
child: body,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -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
122
lib/team_standings.dart
Normal 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;
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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:
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user