Vertical Articles for sport Page
This commit is contained in:
@@ -63,12 +63,12 @@ class HorizontalGameCards extends StatelessWidget {
|
|||||||
var card = gameCard.getGames(sportID);
|
var card = gameCard.getGames(sportID);
|
||||||
var events = [];
|
var events = [];
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: heightIn(context),//heightIn(context),
|
height: heightIn(context),
|
||||||
child: FutureBuilder(
|
child: FutureBuilder(
|
||||||
future: card,
|
future: card,
|
||||||
// ignore: missing_return
|
// ignore: missing_return
|
||||||
builder: (ctx, snapshot) {
|
builder: (ctx, snapshot) {
|
||||||
print(snapshot);
|
//print(snapshot);
|
||||||
if (!snapshot.hasData) {
|
if (!snapshot.hasData) {
|
||||||
return Center(child: CircularProgressIndicator());
|
return Center(child: CircularProgressIndicator());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -90,3 +90,59 @@ class ArticleCard extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ArticleCardVert extends StatelessWidget {
|
||||||
|
const ArticleCardVert({
|
||||||
|
Key key,
|
||||||
|
@required this.article,
|
||||||
|
this.numCards = 2.1,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final Article article;
|
||||||
|
final double numCards;
|
||||||
|
|
||||||
|
double heightIn(BuildContext context) {
|
||||||
|
return (MediaQuery.of(context).size.height * 7/8) / numCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
var decoration = BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: NetworkImage(
|
||||||
|
article.thumbUrl,
|
||||||
|
),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
var body = Column(
|
||||||
|
verticalDirection: VerticalDirection.up,
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
color: Colors.white,
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(
|
||||||
|
article.mediumHeadline,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
maxLines: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
return SizedBox(
|
||||||
|
height: heightIn(context),
|
||||||
|
child: Card(
|
||||||
|
semanticContainer: true,
|
||||||
|
clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||||
|
child: Container(
|
||||||
|
decoration: decoration,
|
||||||
|
child: body,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -82,3 +82,43 @@ class HorizontalNewsFeed extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class VerticalNewsFeed extends StatelessWidget {
|
||||||
|
final Feed newsFeed;
|
||||||
|
final String sportFilter;
|
||||||
|
|
||||||
|
const VerticalNewsFeed({
|
||||||
|
Key key,
|
||||||
|
@required this.newsFeed,
|
||||||
|
@required this.sportFilter,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
var page = newsFeed.getPage(1, size: 100).then((page) => page.where((article) => article.sport.toLowerCase().contains(sportFilter.toLowerCase())).toList());
|
||||||
|
var size = MediaQuery.of(context).size;
|
||||||
|
return SizedBox(
|
||||||
|
height: size.height * (7/8),
|
||||||
|
child: FutureBuilder(
|
||||||
|
future: page,
|
||||||
|
builder: (ctx, snapshot) {
|
||||||
|
if (!snapshot.hasData) {
|
||||||
|
return Center(child: CircularProgressIndicator());
|
||||||
|
} else {
|
||||||
|
List<Article> articles = snapshot.data;
|
||||||
|
return ListView.builder(
|
||||||
|
//shrinkWrap: true,
|
||||||
|
scrollDirection: Axis.vertical,
|
||||||
|
itemCount: articles.length,
|
||||||
|
itemBuilder: (ctx, idx) {
|
||||||
|
return ArticleCardVert(
|
||||||
|
article: articles[idx],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -69,9 +69,10 @@ class Sport extends StatelessWidget {
|
|||||||
]
|
]
|
||||||
),
|
),
|
||||||
body: ListView(
|
body: ListView(
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
HorizontalGameCards(gameCard: gameCard, sportID: sport_ID,),
|
HorizontalGameCards(gameCard: gameCard, sportID: sport_ID,),
|
||||||
HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name), sportFilter: _curSport.name,),
|
VerticalNewsFeed(newsFeed: feed, sportFilter: _curSport.name),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
drawer: Drawer(
|
drawer: Drawer(
|
||||||
@@ -131,7 +132,7 @@ class Sport extends StatelessWidget {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_curSport = value;
|
_curSport = value;
|
||||||
_genderSwitcherCheck();
|
_genderSwitcherCheck();
|
||||||
print(sport_ID);
|
//print(sport_ID);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
items: colorList.map<DropdownMenuItem<Item>>((Item item) {
|
items: colorList.map<DropdownMenuItem<Item>>((Item item) {
|
||||||
@@ -155,7 +156,7 @@ class Sport extends StatelessWidget {
|
|||||||
genderSportSwitch = false;
|
genderSportSwitch = false;
|
||||||
sport_ID = _curSport.sportID[0];
|
sport_ID = _curSport.sportID[0];
|
||||||
}
|
}
|
||||||
print(sport_ID);
|
//print(sport_ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class GameCard extends StatelessWidget {
|
|||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
child: Wrap(
|
child: Wrap(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (gameCard.status == "null") // no game yet
|
if (gameCard.status == null) // no game yet
|
||||||
Text(
|
Text(
|
||||||
'${_months[gameCard.date.month]} ${gameCard.date.day}'
|
'${_months[gameCard.date.month]} ${gameCard.date.day}'
|
||||||
)
|
)
|
||||||
@@ -165,10 +165,12 @@ class GameCard extends StatelessWidget {
|
|||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
child: Wrap(
|
child: Wrap(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (gameCard.status != "null") // no game yet
|
if (gameCard.status != null) // no game yet
|
||||||
Text(
|
Text(
|
||||||
'${_months[gameCard.date.month]} ${gameCard.date.day}', textAlign: TextAlign.center,
|
'${_months[gameCard.date.month]} ${gameCard.date.day}', textAlign: TextAlign.center,
|
||||||
),
|
)
|
||||||
|
else
|
||||||
|
Text('${gameCard.date.hour}:${gameCard.date.minute} PM'),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@@ -178,7 +180,7 @@ class GameCard extends StatelessWidget {
|
|||||||
gameCard.location_indicator,
|
gameCard.location_indicator,
|
||||||
gameCard.image,
|
gameCard.image,
|
||||||
false, ctx)),
|
false, ctx)),
|
||||||
onTap: () => print('${gameCard.status}'),
|
onTap: () => print('${gameCard.date} ${gameCard.status}'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
24
pubspec.lock
24
pubspec.lock
@@ -7,21 +7,21 @@ packages:
|
|||||||
name: archive
|
name: archive
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.11"
|
version: "2.0.13"
|
||||||
args:
|
args:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: args
|
name: args
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.5.2"
|
version: "1.6.0"
|
||||||
async:
|
async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.0"
|
version: "2.4.1"
|
||||||
bloc:
|
bloc:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -35,21 +35,21 @@ packages:
|
|||||||
name: boolean_selector
|
name: boolean_selector
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.5"
|
version: "2.0.0"
|
||||||
charcode:
|
charcode:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: charcode
|
name: charcode
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.2"
|
version: "1.1.3"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: collection
|
name: collection
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.14.11"
|
version: "1.14.12"
|
||||||
convert:
|
convert:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -63,7 +63,7 @@ packages:
|
|||||||
name: crypto
|
name: crypto
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.3"
|
version: "2.1.4"
|
||||||
cupertino_icons:
|
cupertino_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -113,7 +113,7 @@ packages:
|
|||||||
name: image
|
name: image
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.1.12"
|
||||||
intl:
|
intl:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -176,7 +176,7 @@ packages:
|
|||||||
name: quiver
|
name: quiver
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.5"
|
version: "2.1.3"
|
||||||
rxdart:
|
rxdart:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -230,7 +230,7 @@ packages:
|
|||||||
name: source_span
|
name: source_span
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.5.5"
|
version: "1.7.0"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -279,7 +279,7 @@ packages:
|
|||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.11"
|
version: "0.2.15"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -300,7 +300,7 @@ packages:
|
|||||||
name: xml
|
name: xml
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.5.0"
|
version: "3.6.1"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.6.0 <3.0.0"
|
dart: ">=2.6.0 <3.0.0"
|
||||||
flutter: ">=1.12.13+hotfix.4 <2.0.0"
|
flutter: ">=1.12.13+hotfix.4 <2.0.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user