diff --git a/lib/models/game_cards.dart b/lib/models/game_cards.dart index 156d767..f36156d 100644 --- a/lib/models/game_cards.dart +++ b/lib/models/game_cards.dart @@ -63,12 +63,12 @@ class HorizontalGameCards extends StatelessWidget { var card = gameCard.getGames(sportID); var events = []; return SizedBox( - height: heightIn(context),//heightIn(context), + height: heightIn(context), child: FutureBuilder( future: card, // ignore: missing_return builder: (ctx, snapshot) { - print(snapshot); + //print(snapshot); if (!snapshot.hasData) { return Center(child: CircularProgressIndicator()); } else { diff --git a/lib/news/article.dart b/lib/news/article.dart index 033f85b..9019538 100644 --- a/lib/news/article.dart +++ b/lib/news/article.dart @@ -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: [ + 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, + ), + ), + ); + } +} diff --git a/lib/news/feed.dart b/lib/news/feed.dart index 62aaea5..d4a27db 100644 --- a/lib/news/feed.dart +++ b/lib/news/feed.dart @@ -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
articles = snapshot.data; + return ListView.builder( + //shrinkWrap: true, + scrollDirection: Axis.vertical, + itemCount: articles.length, + itemBuilder: (ctx, idx) { + return ArticleCardVert( + article: articles[idx], + ); + }, + ); + } + }, + )); + } +} diff --git a/lib/screens/sport.dart b/lib/screens/sport.dart index 5a1c3ec..c53c82a 100644 --- a/lib/screens/sport.dart +++ b/lib/screens/sport.dart @@ -69,9 +69,10 @@ class Sport extends StatelessWidget { ] ), body: ListView( + physics: const NeverScrollableScrollPhysics(), children: [ HorizontalGameCards(gameCard: gameCard, sportID: sport_ID,), - HorizontalNewsFeed(newsFeed: feed, title: Text(_curSport.name), sportFilter: _curSport.name,), + VerticalNewsFeed(newsFeed: feed, sportFilter: _curSport.name), ], ), drawer: Drawer( @@ -131,7 +132,7 @@ class Sport extends StatelessWidget { setState(() { _curSport = value; _genderSwitcherCheck(); - print(sport_ID); + //print(sport_ID); }); }, items: colorList.map>((Item item) { @@ -155,7 +156,7 @@ class Sport extends StatelessWidget { genderSportSwitch = false; sport_ID = _curSport.sportID[0]; } - print(sport_ID); + //print(sport_ID); } } diff --git a/lib/screens/sport_schedule.dart b/lib/screens/sport_schedule.dart index 47e5308..71a93a5 100644 --- a/lib/screens/sport_schedule.dart +++ b/lib/screens/sport_schedule.dart @@ -148,7 +148,7 @@ class GameCard extends StatelessWidget { fit: BoxFit.contain, child: Wrap( children: [ - if (gameCard.status == "null") // no game yet + if (gameCard.status == null) // no game yet Text( '${_months[gameCard.date.month]} ${gameCard.date.day}' ) @@ -165,10 +165,12 @@ class GameCard extends StatelessWidget { fit: BoxFit.contain, child: Wrap( children: [ - if (gameCard.status != "null") // no game yet + if (gameCard.status != null) // no game yet Text( '${_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.image, false, ctx)), - onTap: () => print('${gameCard.status}'), + onTap: () => print('${gameCard.date} ${gameCard.status}'), ), ), ], diff --git a/pubspec.lock b/pubspec.lock index b39c496..76f0d96 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,21 +7,21 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "2.0.11" + version: "2.0.13" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted - version: "1.5.2" + version: "1.6.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" + version: "2.4.1" bloc: dependency: transitive description: @@ -35,21 +35,21 @@ packages: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "2.0.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.1.3" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" + version: "1.14.12" convert: dependency: transitive description: @@ -63,7 +63,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.1.4" cupertino_icons: dependency: "direct main" description: @@ -113,7 +113,7 @@ packages: name: image url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.12" intl: dependency: transitive description: @@ -176,7 +176,7 @@ packages: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.1.3" rxdart: dependency: transitive description: @@ -230,7 +230,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.7.0" stack_trace: dependency: transitive description: @@ -279,7 +279,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.11" + version: "0.2.15" typed_data: dependency: transitive description: @@ -300,7 +300,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "3.5.0" + version: "3.6.1" sdks: dart: ">=2.6.0 <3.0.0" flutter: ">=1.12.13+hotfix.4 <2.0.0"