From 465eb96f4bb14fd7ce507ab82127aea5205c20c7 Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Rosario Date: Fri, 1 May 2020 11:19:17 -0400 Subject: [PATCH] logic for game card --- lib/models/game_cards.dart | 49 ---------------------------- lib/route_generator.dart | 3 -- lib/screens/sport.dart | 13 +++++--- lib/screens/sport_schedule.dart | 58 +++++++++++++++++++++++---------- 4 files changed, 48 insertions(+), 75 deletions(-) diff --git a/lib/models/game_cards.dart b/lib/models/game_cards.dart index cee780a..156d767 100644 --- a/lib/models/game_cards.dart +++ b/lib/models/game_cards.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; -import 'package:table_calendar/table_calendar.dart'; import '../screens/sport_schedule.dart'; import 'dart:convert'; @@ -95,52 +94,4 @@ class ScheduleObject { DateTime d; List sportSched; ScheduleObject(this.d, this.sportSched); -} - - - - - - -class GameCardTest extends StatelessWidget{ - final int sportID; - GameCardTest(this.sportID); - - @override - Widget build(BuildContext context) { - final feed = GameCardFeed(); - return StatefulBuilder( - builder: (context, StateSetter setState) => Scaffold( - appBar: AppBar( - centerTitle: false, - title: Text("49ers"), - backgroundColor: Colors.green, - ), - body: HorizontalGameCards(gameCard: feed, sportID: sportID,), - drawer: Drawer( - child: ListView( - children: [ - 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, '/'), - ), - ), - ], - ), - ) - )); - } } \ No newline at end of file diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 4ffc765..e0caca6 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -1,4 +1,3 @@ -import 'package:capstone_hungry_hippos/models/game_cards.dart'; import 'package:capstone_hungry_hippos/screens/chat.dart'; import 'package:capstone_hungry_hippos/screens/schedule.dart'; import 'package:capstone_hungry_hippos/screens/standing.dart'; @@ -32,8 +31,6 @@ class RouteGenerator { return MaterialPageRoute(builder: (_) => FavoritesManager()); case '/Twitter': return MaterialPageRoute(builder: (_) => TwitterFeed()); - case '/gamecardtest': - return MaterialPageRoute(builder: (_) => GameCardTest(args)); default: return _errorRoute(); } diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index 25a15e3..201374b 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import '../news/feed.dart'; +import '../models/game_cards.dart'; class Sport extends StatelessWidget { static final List colorList = [ @@ -13,6 +14,7 @@ class Sport extends StatelessWidget { ]; final feed = Feed(); // was var not final + final gameCard = GameCardFeed(); final String imageMale = 'images/male.png'; final String imageFemale = 'images/female.png'; @@ -43,9 +45,9 @@ class Sport extends StatelessWidget { return StatefulBuilder( builder: (context, StateSetter setState) => Scaffold( appBar: AppBar( - centerTitle: false, - title: buildDropdownButton(selectedSport, setState), - backgroundColor: _curSport.color, + centerTitle: false, + title: buildDropdownButton(selectedSport, setState), + backgroundColor: _curSport.color, //--Gender Switch-- Need to make condition to determine gender actions: [ @@ -54,8 +56,8 @@ class Sport extends StatelessWidget { value: genderSport, onChanged: (value) { setState(() { - genderSport = value; - _genderSwitcherCheck(); + genderSport = value; + _genderSwitcherCheck(); }); }, inactiveThumbColor: Colors.lightBlue, @@ -68,6 +70,7 @@ class Sport extends StatelessWidget { ), body: ListView( children: [ + HorizontalGameCards(gameCard: gameCard, sportID: sport_ID,), HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name), sportFilter: _curSport.name,), ], ), diff --git a/lib/screens/sport_schedule.dart b/lib/screens/sport_schedule.dart index a7684b4..47e5308 100644 --- a/lib/screens/sport_schedule.dart +++ b/lib/screens/sport_schedule.dart @@ -67,7 +67,7 @@ class GameCard extends StatelessWidget { const GameCard({ Key key, @required this.gameCard, - this.numCards = 1.75, + this.numCards = 2.25, }) : super(key: key); final sport_schedule gameCard; @@ -89,7 +89,7 @@ class GameCard extends StatelessWidget { 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' + 'https://fiusports.com/images/logos/UNC-Charlotte.png?width=80&height=80&mode=max', )); } else { return (Image.network( @@ -97,6 +97,16 @@ class GameCard extends StatelessWidget { )); } } + + 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) { @@ -116,12 +126,12 @@ class GameCard extends StatelessWidget { }; var decoration = BoxDecoration( border: Border.all( - color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green - width: .5, + color: winLoss(gameCard.status), //UNCC Green + width: 1.2, ), - borderRadius: BorderRadius.circular(12.0), + borderRadius: BorderRadius.circular(2), ); - + var logoWidth = 4.5; var body = Column( verticalDirection: VerticalDirection.up, children: [ @@ -129,18 +139,19 @@ class GameCard extends StatelessWidget { color: Colors.white, child: ListTile( leading: SizedBox( - //width: widthIn(ctx)/3 - 5, - child: Container(decoration: decoration,child: _homeAwayImageOrder( + width: widthIn(ctx)/logoWidth, + child: _homeAwayImageOrder( gameCard.location_indicator, gameCard.image, - true, ctx))), - title: SizedBox( - //width: widthIn(ctx)/3 - 5, - child: Container(decoration: decoration,child: Wrap( + true, ctx)), + title: FittedBox( + fit: BoxFit.contain, + child: Wrap( children: [ if (gameCard.status == "null") // no game yet Text( - '${_months[gameCard.date.month]} ${gameCard.date.day}') + '${_months[gameCard.date.month]} ${gameCard.date.day}' + ) else _pastGameScore( gameCard.location_indicator, @@ -148,15 +159,26 @@ class GameCard extends StatelessWidget { gameCard.team_score, gameCard.opponent_score,), ], - )) + ) + ), + subtitle: FittedBox( + fit: BoxFit.contain, + child: Wrap( + children: [ + if (gameCard.status != "null") // no game yet + Text( + '${_months[gameCard.date.month]} ${gameCard.date.day}', textAlign: TextAlign.center, + ), + ], + ) ), trailing: SizedBox( - //width: widthIn(ctx)/3 - 5, - child: Container(decoration: decoration,child: _homeAwayImageOrder( + width: widthIn(ctx)/logoWidth, + child: _homeAwayImageOrder( gameCard.location_indicator, gameCard.image, - false, ctx))), - onTap: () => print('${gameCard.date}'), + false, ctx)), + onTap: () => print('${gameCard.status}'), ), ), ],