Each card takes you to a details page

This commit is contained in:
Carlos Lopez-Rosario
2020-05-01 21:07:36 -04:00
parent fbd256847a
commit 5a8ab5f5e5
5 changed files with 205 additions and 30 deletions

View File

@@ -0,0 +1,177 @@
import 'package:capstone_hungry_hippos/screens/sport_schedule.dart';
import 'package:flutter/material.dart';
//This will mode to Kalebs
class GameDetailsWidget extends StatelessWidget {
final sport_schedule gameCard;
const GameDetailsWidget(this.gameCard);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("VS. ${gameCard.opponentTitle}"),
),
body: ListView(
physics: const NeverScrollableScrollPhysics(),
children: <Widget>[
GameDetailsHeader(gameCard),
EasyAccess(),
],
),
);
}
} //Move to Kalebs ^^^^
class GameDetailsHeader extends StatelessWidget {
final sport_schedule gameCard;
const GameDetailsHeader(
this.gameCard,
);
Text _pastGameScore(
String homeAway, String winLoss, String uncc, String opponent) {
if (homeAway == "H" || homeAway == "T") {
return (Text('$uncc - $opponent'));
} else {
return (Text('$opponent - $uncc'));
}
}
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',
));
} else {
return (Image.network(
'https://charlotte49ers.com' + opposingTeam,
));
}
}
@override
Widget build(BuildContext context) {
var _months = {
1: 'JAN',
2: 'FEB',
3: 'MAR',
4: 'APR',
5: 'MAY',
6: 'JUN',
7: 'JUL',
8: 'AUG',
9: 'SEP',
10: 'OCT',
11: 'NOV',
12: 'DEC'
};
var size = MediaQuery.of(context).size;
return SizedBox(
height: size.height / 7,
child: Container(
color: Colors.black26,
width: size.width,
child: Center(
child: ListTile(
leading: SizedBox(
width: size.width / 3,
child: _homeAwayImageOrder(gameCard.location_indicator,
gameCard.image, true, context)),
title: FittedBox(
fit: BoxFit.contain,
child: Wrap(
children: <Widget>[
if (gameCard.status == null) // no game yet
Text(
'${_months[gameCard.date.month]} ${gameCard.date.day}')
else
_pastGameScore(
gameCard.location_indicator,
gameCard.status,
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,
)
else
Text(
'${gameCard.date.hour}:${gameCard.date.minute} PM'),
],
)),
trailing: SizedBox(
width: size.width / 3,
child: _homeAwayImageOrder(gameCard.location_indicator,
gameCard.image, false, context)),
),
)),
);
}
}
class EasyAccess extends StatelessWidget {
@override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
return SizedBox(
height: size.height / 15,
child: Container(
color: Colors.black12,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
_button(context, "Play-by-Play"),
_button(context, "Chat")
],
),
),
);
}
Widget _button(BuildContext context, String label) {
var size = MediaQuery.of(context).size;
label = (label == "Standings") ? "Standing" : label;
print(label);
var decoration = BoxDecoration(
border: Border.all(
color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green
),
borderRadius: BorderRadius.circular(5)
);
return Container(
child: GestureDetector(
onTap: () => print("clicked"),
//Navigator.pushNamed(context, "/$label"),
child: Card(
child: SizedBox(
width: size.width / 2.5,
child: Container(
decoration: decoration,
child:Container(
color: Colors.black12,
child: FittedBox(
fit: BoxFit.contain,
child: Text(label),
))),
),
),
),
);
}
}
//Class for pbp

View File

@@ -1,12 +1,13 @@
import 'package:capstone_hungry_hippos/screens/chat.dart'; import 'models/game_details.dart';
import 'package:capstone_hungry_hippos/screens/schedule.dart'; import 'screens/chat.dart';
import 'package:capstone_hungry_hippos/screens/standing.dart'; import 'screens/schedule.dart';
import 'screens/standing.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:capstone_hungry_hippos/screens/home_widget.dart'; import 'screens/home_widget.dart';
import 'package:capstone_hungry_hippos/screens/sport.dart'; import 'screens/sport.dart';
import 'package:capstone_hungry_hippos/screens/twitter_widget.dart'; import 'screens/twitter_widget.dart';
import 'package:capstone_hungry_hippos/screens/favorites_reorder.dart'; import 'screens/favorites_reorder.dart';
import 'package:capstone_hungry_hippos/screens/game_details.dart';
class RouteGenerator { class RouteGenerator {
static Route<dynamic> generateRoute(RouteSettings settings) { static Route<dynamic> generateRoute(RouteSettings settings) {
@@ -26,7 +27,7 @@ class RouteGenerator {
case '/Chat': case '/Chat':
return MaterialPageRoute(builder: (_) => Chat()); return MaterialPageRoute(builder: (_) => Chat());
case '/Details': case '/Details':
return MaterialPageRoute(builder: (_) => Details()); return MaterialPageRoute(builder: (_) => GameDetailsWidget(args));
case '/Favorites': case '/Favorites':
return MaterialPageRoute(builder: (_) => FavoritesManager()); return MaterialPageRoute(builder: (_) => FavoritesManager());
case '/Twitter': case '/Twitter':

View File

@@ -48,13 +48,7 @@ class _HomeState extends State<Home> {
onPressed: () => Navigator.pushNamed(context, '/Chat'), onPressed: () => Navigator.pushNamed(context, '/Chat'),
), ),
), ),
ListTile( //added by Kaleb to test details page. Will update path / delete when we have game tiles implemented. ListTile(
title: IconButton(
icon: Icon(Icons.book),
onPressed: () => Navigator.pushNamed(context, '/Details'),
),
),
ListTile(
title: IconButton( title: IconButton(
icon: Icon(Icons.voice_chat), icon: Icon(Icons.voice_chat),
onPressed: () => Navigator.pushNamed(context, '/Twitter'), onPressed: () => Navigator.pushNamed(context, '/Twitter'),

View File

@@ -180,13 +180,16 @@ class GameCard extends StatelessWidget {
gameCard.location_indicator, gameCard.location_indicator,
gameCard.image, gameCard.image,
false, ctx)), false, ctx)),
onTap: () => print('${gameCard.date} ${gameCard.status}'), onTap: () {
print(gameCard.idSport);
Navigator.pushNamed(ctx, '/Details', arguments: gameCard);
},
), ),
), ),
], ],
); );
return SizedBox( return SizedBox(
width: widthIn(ctx), width: widthIn(ctx),
child: Card( child: Card(

View File

@@ -7,21 +7,21 @@ packages:
name: archive name: archive
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.11" version: "2.0.13"
args: args:
dependency: transitive dependency: transitive
description: description:
name: args name: args
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.5.2" version: "1.6.0"
async: async:
dependency: transitive dependency: transitive
description: description:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.4.0" version: "2.4.1"
bloc: bloc:
dependency: transitive dependency: transitive
description: description:
@@ -35,21 +35,21 @@ packages:
name: boolean_selector name: boolean_selector
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.5" version: "2.0.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.2" version: "1.1.3"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.14.11" version: "1.14.12"
convert: convert:
dependency: transitive dependency: transitive
description: description:
@@ -63,7 +63,7 @@ packages:
name: crypto name: crypto
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.3" version: "2.1.4"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -113,7 +113,7 @@ packages:
name: image name: image
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.4" version: "2.1.12"
intl: intl:
dependency: transitive dependency: transitive
description: description:
@@ -176,7 +176,7 @@ packages:
name: quiver name: quiver
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.5" version: "2.1.3"
rxdart: rxdart:
dependency: transitive dependency: transitive
description: description:
@@ -230,7 +230,7 @@ packages:
name: source_span name: source_span
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.5.5" version: "1.7.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
@@ -279,7 +279,7 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.11" version: "0.2.15"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@@ -300,7 +300,7 @@ packages:
name: xml name: xml
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.5.0" version: "3.6.1"
sdks: sdks:
dart: ">=2.6.0 <3.0.0" dart: ">=2.6.0 <3.0.0"
flutter: ">=1.12.13+hotfix.4 <2.0.0" flutter: ">=1.12.13+hotfix.4 <2.0.0"