From ed5b53755088dca7f8d8c06f18eb44d1e704f3c7 Mon Sep 17 00:00:00 2001 From: daniel-michel <65034538+daniel-michel@users.noreply.github.com> Date: Tue, 9 Jan 2024 19:16:48 +0100 Subject: [PATCH] fix: show no movies when none of the movies is allowed by the filter --- lib/view/movie_list.dart | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/view/movie_list.dart b/lib/view/movie_list.dart index feaca93..8430780 100644 --- a/lib/view/movie_list.dart +++ b/lib/view/movie_list.dart @@ -7,13 +7,11 @@ import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; class MovieList extends StatelessWidget { final List movies; final bool Function(MovieData)? filter; - MovieList(List movies, {this.filter, super.key}) - : movies = movies.toList(), - super(); + const MovieList(this.movies, {this.filter, super.key}); @override Widget build(BuildContext context) { - if (movies.isEmpty) { + Widget noMovies() { return Center( child: IntrinsicHeight( child: Column( @@ -23,7 +21,7 @@ class MovieList extends StatelessWidget { size: 100, ), Text( - "No movies available", + "No Movies", style: Theme.of(context).textTheme.headlineMedium, ), ], @@ -31,6 +29,11 @@ class MovieList extends StatelessWidget { ), ); } + + if (movies.isEmpty) { + return noMovies(); + } + Widget buildGroupSeparator(BuildContext context, DateWithPrecision date) { bool highlight = date.includes(DateTime.now()); return SizedBox( @@ -38,7 +41,7 @@ class MovieList extends StatelessWidget { child: Align( alignment: Alignment.center, child: Card( - elevation: 5, + elevation: 3, color: highlight ? Theme.of(context).colorScheme.primaryContainer : null, @@ -66,6 +69,9 @@ class MovieList extends StatelessWidget { } index++; } + if (indexMap.isEmpty) { + return noMovies(); + } int firstMovieTodayOrAfterIndex = () { DateWithPrecision today = DateWithPrecision.today(); int min = 0; @@ -93,6 +99,7 @@ class MovieList extends StatelessWidget { initialScrollIndex: firstMovieTodayOrAfterIndex, ); } + int firstMovieTodayOrAfterIndex = () { DateWithPrecision today = DateWithPrecision.today(); int min = 0;