feat: grid jump to index (#1004)

This commit is contained in:
My-Responsitories
2025-08-12 17:06:33 +08:00
committed by GitHub
parent e00c176bdf
commit 690c4f5786
4 changed files with 38 additions and 12 deletions

View File

@@ -595,7 +595,7 @@ class _CreateDynPanelState extends CommonRichTextPubPageState<CreateDynPanel> {
height: height,
child: GridView(
padding: const EdgeInsets.only(left: 12, bottom: 12, right: 12),
gridDelegate: const SliverGridDelegateWithExtentAndRatio(
gridDelegate: SliverGridDelegateWithExtentAndRatio(
maxCrossAxisExtent: 65,
mainAxisSpacing: 12,
crossAxisSpacing: 12,

View File

@@ -42,6 +42,8 @@ class _MemberVideoState extends State<MemberVideo>
@override
bool get wantKeepAlive => true;
late final gridDelegate = Grid.videoCardHDelegate(context);
late final _controller = Get.put(
MemberVideoCtr(
type: widget.type,
@@ -89,12 +91,29 @@ class _MemberVideoState extends State<MemberVideo>
top: false,
left: false,
child: FloatingActionButton.extended(
onPressed: () => _controller
..isLocating.value = true
..lastAid = _controller.fromViewAid
..page = 0
..loadingState.value = LoadingState.loading()
..queryData(),
onPressed: () {
final fromViewAid = _controller.fromViewAid;
_controller
..isLocating.value = true
..lastAid = fromViewAid;
final locatedIndex = _controller
.loadingState
.value
.dataOrNull
?.indexWhere((i) => i.param == fromViewAid);
if (locatedIndex == null || locatedIndex == -1) {
_controller
..page = 0
..loadingState.value = LoadingState.loading()
..queryData();
} else {
PrimaryScrollController.of(context).jumpTo(
gridDelegate.layoutCache!
.getGeometryForChildIndex(locatedIndex)
.scrollOffset,
);
}
},
label: const Text('定位至上次观看'),
),
),
@@ -217,7 +236,7 @@ class _MemberVideoState extends State<MemberVideo>
),
),
SliverGrid(
gridDelegate: Grid.videoCardHDelegate(context),
gridDelegate: gridDelegate,
delegate: SliverChildBuilderDelegate(
(context, index) {
if (widget.type != ContributeType.season &&

View File

@@ -301,7 +301,7 @@ class _ReplyPageState extends CommonRichTextPubPageState<ReplyPage> {
height: height,
child: GridView(
padding: const EdgeInsets.only(left: 12, bottom: 12, right: 12),
gridDelegate: const SliverGridDelegateWithExtentAndRatio(
gridDelegate: SliverGridDelegateWithExtentAndRatio(
maxCrossAxisExtent: 65,
mainAxisSpacing: 12,
crossAxisSpacing: 12,