logic for game card
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:table_calendar/table_calendar.dart';
|
|
||||||
|
|
||||||
import '../screens/sport_schedule.dart';
|
import '../screens/sport_schedule.dart';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
@@ -95,52 +94,4 @@ class ScheduleObject {
|
|||||||
DateTime d;
|
DateTime d;
|
||||||
List<sport_schedule> sportSched;
|
List<sport_schedule> sportSched;
|
||||||
ScheduleObject(this.d, this.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/chat.dart';
|
||||||
import 'package:capstone_hungry_hippos/screens/schedule.dart';
|
import 'package:capstone_hungry_hippos/screens/schedule.dart';
|
||||||
import 'package:capstone_hungry_hippos/screens/standing.dart';
|
import 'package:capstone_hungry_hippos/screens/standing.dart';
|
||||||
@@ -32,8 +31,6 @@ class RouteGenerator {
|
|||||||
return MaterialPageRoute(builder: (_) => FavoritesManager());
|
return MaterialPageRoute(builder: (_) => FavoritesManager());
|
||||||
case '/Twitter':
|
case '/Twitter':
|
||||||
return MaterialPageRoute(builder: (_) => TwitterFeed());
|
return MaterialPageRoute(builder: (_) => TwitterFeed());
|
||||||
case '/gamecardtest':
|
|
||||||
return MaterialPageRoute(builder: (_) => GameCardTest(args));
|
|
||||||
default:
|
default:
|
||||||
return _errorRoute();
|
return _errorRoute();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
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>[
|
||||||
@@ -13,6 +14,7 @@ class Sport extends StatelessWidget {
|
|||||||
];
|
];
|
||||||
|
|
||||||
final feed = Feed(); // was var not final
|
final feed = Feed(); // was var not final
|
||||||
|
final gameCard = GameCardFeed();
|
||||||
|
|
||||||
final String imageMale = 'images/male.png';
|
final String imageMale = 'images/male.png';
|
||||||
final String imageFemale = 'images/female.png';
|
final String imageFemale = 'images/female.png';
|
||||||
@@ -43,9 +45,9 @@ class Sport extends StatelessWidget {
|
|||||||
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: _curSport.color,
|
||||||
|
|
||||||
//--Gender Switch-- Need to make condition to determine gender
|
//--Gender Switch-- Need to make condition to determine gender
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
@@ -54,8 +56,8 @@ class Sport extends StatelessWidget {
|
|||||||
value: genderSport,
|
value: genderSport,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
genderSport = value;
|
genderSport = value;
|
||||||
_genderSwitcherCheck();
|
_genderSwitcherCheck();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
inactiveThumbColor: Colors.lightBlue,
|
inactiveThumbColor: Colors.lightBlue,
|
||||||
@@ -68,6 +70,7 @@ class Sport extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
body: ListView(
|
body: ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
HorizontalGameCards(gameCard: gameCard, sportID: sport_ID,),
|
||||||
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name), sportFilter: _curSport.name,),
|
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name), sportFilter: _curSport.name,),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class GameCard extends StatelessWidget {
|
|||||||
const GameCard({
|
const GameCard({
|
||||||
Key key,
|
Key key,
|
||||||
@required this.gameCard,
|
@required this.gameCard,
|
||||||
this.numCards = 1.75,
|
this.numCards = 2.25,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final sport_schedule gameCard;
|
final sport_schedule gameCard;
|
||||||
@@ -89,7 +89,7 @@ class GameCard extends StatelessWidget {
|
|||||||
Image _homeAwayImageOrder(String h, String opposingTeam, bool l, BuildContext ctx) {
|
Image _homeAwayImageOrder(String h, String opposingTeam, bool l, BuildContext ctx) {
|
||||||
if ((h == "H") == l) {
|
if ((h == "H") == l) {
|
||||||
return (Image.network(
|
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 {
|
} else {
|
||||||
return (Image.network(
|
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
|
@override
|
||||||
Widget build(BuildContext ctx) {
|
Widget build(BuildContext ctx) {
|
||||||
@@ -116,12 +126,12 @@ class GameCard extends StatelessWidget {
|
|||||||
};
|
};
|
||||||
var decoration = BoxDecoration(
|
var decoration = BoxDecoration(
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green
|
color: winLoss(gameCard.status), //UNCC Green
|
||||||
width: .5,
|
width: 1.2,
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
borderRadius: BorderRadius.circular(2),
|
||||||
);
|
);
|
||||||
|
var logoWidth = 4.5;
|
||||||
var body = Column(
|
var body = Column(
|
||||||
verticalDirection: VerticalDirection.up,
|
verticalDirection: VerticalDirection.up,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@@ -129,18 +139,19 @@ class GameCard extends StatelessWidget {
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: SizedBox(
|
leading: SizedBox(
|
||||||
//width: widthIn(ctx)/3 - 5,
|
width: widthIn(ctx)/logoWidth,
|
||||||
child: Container(decoration: decoration,child: _homeAwayImageOrder(
|
child: _homeAwayImageOrder(
|
||||||
gameCard.location_indicator,
|
gameCard.location_indicator,
|
||||||
gameCard.image,
|
gameCard.image,
|
||||||
true, ctx))),
|
true, ctx)),
|
||||||
title: SizedBox(
|
title: FittedBox(
|
||||||
//width: widthIn(ctx)/3 - 5,
|
fit: BoxFit.contain,
|
||||||
child: Container(decoration: decoration,child: Wrap(
|
child: Wrap(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (gameCard.status == "null") // no game yet
|
if (gameCard.status == "null") // no game yet
|
||||||
Text(
|
Text(
|
||||||
'${_months[gameCard.date.month]} ${gameCard.date.day}')
|
'${_months[gameCard.date.month]} ${gameCard.date.day}'
|
||||||
|
)
|
||||||
else
|
else
|
||||||
_pastGameScore(
|
_pastGameScore(
|
||||||
gameCard.location_indicator,
|
gameCard.location_indicator,
|
||||||
@@ -148,15 +159,26 @@ class GameCard extends StatelessWidget {
|
|||||||
gameCard.team_score,
|
gameCard.team_score,
|
||||||
gameCard.opponent_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(
|
trailing: SizedBox(
|
||||||
//width: widthIn(ctx)/3 - 5,
|
width: widthIn(ctx)/logoWidth,
|
||||||
child: Container(decoration: decoration,child: _homeAwayImageOrder(
|
child: _homeAwayImageOrder(
|
||||||
gameCard.location_indicator,
|
gameCard.location_indicator,
|
||||||
gameCard.image,
|
gameCard.image,
|
||||||
false, ctx))),
|
false, ctx)),
|
||||||
onTap: () => print('${gameCard.date}'),
|
onTap: () => print('${gameCard.status}'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user