Calendar shows what sport, and little box for games with more than 1 game

This commit is contained in:
clopezr1
2020-04-23 17:49:34 -04:00
parent ff26f31dc8
commit 3a8397b89e
3 changed files with 23 additions and 11 deletions

View File

@@ -208,14 +208,20 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
markersBuilder: (context, date, events, holidays) {
final miniBox = <Widget>[];
if (events.isNotEmpty) {
miniBox.add(
Positioned(
right: 0,top: 0, left: 0, bottom: 0,
child: _buildEventsMarker(date, events[0].location_indicator),
child: _buildEventsMarker(date, events[0].location_indicator, true, events),
),
);
if (events.length > 1)
miniBox.add(
Positioned(
right: 1, bottom: 1,
child: _buildEventsMarker(date, events[0].location_indicator, false, events),
)
);
}
return miniBox;
@@ -234,7 +240,10 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
}
//----- Creates event box display (mini box) -----
Widget _buildEventsMarker(DateTime date, String location) {
Widget _buildEventsMarker(DateTime date, String location, bool main, events) {
String s;
if (main) {s = "${date.day}";} else {s = "${events.length}";}
return AnimatedContainer(
duration: const Duration(milliseconds: 300),
@@ -253,7 +262,7 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
//if selected date && home game / else away game
color: _calController.isSelected(date)
? Colors.blue[400]
: _homeAwayColor(location), //UNCC Green
: _homeAwayColor(location, main), //UNCC Green
//: Colors.grey,
),
@@ -262,7 +271,7 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
child: Center(
child: Text(
'${date.day}',
s,
style: TextStyle().copyWith(
color: Colors.white,
fontSize: 12.0,
@@ -272,7 +281,7 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
);
}
Color _homeAwayColor(String location){
Color _homeAwayColor(String location, bool main){
//TODO: Here should be the logic on if Home or Away return the colors
// Do whatever you need to do to check home/away
// my guess is if the game says vs its home
@@ -285,6 +294,9 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
} else {
c = Colors.grey;
}
if (!main){
c = Colors.black45;//Color.fromRGBO(179, 163, 105, 1);
}
return c;
}

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

@@ -105,7 +105,7 @@ class Sport extends StatelessWidget {
ListTile(
title: IconButton(
icon: Icon(Icons.calendar_today),
onPressed: () => Navigator.pushNamed(context, '/Schedule',arguments: sport_ID),
onPressed: () => Navigator.pushNamed(context, '/Schedule',arguments: [sport_ID, _curSport.name],),
),
),
],