summaryrefslogtreecommitdiff
path: root/lib/widgets/popular_item.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/widgets/popular_item.dart')
-rw-r--r--lib/widgets/popular_item.dart40
1 files changed, 35 insertions, 5 deletions
diff --git a/lib/widgets/popular_item.dart b/lib/widgets/popular_item.dart
index 7e8cc2c..3ef32cd 100644
--- a/lib/widgets/popular_item.dart
+++ b/lib/widgets/popular_item.dart
@@ -3,15 +3,45 @@ import 'package:pmsna1/models/popular.dart';
class PopularItem extends StatelessWidget {
final Popular popular;
+ final void Function(bool favorited) onFavorited;
+ final void Function() onPressed;
- const PopularItem(this.popular, {super.key});
+ const PopularItem(
+ this.popular, {
+ super.key,
+ required this.onFavorited,
+ required this.onPressed,
+ });
@override
Widget build(BuildContext context) {
- return FadeInImage(
- placeholder: const AssetImage('assets/loading.gif'),
- image: NetworkImage(
- 'https://image.tmdb.org/t/p/w500/${popular.posterPath!}',
+ return Card(
+ semanticContainer: true,
+ clipBehavior: Clip.antiAliasWithSaveLayer,
+ child: InkWell(
+ onTap: onPressed,
+ child: Stack(
+ children: [
+ Hero(
+ tag: popular.posterPath!,
+ child: FadeInImage(
+ placeholder: const AssetImage('assets/loading.gif'),
+ image: NetworkImage(
+ 'https://image.tmdb.org/t/p/w500/${popular.posterPath!}',
+ ),
+ ),
+ ),
+ popular.hasFavorite
+ ? IconButton(
+ icon: const Icon(Icons.favorite),
+ onPressed: () => onFavorited(!popular.hasFavorite),
+ )
+ : IconButton(
+ icon: const Icon(Icons.favorite_outline),
+ onPressed: () => onFavorited(!popular.hasFavorite),
+ ),
+ ],
+ ),
),
);
}