Route to sports takes an argument and goes to proper sport

This commit is contained in:
Carlos Lopez-Rosario
2020-04-17 14:02:30 -04:00
parent 99cff9ac7a
commit b3fb054c45
3 changed files with 30 additions and 11 deletions

View File

@@ -18,7 +18,7 @@ class Feed {
class HorizontalNewsFeed extends StatelessWidget {
final Feed newsFeed;
final Widget title;
final Text title;
final double numCards;
const HorizontalNewsFeed({
@@ -31,9 +31,9 @@ class HorizontalNewsFeed extends StatelessWidget {
double heightIn(BuildContext context) {
return MediaQuery.of(context).size.height / numCards;
}
@override
Widget build(BuildContext context) {
//print(title.data);
return SizedBox(
height: heightIn(context),
child: Column(
@@ -43,8 +43,8 @@ class HorizontalNewsFeed extends StatelessWidget {
title: title,
trailing: IconButton(
icon: Icon(Icons.navigate_next),
onPressed: () => Navigator.of(context).pushNamed('/Sport', arguments: title.data),
onPressed: () => Navigator.of(context).pushNamed('/Sport'),
/*onPressed: () { //changed
Navigator.of(context).pushNamed('/Sport');

View File

@@ -18,7 +18,7 @@ class RouteGenerator {
return MaterialPageRoute(builder: (_) => Home());
case '/Sport':
//We can put logic and stuff here for checking if logged in
return MaterialPageRoute(builder: (_) => Sport());
return MaterialPageRoute(builder: (_) => Sport(args));
case '/Schedule':
return MaterialPageRoute(builder: (_) => Schedule());
case '/Standing':

View File

@@ -4,26 +4,45 @@ import '../news/feed.dart';
class Sport extends StatelessWidget {
static final List<Item> colorList = <Item>[
const Item('FootBall', Colors.green),
const Item("BasketBall", Colors.red),
const Item('Football', Colors.green),
const Item("Basketball", Colors.red),
const Item("Soccer", Colors.pinkAccent),
const Item('Baseball', Colors.orange),
const Item('Volleyball', Colors.blue),
const Item('Softball', Colors.yellow),
const Item('Tennis', Colors.yellowAccent),
];
Item _curSport = colorList[0];
final feed = Feed(); // was var not final
bool genderSportSwitch = false; //determines if sport needs the gender switch
final String imageMale = 'images/male.png';
final String imageFemale = 'images/female.png';
static bool genderSport = false; //determines which gender switch is set M - false / F - True
static int sport_ID;
final String sport;
Sport(this.sport);
Item _curSport = colorList[0];
@override
Widget build(BuildContext context) {
Item _setDefault(){
Item _curSport;
for (Item i in colorList){
if (i.name == sport){
_curSport = i;
break;
}
}
return _curSport;
}
_curSport = _setDefault();
Item selectedSport;
if (_curSport.name == "Soccer" || _curSport.name == "Basketball" || _curSport.name == "Tennis" ){
genderSportSwitch = true;
}
return StatefulBuilder(
builder: (context, StateSetter setState) => Scaffold(
@@ -34,7 +53,7 @@ class Sport extends StatelessWidget {
//--Gender Switch-- Need to make condition to determine gender
actions: <Widget>[
if (genderSportSwitch == true)
if (genderSportSwitch)
Switch(
value: genderSport,
onChanged: (value) {
@@ -183,4 +202,4 @@ class Item {
final String name;
final Color color;
}
}