Merge branch 'filter-sport-articles' into Standings
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -10,7 +10,6 @@ class Favorites {
|
||||
'Basketball',
|
||||
'Baseball',
|
||||
'Soccer',
|
||||
'Tennis',
|
||||
'Volleyball'
|
||||
];
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ Future<List<HorizontalNewsFeed>> _buildList() async {
|
||||
return HorizontalNewsFeed(
|
||||
newsFeed: feed,
|
||||
title: Text(sport),
|
||||
sportFilter: sport,
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user