fix: 补充更多的heroTag,直接传入避免问题

This commit is contained in:
orz12
2024-06-02 13:27:39 +08:00
parent 3dd4fef45a
commit 03b97c5f43
7 changed files with 50 additions and 24 deletions

View File

@@ -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<BangumiIntroPanel>
@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<VideoDetailController>(tag: heroTag);

View File

@@ -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<VideoIntroPanel> createState() => _VideoIntroPanelState();
@@ -48,9 +49,10 @@ class _VideoIntroPanelState extends State<VideoIntroPanel>
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<VideoInfo> 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<VideoInfo> 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,

View File

@@ -15,11 +15,13 @@ class PagesPanel extends StatefulWidget {
this.cid,
required this.bvid,
required this.changeFuc,
required this.heroTag,
});
final List<Part> pages;
final int? cid;
final String bvid;
final Function changeFuc;
final String heroTag;
@override
State<PagesPanel> createState() => _PagesPanelState();
@@ -29,7 +31,8 @@ class _PagesPanelState extends State<PagesPanel> {
late List<Part> 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<PagesPanel> {
super.initState();
cid = widget.cid!;
episodes = widget.pages;
heroTag = widget.heroTag;
_videoDetailController = Get.find<VideoDetailController>(tag: heroTag);
currentIndex = episodes.indexWhere((Part e) => e.cid == cid);
_videoDetailController.cid.listen((int p0) {

View File

@@ -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<SeasonPanel> createState() => _SeasonPanelState();
@@ -23,7 +25,8 @@ class _SeasonPanelState extends State<SeasonPanel> {
List<EpisodeItem>? 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<SeasonPanel> {
void initState() {
super.initState();
cid = widget.cid!;
heroTag = widget.heroTag;
_videoDetailController = Get.find<VideoDetailController>(tag: heroTag);
/// 根据 cid 找到对应集,找到对应 episodes

View File

@@ -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<RelatedVideoPanel> createState() => _RelatedVideoPanelState();
}
@@ -27,8 +27,7 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel>
@override
void initState() {
super.initState();
_releatedController =
Get.put(ReleatedController(), tag: Get.arguments?['heroTag']);
_releatedController = Get.put(ReleatedController(), tag: widget.heroTag);
_futureBuilder = _releatedController.queryRelatedVideo();
}

View File

@@ -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<VideoReplyPanel>
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(

View File

@@ -607,11 +607,12 @@ class _VideoDetailPageState extends State<VideoDetailPage>
slivers: <Widget>[
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<VideoDetailPage>
.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<VideoDetailPage>
slivers: <Widget>[
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<VideoDetailPage>
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<VideoDetailPage>
key: PageStorageKey<String>('简介${videoDetailController.bvid}'),
slivers: <Widget>[
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<VideoDetailPage>
() => VideoReplyPanel(
bvid: videoDetailController.bvid,
oid: videoDetailController.oid.value,
heroTag: heroTag,
),
),
)
@@ -888,11 +893,12 @@ class _VideoDetailPageState extends State<VideoDetailPage>
key: PageStorageKey<String>('简介${videoDetailController.bvid}'),
slivers: <Widget>[
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<VideoDetailPage>
() => VideoReplyPanel(
bvid: videoDetailController.bvid,
oid: videoDetailController.oid.value,
heroTag: heroTag,
),
),
)
@@ -1019,11 +1026,12 @@ class _VideoDetailPageState extends State<VideoDetailPage>
slivers: <Widget>[
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<VideoDetailPage>
() => VideoReplyPanel(
bvid: videoDetailController.bvid,
oid: videoDetailController.oid.value,
heroTag: heroTag,
),
)
// ],