mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix: 分p视频新增列表滑动
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPalaX/models/video_detail_res.dart';
|
||||
@@ -27,6 +29,7 @@ class _PagesPanelState extends State<PagesPanel> {
|
||||
final String heroTag = Get.arguments['heroTag'];
|
||||
late VideoDetailController _videoDetailController;
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
final ScrollController _scrollController2 = ScrollController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -43,8 +46,17 @@ class _PagesPanelState extends State<PagesPanel> {
|
||||
}
|
||||
|
||||
void changeFucCall(item, i) async {
|
||||
await widget.changeFuc!(
|
||||
item.cid,
|
||||
await widget.changeFuc!(item.cid);
|
||||
|
||||
const double itemWidth = 150; // 每个列表项的宽度
|
||||
final double targetOffset = min((i * itemWidth) - (itemWidth / 2),
|
||||
_scrollController2.position.maxScrollExtent);
|
||||
|
||||
// 滑动至目标位置
|
||||
_scrollController2.animateTo(
|
||||
targetOffset,
|
||||
duration: const Duration(milliseconds: 300), // 滑动动画持续时间
|
||||
curve: Curves.easeInOut, // 滑动动画曲线
|
||||
);
|
||||
currentIndex = i;
|
||||
setState(() {});
|
||||
@@ -207,6 +219,7 @@ class _PagesPanelState extends State<PagesPanel> {
|
||||
height: 35,
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
child: ListView.builder(
|
||||
controller: _scrollController2,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: widget.pages.length,
|
||||
itemExtent: 150,
|
||||
|
||||
Reference in New Issue
Block a user