mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix member video jump
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -106,6 +106,7 @@ class MemberVideoCtr
|
|||||||
}
|
}
|
||||||
firstAid = data.item?.firstOrNull?.param;
|
firstAid = data.item?.firstOrNull?.param;
|
||||||
lastAid = data.item?.lastOrNull?.param;
|
lastAid = data.item?.lastOrNull?.param;
|
||||||
|
isLoadPrevious = false;
|
||||||
loadingState.value = Success(data.item);
|
loadingState.value = Success(data.item);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import 'package:PiliPlus/pages/member/controller.dart';
|
|||||||
import 'package:PiliPlus/pages/member_video/controller.dart';
|
import 'package:PiliPlus/pages/member_video/controller.dart';
|
||||||
import 'package:PiliPlus/pages/member_video/widgets/video_card_h_member_video.dart';
|
import 'package:PiliPlus/pages/member_video/widgets/video_card_h_member_video.dart';
|
||||||
import 'package:PiliPlus/utils/grid.dart';
|
import 'package:PiliPlus/utils/grid.dart';
|
||||||
|
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -55,6 +57,23 @@ class _MemberVideoState extends State<MemberVideo>
|
|||||||
'${widget.heroTag}${widget.type.name}${widget.seasonId}${widget.seriesId}',
|
'${widget.heroTag}${widget.type.name}${widget.seasonId}${widget.seriesId}',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
int? _index;
|
||||||
|
late ExtendedNestedScrollController _scrollController;
|
||||||
|
|
||||||
|
void _jumpToIndex(int index) {
|
||||||
|
final scrollOffset = gridDelegate.layoutCache!
|
||||||
|
.getGeometryForChildIndex(index)
|
||||||
|
.scrollOffset;
|
||||||
|
try {
|
||||||
|
_scrollController.nestedPositions
|
||||||
|
.elementAt(_index!)
|
||||||
|
.localJumpTo(scrollOffset);
|
||||||
|
} catch (e) {
|
||||||
|
_scrollController.jumpTo(scrollOffset);
|
||||||
|
if (kDebugMode) debugPrint('jump error: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
@@ -64,20 +83,14 @@ class _MemberVideoState extends State<MemberVideo>
|
|||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
final count = _controller.loadingState.value.dataOrNull?.length;
|
final count = _controller.loadingState.value.dataOrNull?.length;
|
||||||
await _controller.onRefresh();
|
await _controller.onRefresh();
|
||||||
if (_controller.isLoadPrevious) {
|
if (_controller.isLocating.value && mounted) {
|
||||||
if (mounted) {
|
|
||||||
final newCount = _controller.loadingState.value.dataOrNull?.length;
|
final newCount = _controller.loadingState.value.dataOrNull?.length;
|
||||||
if (count != null && newCount != null && newCount > count) {
|
if (count != null && newCount != null && newCount > count) {
|
||||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||||
PrimaryScrollController.of(this.context).jumpTo(
|
_jumpToIndex(newCount - count);
|
||||||
gridDelegate.layoutCache!
|
|
||||||
.getGeometryForChildIndex(newCount - count)
|
|
||||||
.scrollOffset,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
physics: ReloadScrollPhysics(controller: _controller),
|
physics: ReloadScrollPhysics(controller: _controller),
|
||||||
@@ -93,6 +106,12 @@ class _MemberVideoState extends State<MemberVideo>
|
|||||||
);
|
);
|
||||||
if (widget.type == ContributeType.video &&
|
if (widget.type == ContributeType.video &&
|
||||||
_controller.fromViewAid?.isNotEmpty == true) {
|
_controller.fromViewAid?.isNotEmpty == true) {
|
||||||
|
if (_index == null) {
|
||||||
|
_scrollController =
|
||||||
|
PrimaryScrollController.of(this.context)
|
||||||
|
as ExtendedNestedScrollController;
|
||||||
|
_index = _scrollController.nestedPositions.length;
|
||||||
|
}
|
||||||
return Stack(
|
return Stack(
|
||||||
clipBehavior: Clip.none,
|
clipBehavior: Clip.none,
|
||||||
children: [
|
children: [
|
||||||
@@ -118,11 +137,7 @@ class _MemberVideoState extends State<MemberVideo>
|
|||||||
..loadingState.value = LoadingState.loading()
|
..loadingState.value = LoadingState.loading()
|
||||||
..queryData();
|
..queryData();
|
||||||
} else {
|
} else {
|
||||||
PrimaryScrollController.of(context).jumpTo(
|
_jumpToIndex(locatedIndex);
|
||||||
gridDelegate.layoutCache!
|
|
||||||
.getGeometryForChildIndex(locatedIndex)
|
|
||||||
.scrollOffset,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
label: const Text('定位至上次观看'),
|
label: const Text('定位至上次观看'),
|
||||||
|
|||||||
Reference in New Issue
Block a user