2023-11-06 10:38:26 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:release_schedule/model/movie.dart';
|
2024-01-08 14:30:32 +01:00
|
|
|
import 'package:release_schedule/view/movie_page.dart';
|
2023-11-06 10:38:26 +01:00
|
|
|
|
|
|
|
class MovieItem extends StatelessWidget {
|
|
|
|
final MovieData movie;
|
2024-01-09 14:48:36 +01:00
|
|
|
final bool showReleaseDate;
|
|
|
|
const MovieItem(this.movie, {this.showReleaseDate = false, super.key});
|
2023-11-06 10:38:26 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return AnimatedBuilder(
|
|
|
|
animation: movie,
|
|
|
|
builder: (context, widget) {
|
|
|
|
return ListTile(
|
2024-01-08 12:57:36 +01:00
|
|
|
title: Text(movie.title),
|
2024-01-09 14:48:36 +01:00
|
|
|
subtitle: Text(
|
|
|
|
(showReleaseDate ? "${movie.releaseDate} " : "") +
|
|
|
|
(movie.genres?.join(", ") ?? ""),
|
|
|
|
),
|
2024-01-08 21:48:13 +01:00
|
|
|
trailing: IconButton(
|
|
|
|
icon: Icon(movie.bookmarked
|
2024-01-08 12:57:36 +01:00
|
|
|
? Icons.bookmark_added
|
|
|
|
: Icons.bookmark_border),
|
|
|
|
onPressed: () => movie.setDetails(bookmarked: !movie.bookmarked),
|
|
|
|
),
|
2024-01-08 14:30:32 +01:00
|
|
|
onTap: () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) {
|
|
|
|
return MoviePage(movie);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
2024-01-08 12:57:36 +01:00
|
|
|
);
|
2023-11-06 10:38:26 +01:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|