Merge branch 'filter-sport-articles' into Standings

This commit is contained in:
2020-04-30 20:29:45 -04:00
4 changed files with 13 additions and 4 deletions

View File

@@ -20,11 +20,13 @@ class HorizontalNewsFeed extends StatelessWidget {
final Feed newsFeed;
final Text title;
final double numCards;
final String sportFilter;
const HorizontalNewsFeed({
Key key,
@required this.newsFeed,
@required this.title,
@required this.sportFilter,
this.numCards = 3.25,
}) : super(key: key);
@@ -33,7 +35,8 @@ class HorizontalNewsFeed extends StatelessWidget {
}
@override
Widget build(BuildContext context) {
//print(title.data);
var page = newsFeed.getPage(1, size: 100).then((page) => page.where((article) => article.sport.toLowerCase().contains(sportFilter.toLowerCase())).toList());
return SizedBox(
height: heightIn(context),
child: Column(
@@ -54,7 +57,7 @@ class HorizontalNewsFeed extends StatelessWidget {
),
Expanded(
child: FutureBuilder(
future: newsFeed.getPage(1),
future: page,
builder: (ctx, snapshot) {
if (!snapshot.hasData) {
return Center(child: CircularProgressIndicator());

View File

@@ -10,7 +10,6 @@ class Favorites {
'Basketball',
'Baseball',
'Soccer',
'Tennis',
'Volleyball'
];

View File

@@ -96,6 +96,7 @@ Future<List<HorizontalNewsFeed>> _buildList() async {
return HorizontalNewsFeed(
newsFeed: feed,
title: Text(sport),
sportFilter: sport,
);
}).toList();
}

View File

@@ -7,9 +7,15 @@ class Sport extends StatelessWidget {
const Item("Basketball", Colors.red,[5,13]),
const Item("Soccer", Colors.pinkAccent,[9,17]),
const Item('Baseball', Colors.orange,[1]),
<<<<<<< HEAD
const Item('Softball', Colors.yellow,[12]),
const Item('Volleyball', Colors.blue,[20]),
const Item('Tennis', Colors.yellowAccent,[10,18]),
=======
const Item('Volleyball', Colors.blue,[0]),
const Item('Softball', Colors.yellow,[0]),
const Item('Tennis', Colors.yellowAccent,[0,0]),
>>>>>>> filter-sport-articles
];
final feed = Feed(); // was var not final
@@ -68,7 +74,7 @@ class Sport extends StatelessWidget {
),
body: ListView(
children: <Widget>[
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name)),
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name), sportFilter: _curSport.name,),
],
),
drawer: Drawer(