Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

fix(video): locate history episode in selection grid (#2465)

NanoShikia2fd82590323
diff --git a/lib/pages/video/video_page.dart b/lib/pages/video/video_page.dart
index 29226bbf..b11fd23a 100644
--- a/lib/pages/video/video_page.dart
+++ b/lib/pages/video/video_page.dart
@@ -154,12 +154,12 @@ class _VideoPageState extends State<VideoPage>
}
void _initOfflineMode(PlayerController playerController) {
- _showTabBodyImmediately(locateEpisode: false);
final identity = videoPageController.currentHistoryIdentity;
videoPageController.historyOffset = identity == null
? 0
: videoPageController.getHistoryOffsetFor(identity);
visibleRoad = videoPageController.selectedEpisode.road;
+ _showTabBodyImmediately();
WidgetsBinding.instance.addPostFrameCallback((_) async {
await Future.delayed(_offlinePlayerInitDelay);
@@ -177,7 +177,6 @@ class _VideoPageState extends State<VideoPage>
void _initOnlineMode(PlayerController playerController) {
videoPageController.historyOffset = 0;
- _showTabBodyImmediately(locateEpisode: false);
var progress = historyController.lastWatching(
videoPageController.bangumiItem,
@@ -197,6 +196,7 @@ class _VideoPageState extends State<VideoPage>
}
}
visibleRoad = videoPageController.selectedEpisode.road;
+ _showTabBodyImmediately();
_logSubscription = videoPageController.logStream.listen((log) {
if (mounted) {
@@ -299,14 +299,18 @@ class _VideoPageState extends State<VideoPage>
}
void menuJumpToCurrentEpisode() {
- Future.delayed(const Duration(milliseconds: 20), () async {
- if (!mounted) {
+ WidgetsBinding.instance.addPostFrameCallback((_) async {
+ // GridViewObserver binds its sliver context in its own post-frame callback.
+ // Wait until the current frame's callbacks have all completed first.
+ await Future<void>.delayed(Duration.zero);
+ if (!mounted || !scrollController.hasClients) {
return;
}
+ final int index = videoPageController.selectedEpisode.episode - 1;
await observerController.jumpTo(
- index: videoPageController.selectedEpisode.episode > 1
- ? videoPageController.selectedEpisode.episode - 1
- : videoPageController.selectedEpisode.episode);
+ index: index < 0 ? 0 : index,
+ isFixedHeight: true,
+ );
});
}
@@ -334,11 +338,9 @@ class _VideoPageState extends State<VideoPage>
}
}
- void _showTabBodyImmediately({bool locateEpisode = true}) {
+ void _showTabBodyImmediately() {
_setTabBodyVisible(true, animated: false);
- if (locateEpisode) {
- menuJumpToCurrentEpisode();
- }
+ menuJumpToCurrentEpisode();
}
void _hideTabBodyImmediately() {
@@ -655,17 +657,17 @@ class _VideoPageState extends State<VideoPage>
: MediaQuery.sizeOf(context).width / 3),
child: Container(
color: Theme.of(context).canvasColor,
- child: GridViewObserver(
- controller: observerController,
- child: (isDesktop() || isTablet())
- ? tabBody
- : Column(
+ child: (isDesktop() || isTablet())
+ ? tabBody
+ : GridViewObserver(
+ controller: observerController,
+ child: Column(
children: [
menuBar,
menuBody,
],
),
- ),
+ ),
),
);
}