diff --git a/lib/monthly_calendar.dart b/lib/monthly_calendar.dart index d3cef7b..bf1efc4 100644 --- a/lib/monthly_calendar.dart +++ b/lib/monthly_calendar.dart @@ -11,9 +11,11 @@ class Calendar extends StatefulWidget { _Calendar createState() => _Calendar(); } +List _selectedEvents; +DateTime selectedDay; +Map> _events; + class _Calendar extends State with TickerProviderStateMixin { - Map _events; - List _selectedEvents; AnimationController _animationController; CalendarController _calController; @@ -23,15 +25,17 @@ class _Calendar extends State with TickerProviderStateMixin { Future> getEvents() async { var url = '$sportUrl&sport_id=$sportID&name=&extra=%7B%7D'; - print(url); //temp + //print(url); //temp http.Response response = await http.get(url); Iterable games = json.decode(response.body); - return games.map((e) => sport_schedule.fromJson(e)).toList(); + + return games.map((json) => sport_schedule.fromJson(json)).toList(); + //return games.map((e) => sport_schedule.fromJson(e)).toList(); } - Future> getGames() async { - Map mapGrab = {}; + Future>> getGames() async { + Map> mapGrab = {}; List eventInfo = await getEvents(); @@ -45,10 +49,10 @@ class _Calendar extends State with TickerProviderStateMixin { if (original == null) { //print("null"); - mapGrab[sportEvent] = [eventInfo[i].opponentTitle]; + mapGrab[sportEvent] = [eventInfo[i]]; } else { //print(eventInfo[i].date); - mapGrab[sportEvent] = List.from(original)..addAll([eventInfo[i].opponentTitle]); + mapGrab[sportEvent] = List.from(original)..addAll([eventInfo[i]]); } //print([eventInfo[i].opponentTitle]); //temp } @@ -86,9 +90,10 @@ class _Calendar extends State with TickerProviderStateMixin { super.dispose(); } - void _DaySelected(DateTime day, List events) { + void _DaySelected(DateTime day, List events) { setState(() { _selectedEvents = events; + selectedDay = DateTime(day.year, day.month, day.day); }); } @@ -226,7 +231,7 @@ class _Calendar extends State with TickerProviderStateMixin { //----- Creates event box display (mini box) ----- Widget _buildEventsMarker(DateTime date, List events) { - return AnimatedContainer( + children: _selectedEvents.map((event) => AnimatedContainer( duration: const Duration(milliseconds: 300), decoration: BoxDecoration( @@ -259,45 +264,13 @@ class _Calendar extends State with TickerProviderStateMixin { ), ), ), - ); - } - - //----- Format to Game Result ----- - Widget _buildGameResult() { - return Container( - decoration: BoxDecoration( - shape: BoxShape.rectangle, - - color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green - if win - //color: Colors.grey, // - if lose/tie - ), - - width: 15.0, - height: 15.0, - alignment: Alignment.center, - - child: Text( - 'W', //Game Result (W-L-T) - style: TextStyle().copyWith( - color: Colors.white, // - if win - fontSize: 13.0, - fontWeight: FontWeight.bold, - - /*'L', //Game Result (W-L-T) - style: TextStyle().copyWith( - color: Colors.black, // - if lose/tie - fontSize: 13.0, - fontWeight: FontWeight.bold,*/ - ), - ), - ); + )); } //----- Creates event display ----- Widget _eventLister() { return ListView( children: _selectedEvents.map((event) => Container( - decoration: BoxDecoration( border: Border.all( color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green @@ -311,31 +284,107 @@ class _Calendar extends State with TickerProviderStateMixin { margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0), child: ListTile( - leading: Icon(Icons.accessible), //opponent logo + leading: Icon(Icons.accessible), //opponent logo - Not done title: Row( children: [ - //Text('vs. '), //home or away (vs. / @) - Text('at '), //home or away (vs. / at) - Text(event.toString()), //opponent name + if (event.location.toString() == "Charlotte, NC" || event.location.toString() == "Charlotte, N.C.") + Text('vs. ') //home game + else + Text('at '), //away game + + Text(event.opponentTitle.toString()), //opponent name ], ), - //subtitle: Text(event.toString()), //Type of sport - Location - subtitle: Text('Sport - Location'), + subtitle: Text(event.sportTitle.toString() + " - " + event.location.toString()), //Type of sport - Location trailing: Row( mainAxisSize: MainAxisSize.min, children: [ - Text('Score '), - _buildGameResult(), //Game Result (W-L) - //Text('TBD'), + //Game Result (W/L/T) - Not done + /*if (event.status.toString() == "W") + _buildGameResultWin() + else if (event.status.toString() == "L") + _buildGameResultLose() + else if (event.status.toString() == "T") + _buildGameResultTie() + else + Text('TBD')*/ ], ), onTap: () => print('$event tapped!'), //When event display is clicked ), - )) - .toList(), + )).toList(), ); } + + //----- Format to Game Result (W)----- + Widget _buildGameResultWin() { + children: _selectedEvents.map((event) => Container( + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: Color.fromRGBO(0, 112, 60, 1), + ), + + width: 15.0, + height: 15.0, + alignment: Alignment.center, + + child: Text( + event.status.toString(), //Game Result (W-L-T) + style: TextStyle().copyWith( + color: Colors.white, + fontSize: 13.0, + fontWeight: FontWeight.bold, + ), + ), + )); + } + + //----- Format to Game Result (L)----- + Widget _buildGameResultLose() { + children: _selectedEvents.map((event) => Container( + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: Colors.grey, + ), + + width: 15.0, + height: 15.0, + alignment: Alignment.center, + + child: Text( + event.status.toString(), //Game Result (W-L-T) + style: TextStyle().copyWith( + color: Colors.black, + fontSize: 13.0, + fontWeight: FontWeight.bold, + ), + ), + )); + } + + //----- Format to Game Result (T)----- + Widget _buildGameResultTie() { + children: _selectedEvents.map((event) => Container( + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: Colors.grey, + ), + + width: 15.0, + height: 15.0, + alignment: Alignment.center, + + child: Text( + event.status.toString(), //Game Result (W-L-T) + style: TextStyle().copyWith( + color: Colors.black, + fontSize: 13.0, + fontWeight: FontWeight.bold, + ), + ), + )); + } } \ No newline at end of file diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index 3292f77..ec3b377 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -14,9 +14,10 @@ class Sport extends StatelessWidget { final feed = Feed(); // was var not final - bool genderSportSwitch = false; + bool genderSportSwitch = false; //determines if sport needs the gender switch final String imageMale = 'images/male.png'; final String imageFemale = 'images/female.png'; + bool genderSport = false; //determines which gender switch is set M - false / F - True static int sport_ID; @@ -37,17 +38,22 @@ class Sport extends StatelessWidget { Switch( value: false, onChanged: (value) { - setState(() {}); + setState(() { + if (value == false) { + genderSport = false; + } + else { + genderSport = true; + } + + //print(genderSport); + }); }, inactiveThumbColor: Colors.lightBlue, - inactiveThumbImage: Image - .asset(imageMale) - .image, + inactiveThumbImage: Image.asset(imageMale).image, activeColor: Colors.pinkAccent, - activeThumbImage: Image - .asset(imageFemale) - .image, + activeThumbImage: Image.asset(imageFemale).image, ), ] @@ -120,31 +126,46 @@ class Sport extends StatelessWidget { _curSport = value; //Will set the sport id / Display gender switch - switch (_curSport.name) { //prints are temporary + switch (_curSport.name) { //prints are temp case 'FootBall': - print(_curSport.name); - print(genderSportSwitch); + //print(_curSport.name); genderSportSwitch = false; + //print(genderSportSwitch); + sport_ID = 3; break; + case 'BasketBall': - print(_curSport.name); - print(genderSportSwitch); + //print(_curSport.name); genderSportSwitch = true; - sport_ID = 5; //Male - //sport_ID = 13; //Female + //print(genderSportSwitch); + + if (genderSport == false) { + sport_ID = 5; //Male + } + else { + sport_ID = 13; //Female + } break; + case 'Soccer': - print(_curSport.name); - print(genderSportSwitch); + //print(_curSport.name); genderSportSwitch = true; - sport_ID = 9; //Male - //sport_ID = 17; //Female + //print(genderSportSwitch); + + if (genderSport == false) { + sport_ID = 9; //Male + } + else { + sport_ID = 17; //Female + } break; + case 'Baseball': - print(_curSport.name); - print(genderSportSwitch); + //print(_curSport.name); genderSportSwitch = false; + //print(genderSportSwitch); + sport_ID = 1; break; }