fix: show no movies when none of the movies is allowed by the filter
parent
642f5b70a2
commit
ed5b537550
|
@ -7,13 +7,11 @@ import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
||||||
class MovieList extends StatelessWidget {
|
class MovieList extends StatelessWidget {
|
||||||
final List<MovieData> movies;
|
final List<MovieData> movies;
|
||||||
final bool Function(MovieData)? filter;
|
final bool Function(MovieData)? filter;
|
||||||
MovieList(List<MovieData> movies, {this.filter, super.key})
|
const MovieList(this.movies, {this.filter, super.key});
|
||||||
: movies = movies.toList(),
|
|
||||||
super();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (movies.isEmpty) {
|
Widget noMovies() {
|
||||||
return Center(
|
return Center(
|
||||||
child: IntrinsicHeight(
|
child: IntrinsicHeight(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
@ -23,7 +21,7 @@ class MovieList extends StatelessWidget {
|
||||||
size: 100,
|
size: 100,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
"No movies available",
|
"No Movies",
|
||||||
style: Theme.of(context).textTheme.headlineMedium,
|
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) {
|
Widget buildGroupSeparator(BuildContext context, DateWithPrecision date) {
|
||||||
bool highlight = date.includes(DateTime.now());
|
bool highlight = date.includes(DateTime.now());
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
|
@ -38,7 +41,7 @@ class MovieList extends StatelessWidget {
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Card(
|
child: Card(
|
||||||
elevation: 5,
|
elevation: 3,
|
||||||
color: highlight
|
color: highlight
|
||||||
? Theme.of(context).colorScheme.primaryContainer
|
? Theme.of(context).colorScheme.primaryContainer
|
||||||
: null,
|
: null,
|
||||||
|
@ -66,6 +69,9 @@ class MovieList extends StatelessWidget {
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
if (indexMap.isEmpty) {
|
||||||
|
return noMovies();
|
||||||
|
}
|
||||||
int firstMovieTodayOrAfterIndex = () {
|
int firstMovieTodayOrAfterIndex = () {
|
||||||
DateWithPrecision today = DateWithPrecision.today();
|
DateWithPrecision today = DateWithPrecision.today();
|
||||||
int min = 0;
|
int min = 0;
|
||||||
|
@ -93,6 +99,7 @@ class MovieList extends StatelessWidget {
|
||||||
initialScrollIndex: firstMovieTodayOrAfterIndex,
|
initialScrollIndex: firstMovieTodayOrAfterIndex,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
int firstMovieTodayOrAfterIndex = () {
|
int firstMovieTodayOrAfterIndex = () {
|
||||||
DateWithPrecision today = DateWithPrecision.today();
|
DateWithPrecision today = DateWithPrecision.today();
|
||||||
int min = 0;
|
int min = 0;
|
||||||
|
|
Loading…
Reference in New Issue