diff --git a/lib/components/comic.dart b/lib/components/comic.dart index f73ac9b..e5840a6 100644 --- a/lib/components/comic.dart +++ b/lib/components/comic.dart @@ -1626,7 +1626,7 @@ class _SMClipper extends CustomClipper { class SimpleComicTile extends StatelessWidget { const SimpleComicTile( - {super.key, required this.comic, this.onTap, this.withTitle = false}); + {super.key, required this.comic, this.onTap, this.withTitle = false, this.heroID}); final Comic comic; @@ -1634,6 +1634,8 @@ class SimpleComicTile extends StatelessWidget { final bool withTitle; + final int? heroID; + @override Widget build(BuildContext context) { var image = _findImageProvider(comic); @@ -1659,6 +1661,13 @@ class SimpleComicTile extends StatelessWidget { child: child, ); + if (heroID != null) { + child = Hero( + tag: "cover$heroID", + child: child, + ); + } + child = AnimatedTapRegion( borderRadius: 8, onTap: onTap ?? @@ -1667,6 +1676,9 @@ class SimpleComicTile extends StatelessWidget { () => ComicPage( id: comic.id, sourceKey: comic.sourceKey, + cover: comic.cover, + title: comic.title, + heroID: heroID, ), ); }, diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index c28c1bb..24c4165 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -302,13 +302,18 @@ class _HistoryState extends State<_History> { scrollDirection: Axis.horizontal, itemCount: history.length, itemBuilder: (context, index) { + final heroID = history[index].id.hashCode; return SimpleComicTile( comic: history[index], + heroID: heroID, onTap: () { context.to( () => ComicPage( id: history[index].id, sourceKey: history[index].type.sourceKey, + cover: history[index].cover, + title: history[index].title, + heroID: heroID, ), ); }, @@ -386,7 +391,9 @@ class _LocalState extends State<_Local> { Container( margin: const EdgeInsets.symmetric(horizontal: 8), padding: const EdgeInsets.symmetric( - horizontal: 8, vertical: 2), + horizontal: 8, + vertical: 2, + ), decoration: BoxDecoration( color: Theme.of(context).colorScheme.secondaryContainer, borderRadius: BorderRadius.circular(8), @@ -405,9 +412,22 @@ class _LocalState extends State<_Local> { scrollDirection: Axis.horizontal, itemCount: local.length, itemBuilder: (context, index) { - return SimpleComicTile(comic: local[index]) - .paddingHorizontal(8) - .paddingVertical(2); + final heroID = local[index].id.hashCode; + return SimpleComicTile( + comic: local[index], + heroID: heroID, + onTap: () { + context.to( + () => ComicPage( + id: local[index].id, + sourceKey: local[index].sourceKey, + cover: local[index].cover, + title: local[index].title, + heroID: heroID, + ), + ); + }, + ).paddingHorizontal(8).paddingVertical(2); }, ), ).paddingHorizontal(8),