From 03b97c5f4326008dc6dd6cfa25392de97845c13e Mon Sep 17 00:00:00 2001 From: orz12 Date: Sun, 2 Jun 2024 13:27:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A1=A5=E5=85=85=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E7=9A=84heroTag=EF=BC=8C=E7=9B=B4=E6=8E=A5=E4=BC=A0=E5=85=A5?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/bangumi/introduction/view.dart | 5 ++- lib/pages/video/detail/introduction/view.dart | 12 ++++--- .../detail/introduction/widgets/page.dart | 6 +++- .../detail/introduction/widgets/season.dart | 6 +++- lib/pages/video/detail/related/view.dart | 7 ++-- lib/pages/video/detail/reply/view.dart | 5 ++- lib/pages/video/detail/view.dart | 33 ++++++++++++------- 7 files changed, 50 insertions(+), 24 deletions(-) diff --git a/lib/pages/bangumi/introduction/view.dart b/lib/pages/bangumi/introduction/view.dart index b31d5ebd..ad4141d5 100644 --- a/lib/pages/bangumi/introduction/view.dart +++ b/lib/pages/bangumi/introduction/view.dart @@ -21,9 +21,11 @@ import 'widgets/intro_detail.dart'; class BangumiIntroPanel extends StatefulWidget { final int? cid; + final String heroTag; const BangumiIntroPanel({ Key? key, this.cid, + required this.heroTag, }) : super(key: key); @override @@ -46,7 +48,8 @@ class _BangumiIntroPanelState extends State @override void initState() { super.initState(); - heroTag = Get.arguments['heroTag']; + // heroTag = Get.arguments['heroTag']; + heroTag = widget.heroTag; cid = widget.cid!; bangumiIntroController = Get.put(BangumiIntroController(), tag: heroTag); videoDetailCtr = Get.find(tag: heroTag); diff --git a/lib/pages/video/detail/introduction/view.dart b/lib/pages/video/detail/introduction/view.dart index c76f7d88..f54eafa1 100644 --- a/lib/pages/video/detail/introduction/view.dart +++ b/lib/pages/video/detail/introduction/view.dart @@ -26,7 +26,8 @@ import 'widgets/page.dart'; import 'widgets/season.dart'; class VideoIntroPanel extends StatefulWidget { - const VideoIntroPanel({super.key}); + const VideoIntroPanel({required this.heroTag, super.key}); + final String heroTag; @override State createState() => _VideoIntroPanelState(); @@ -48,9 +49,10 @@ class _VideoIntroPanelState extends State super.initState(); /// fix 全屏时参数丢失 - if (Get.arguments != null) { - heroTag = Get.arguments['heroTag']; - } + // if (Get.arguments != null) { + // heroTag = Get.arguments['heroTag']; + // } + heroTag = widget.heroTag; videoIntroController = Get.put(VideoIntroController(), tag: heroTag); _futureBuilderFuture = videoIntroController.queryVideoIntro(); videoIntroController.videoDetail.listen((value) { @@ -482,6 +484,7 @@ class _VideoInfoState extends State with TickerProviderStateMixin { widget.videoDetail!.ugcSeason != null) ...[ Obx( () => SeasonPanel( + heroTag: heroTag, ugcSeason: widget.videoDetail!.ugcSeason!, cid: videoIntroController.lastPlayCid.value != 0 ? videoIntroController.lastPlayCid.value @@ -494,6 +497,7 @@ class _VideoInfoState extends State with TickerProviderStateMixin { widget.videoDetail!.pages != null && widget.videoDetail!.pages!.length > 1) ...[ Obx(() => PagesPanel( + heroTag: heroTag, pages: widget.videoDetail!.pages!, cid: videoIntroController.lastPlayCid.value, bvid: videoIntroController.bvid, diff --git a/lib/pages/video/detail/introduction/widgets/page.dart b/lib/pages/video/detail/introduction/widgets/page.dart index 4bd03ad2..24d95d9f 100644 --- a/lib/pages/video/detail/introduction/widgets/page.dart +++ b/lib/pages/video/detail/introduction/widgets/page.dart @@ -15,11 +15,13 @@ class PagesPanel extends StatefulWidget { this.cid, required this.bvid, required this.changeFuc, + required this.heroTag, }); final List pages; final int? cid; final String bvid; final Function changeFuc; + final String heroTag; @override State createState() => _PagesPanelState(); @@ -29,7 +31,8 @@ class _PagesPanelState extends State { late List episodes; late int cid; late int currentIndex; - final String heroTag = Get.arguments['heroTag']; + // final String heroTag = Get.arguments['heroTag']; + late final String heroTag; late VideoDetailController _videoDetailController; final ScrollController _scrollController2 = ScrollController(); @@ -38,6 +41,7 @@ class _PagesPanelState extends State { super.initState(); cid = widget.cid!; episodes = widget.pages; + heroTag = widget.heroTag; _videoDetailController = Get.find(tag: heroTag); currentIndex = episodes.indexWhere((Part e) => e.cid == cid); _videoDetailController.cid.listen((int p0) { diff --git a/lib/pages/video/detail/introduction/widgets/season.dart b/lib/pages/video/detail/introduction/widgets/season.dart index fc71003a..a04a8a88 100644 --- a/lib/pages/video/detail/introduction/widgets/season.dart +++ b/lib/pages/video/detail/introduction/widgets/season.dart @@ -10,10 +10,12 @@ class SeasonPanel extends StatefulWidget { required this.ugcSeason, this.cid, required this.changeFuc, + required this.heroTag, }); final UgcSeason ugcSeason; final int? cid; final Function changeFuc; + final String heroTag; @override State createState() => _SeasonPanelState(); @@ -23,7 +25,8 @@ class _SeasonPanelState extends State { List? episodes; late int cid; int currentIndex = 0; - final String heroTag = Get.arguments['heroTag']; + // final String heroTag = Get.arguments['heroTag']; + late final String heroTag; late VideoDetailController _videoDetailController; final ScrollController _scrollController = ScrollController(); @@ -31,6 +34,7 @@ class _SeasonPanelState extends State { void initState() { super.initState(); cid = widget.cid!; + heroTag = widget.heroTag; _videoDetailController = Get.find(tag: heroTag); /// 根据 cid 找到对应集,找到对应 episodes diff --git a/lib/pages/video/detail/related/view.dart b/lib/pages/video/detail/related/view.dart index e998f2d4..822ad0bf 100644 --- a/lib/pages/video/detail/related/view.dart +++ b/lib/pages/video/detail/related/view.dart @@ -10,8 +10,8 @@ import '../../../../utils/grid.dart'; import './controller.dart'; class RelatedVideoPanel extends StatefulWidget { - const RelatedVideoPanel({super.key}); - + const RelatedVideoPanel({super.key, required this.heroTag}); + final String heroTag; @override State createState() => _RelatedVideoPanelState(); } @@ -27,8 +27,7 @@ class _RelatedVideoPanelState extends State @override void initState() { super.initState(); - _releatedController = - Get.put(ReleatedController(), tag: Get.arguments?['heroTag']); + _releatedController = Get.put(ReleatedController(), tag: widget.heroTag); _futureBuilder = _releatedController.queryRelatedVideo(); } diff --git a/lib/pages/video/detail/reply/view.dart b/lib/pages/video/detail/reply/view.dart index 948aa28a..7ce90a5e 100644 --- a/lib/pages/video/detail/reply/view.dart +++ b/lib/pages/video/detail/reply/view.dart @@ -16,12 +16,14 @@ class VideoReplyPanel extends StatefulWidget { final int? oid; final int rpid; final String? replyLevel; + final String heroTag; const VideoReplyPanel({ this.bvid, this.oid, this.rpid = 0, this.replyLevel, + required this.heroTag, super.key, }); @@ -47,7 +49,8 @@ class _VideoReplyPanelState extends State void initState() { super.initState(); // int oid = widget.bvid != null ? IdUtils.bv2av(widget.bvid!) : 0; - heroTag = Get.arguments['heroTag']; + // heroTag = Get.arguments['heroTag']; + heroTag = widget.heroTag; replyLevel = widget.replyLevel ?? '1'; if (replyLevel == '2') { _videoReplyController = Get.put( diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 90a30b50..b47cb613 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -607,11 +607,12 @@ class _VideoDetailPageState extends State slivers: [ if (videoDetailController.videoType == SearchType.video) ...[ - const VideoIntroPanel(), + VideoIntroPanel(heroTag: heroTag), ] else if (videoDetailController .videoType == SearchType.media_bangumi) ...[ Obx(() => BangumiIntroPanel( + heroTag: heroTag, cid: videoDetailController.cid.value)), ], @@ -624,13 +625,14 @@ class _VideoDetailPageState extends State .withOpacity(0.06), ), ), - const RelatedVideoPanel(), + RelatedVideoPanel(heroTag: heroTag), ], ), Obx( () => VideoReplyPanel( bvid: videoDetailController.bvid, oid: videoDetailController.oid.value, + heroTag: heroTag, ), ) ], @@ -711,10 +713,11 @@ class _VideoDetailPageState extends State slivers: [ if (videoDetailController.videoType == SearchType.video) ...[ - const VideoIntroPanel(), + VideoIntroPanel(heroTag: heroTag), ] else if (videoDetailController.videoType == SearchType.media_bangumi) ...[ Obx(() => BangumiIntroPanel( + heroTag: heroTag, cid: videoDetailController.cid.value)), ], SliverToBoxAdapter( @@ -724,13 +727,14 @@ class _VideoDetailPageState extends State color: Theme.of(context).dividerColor.withOpacity(0.06), ), ), - const RelatedVideoPanel(), + RelatedVideoPanel(heroTag: heroTag), ], ), Obx( () => VideoReplyPanel( bvid: videoDetailController.bvid, oid: videoDetailController.oid.value, + heroTag: heroTag, ), ) ], @@ -801,12 +805,12 @@ class _VideoDetailPageState extends State key: PageStorageKey('简介${videoDetailController.bvid}'), slivers: [ if (videoDetailController.videoType == SearchType.video) ...[ - const VideoIntroPanel(), - const RelatedVideoPanel(), + VideoIntroPanel(heroTag: heroTag), + RelatedVideoPanel(heroTag: heroTag), ] else if (videoDetailController.videoType == SearchType.media_bangumi) ...[ - Obx(() => - BangumiIntroPanel(cid: videoDetailController.cid.value)), + Obx(() => BangumiIntroPanel( + heroTag: heroTag, cid: videoDetailController.cid.value)), ] ], )), @@ -815,6 +819,7 @@ class _VideoDetailPageState extends State () => VideoReplyPanel( bvid: videoDetailController.bvid, oid: videoDetailController.oid.value, + heroTag: heroTag, ), ), ) @@ -888,11 +893,12 @@ class _VideoDetailPageState extends State key: PageStorageKey('简介${videoDetailController.bvid}'), slivers: [ if (videoDetailController.videoType == SearchType.video) ...[ - const VideoIntroPanel(), - const RelatedVideoPanel(), + VideoIntroPanel(heroTag: heroTag), + RelatedVideoPanel(heroTag: heroTag), ] else if (videoDetailController.videoType == SearchType.media_bangumi) ...[ Obx(() => BangumiIntroPanel( + heroTag: heroTag, cid: videoDetailController.cid.value)), ] ], @@ -902,6 +908,7 @@ class _VideoDetailPageState extends State () => VideoReplyPanel( bvid: videoDetailController.bvid, oid: videoDetailController.oid.value, + heroTag: heroTag, ), ), ) @@ -1019,11 +1026,12 @@ class _VideoDetailPageState extends State slivers: [ if (videoDetailController.videoType == SearchType.video) ...[ - const VideoIntroPanel(), - const RelatedVideoPanel(), + VideoIntroPanel(heroTag: heroTag), + RelatedVideoPanel(heroTag: heroTag), ] else if (videoDetailController.videoType == SearchType.media_bangumi) ...[ Obx(() => BangumiIntroPanel( + heroTag: heroTag, cid: videoDetailController.cid.value)), ] ], @@ -1059,6 +1067,7 @@ class _VideoDetailPageState extends State () => VideoReplyPanel( bvid: videoDetailController.bvid, oid: videoDetailController.oid.value, + heroTag: heroTag, ), ) // ],