Skip to content

Commit

Permalink
fix: 继续观看也播放 hero 动画
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaoMint committed Jul 11, 2023
1 parent f3fa739 commit 87067e9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
7 changes: 5 additions & 2 deletions lib/pages/detail/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ class DetailPageController extends GetxController {
DetailPageController({
required this.package,
required this.url,
this.heroTag,
});

final String package;
final String url;
final String? heroTag;

ScrollController scrollController = ScrollController();

final isFavorite = false.obs;
final String package;
final String url;
final Rx<ExtensionDetail?> data = Rx(null);
final Rx<History?> history = Rx(null);
final RxString error = ''.obs;
Expand Down
16 changes: 11 additions & 5 deletions lib/pages/detail/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ class DetailPage extends StatefulWidget {
Key? key,
required this.url,
required this.package,
this.heroTag,
}) : super(key: key);
final String url;
final String package;
final String? heroTag;

@override
State<DetailPage> createState() => _DetailPageState();
Expand All @@ -32,16 +34,20 @@ class _DetailPageState extends State<DetailPage> {

@override
void initState() {
c = Get.put(DetailPageController(
package: widget.package,
url: widget.url,
));
c = Get.put(
DetailPageController(
package: widget.package,
url: widget.url,
heroTag: widget.heroTag,
),
tag: widget.package + widget.url,
);
super.initState();
}

@override
void dispose() {
Get.delete<DetailPageController>();
Get.delete<DetailPageController>(tag: widget.package + widget.url);
super.dispose();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/pages/detail/widgets/detail_appbar_flexible_space.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class _DetailAppbarflexibleSpaceState extends State<DetailAppbarflexibleSpace> {
child: Row(
children: [
Hero(
tag: c.url,
tag: c.heroTag ?? '',
child: Card(
clipBehavior: Clip.antiAlias,
child: SizedBox(
Expand Down
14 changes: 6 additions & 8 deletions lib/widgets/bangumi_card.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:miru_app/main.dart';
import 'package:miru_app/pages/detail/view.dart';
import 'package:miru_app/widgets/cache_network_image.dart';
Expand Down Expand Up @@ -98,14 +99,11 @@ class _BangumiCardState extends State<BangumiCard> {
color: Colors.transparent,
child: InkWell(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => DetailPage(
url: widget.url,
package: widget.package,
),
),
);
Get.to(DetailPage(
url: widget.url,
package: widget.package,
heroTag: widget.url,
));
},
),
),
Expand Down

0 comments on commit 87067e9

Please sign in to comment.