Merge branch 'filter-sport-articles' into Standings
This commit is contained in:
@@ -20,11 +20,13 @@ class HorizontalNewsFeed extends StatelessWidget {
|
|||||||
final Feed newsFeed;
|
final Feed newsFeed;
|
||||||
final Text title;
|
final Text title;
|
||||||
final double numCards;
|
final double numCards;
|
||||||
|
final String sportFilter;
|
||||||
|
|
||||||
const HorizontalNewsFeed({
|
const HorizontalNewsFeed({
|
||||||
Key key,
|
Key key,
|
||||||
@required this.newsFeed,
|
@required this.newsFeed,
|
||||||
@required this.title,
|
@required this.title,
|
||||||
|
@required this.sportFilter,
|
||||||
this.numCards = 3.25,
|
this.numCards = 3.25,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@@ -33,7 +35,8 @@ class HorizontalNewsFeed extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
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(
|
return SizedBox(
|
||||||
height: heightIn(context),
|
height: heightIn(context),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -54,7 +57,7 @@ class HorizontalNewsFeed extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: FutureBuilder(
|
child: FutureBuilder(
|
||||||
future: newsFeed.getPage(1),
|
future: page,
|
||||||
builder: (ctx, snapshot) {
|
builder: (ctx, snapshot) {
|
||||||
if (!snapshot.hasData) {
|
if (!snapshot.hasData) {
|
||||||
return Center(child: CircularProgressIndicator());
|
return Center(child: CircularProgressIndicator());
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ class Favorites {
|
|||||||
'Basketball',
|
'Basketball',
|
||||||
'Baseball',
|
'Baseball',
|
||||||
'Soccer',
|
'Soccer',
|
||||||
'Tennis',
|
|
||||||
'Volleyball'
|
'Volleyball'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ Future<List<HorizontalNewsFeed>> _buildList() async {
|
|||||||
return HorizontalNewsFeed(
|
return HorizontalNewsFeed(
|
||||||
newsFeed: feed,
|
newsFeed: feed,
|
||||||
title: Text(sport),
|
title: Text(sport),
|
||||||
|
sportFilter: sport,
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,15 @@ class Sport extends StatelessWidget {
|
|||||||
const Item("Basketball", Colors.red,[5,13]),
|
const Item("Basketball", Colors.red,[5,13]),
|
||||||
const Item("Soccer", Colors.pinkAccent,[9,17]),
|
const Item("Soccer", Colors.pinkAccent,[9,17]),
|
||||||
const Item('Baseball', Colors.orange,[1]),
|
const Item('Baseball', Colors.orange,[1]),
|
||||||
|
<<<<<<< HEAD
|
||||||
const Item('Softball', Colors.yellow,[12]),
|
const Item('Softball', Colors.yellow,[12]),
|
||||||
const Item('Volleyball', Colors.blue,[20]),
|
const Item('Volleyball', Colors.blue,[20]),
|
||||||
const Item('Tennis', Colors.yellowAccent,[10,18]),
|
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
|
final feed = Feed(); // was var not final
|
||||||
@@ -68,7 +74,7 @@ class Sport extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
body: ListView(
|
body: ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name)),
|
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name), sportFilter: _curSport.name,),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
drawer: Drawer(
|
drawer: Drawer(
|
||||||
|
|||||||
Reference in New Issue
Block a user