From b3fb054c450cb085901d37f89689221a55610635 Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Rosario Date: Fri, 17 Apr 2020 14:02:30 -0400 Subject: [PATCH] Route to sports takes an argument and goes to proper sport --- lib/news/feed.dart | 6 +++--- lib/route_generator.dart | 2 +- lib/screens/sport.dart | 33 ++++++++++++++++++++++++++------- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/lib/news/feed.dart b/lib/news/feed.dart index c5662ce..f1938c6 100644 --- a/lib/news/feed.dart +++ b/lib/news/feed.dart @@ -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'); diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 7678fff..8c6ac8e 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -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': diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index b141d4d..05311a8 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -4,26 +4,45 @@ import '../news/feed.dart'; class Sport extends StatelessWidget { static final List colorList = [ - 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: [ - if (genderSportSwitch == true) + if (genderSportSwitch) Switch( value: genderSport, onChanged: (value) { @@ -183,4 +202,4 @@ class Item { final String name; final Color color; -} +} \ No newline at end of file