fix: 视频合集,向下滑动 ui 显示问题 issues #314

This commit is contained in:
guozhigq
2023-12-24 19:39:48 +08:00
parent cd55914b36
commit 579a4f2a81
4 changed files with 76 additions and 179 deletions

View File

@ -3,6 +3,7 @@ import 'package:get/get.dart';
import 'package:pilipala/models/video_detail_res.dart';
import 'package:pilipala/pages/video/detail/index.dart';
import 'package:pilipala/utils/id_utils.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
class SeasonPanel extends StatefulWidget {
final UgcSeason ugcSeason;
@ -29,6 +30,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
String heroTag = Get.arguments['heroTag'];
late VideoDetailController _videoDetailController;
final ScrollController _scrollController = ScrollController();
final ItemScrollController itemScrollController = ItemScrollController();
@override
void initState() {
@ -101,8 +103,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
WidgetsBinding.instance.addPostFrameCallback((_) async {
await Future.delayed(const Duration(milliseconds: 200));
_scrollController.jumpTo(currentIndex * 56);
itemScrollController.jumpTo(index: currentIndex);
});
return Container(
height: widget.sheetHeight,
@ -133,38 +134,34 @@ class _SeasonPanelState extends State<SeasonPanel> {
),
Expanded(
child: Material(
child: ListView.builder(
controller: _scrollController,
child: ScrollablePositionedList.builder(
itemCount: episodes.length,
itemBuilder: (context, index) {
return ListTile(
onTap: () =>
changeFucCall(episodes[index], index),
dense: false,
leading: index == currentIndex
? Image.asset(
'assets/images/live.gif',
color: Theme.of(context)
.colorScheme
.primary,
height: 12,
)
: null,
title: Text(
episodes[index].title!,
style: TextStyle(
fontSize: 14,
color: index == currentIndex
? Theme.of(context)
.colorScheme
.primary
: Theme.of(context)
.colorScheme
.onSurface,
),
itemBuilder: (context, index) => ListTile(
onTap: () =>
changeFucCall(episodes[index], index),
dense: false,
leading: index == currentIndex
? Image.asset(
'assets/images/live.gif',
color: Theme.of(context)
.colorScheme
.primary,
height: 12,
)
: null,
title: Text(
episodes[index].title!,
style: TextStyle(
fontSize: 14,
color: index == currentIndex
? Theme.of(context).colorScheme.primary
: Theme.of(context)
.colorScheme
.onSurface,
),
);
},
),
),
itemScrollController: itemScrollController,
),
),
),
@ -210,112 +207,3 @@ class _SeasonPanelState extends State<SeasonPanel> {
});
}
}
// Widget seasonPanel(UgcSeason ugcSeason, cid, sheetHeight) {
// return Builder(builder: (context) {
// List<EpisodeItem> episodes = ugcSeason.sections!.first.episodes!;
// int currentIndex = episodes.indexWhere((e) => e.cid == cid);
// return Container(
// margin: const EdgeInsets.only(
// top: 8,
// left: 2,
// right: 2,
// bottom: 2,
// ),
// child: Material(
// color: Theme.of(context).colorScheme.onInverseSurface,
// borderRadius: BorderRadius.circular(6),
// clipBehavior: Clip.hardEdge,
// child: InkWell(
// onTap: () => showBottomSheet(
// context: context,
// builder: (_) => Container(
// height: sheetHeight,
// color: Theme.of(context).colorScheme.background,
// child: Column(
// children: [
// Container(
// height: 45,
// padding: const EdgeInsets.only(left: 14, right: 14),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text(
// '合集(${episodes.length}',
// style: Theme.of(context).textTheme.titleMedium,
// ),
// IconButton(
// icon: const Icon(Icons.close),
// onPressed: () => Navigator.pop(context),
// ),
// ],
// ),
// ),
// Divider(
// height: 1,
// color: Theme.of(context).dividerColor.withOpacity(0.1),
// ),
// Expanded(
// child: Material(
// child: ListView.builder(
// itemCount: episodes.length,
// itemBuilder: (context, index) {
// return InkWell(
// onTap: () {},
// child: Padding(
// padding: const EdgeInsets.only(
// top: 10, bottom: 10, left: 15, right: 15),
// child: Text(
// episodes[index].title!,
// style: TextStyle(
// color: index == currentIndex
// ? Theme.of(context).colorScheme.primary
// : Theme.of(context)
// .colorScheme
// .onSurface),
// ),
// ),
// );
// },
// ),
// ),
// ),
// ],
// ),
// ),
// ),
// child: Padding(
// padding: const EdgeInsets.fromLTRB(8, 12, 8, 12),
// child: Row(
// children: [
// Expanded(
// child: Text(
// '合集:${ugcSeason.title!}',
// style: Theme.of(context).textTheme.labelMedium,
// overflow: TextOverflow.ellipsis,
// ),
// ),
// const SizedBox(width: 15),
// Image.asset(
// 'assets/images/live.gif',
// color: Theme.of(context).colorScheme.primary,
// height: 12,
// ),
// const SizedBox(width: 10),
// Text(
// '${currentIndex + 1}/${ugcSeason.epCount}',
// style: Theme.of(context).textTheme.labelMedium,
// ),
// const SizedBox(width: 6),
// const Icon(
// Icons.arrow_forward_ios_outlined,
// size: 13,
// )
// ],
// ),
// ),
// ),
// ),
// );
// });
// }