logic for game card
This commit is contained in:
@@ -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';
|
||||
@@ -96,51 +95,3 @@ class ScheduleObject {
|
||||
List<sport_schedule> 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: <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, '/'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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<Item> colorList = <Item>[
|
||||
@@ -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';
|
||||
@@ -68,6 +70,7 @@ class Sport extends StatelessWidget {
|
||||
),
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
HorizontalGameCards(gameCard: gameCard, sportID: sport_ID,),
|
||||
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name), sportFilter: _curSport.name,),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -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(
|
||||
@@ -98,6 +98,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) {
|
||||
var _months = {
|
||||
@@ -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: <Widget>[
|
||||
@@ -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: <Widget>[
|
||||
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: <Widget>[
|
||||
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}'),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user