mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: 重构选集功能,播放器添加选集,修复连播退全屏、无法保存已看完状态
This commit is contained in:
@@ -295,7 +295,7 @@ class BangumiIntroController extends GetxController {
|
||||
}
|
||||
|
||||
/// 列表循环或者顺序播放时,自动播放下一个
|
||||
void nextPlay() {
|
||||
bool nextPlay() {
|
||||
late List episodes;
|
||||
if (bangumiDetail.value.episodes != null) {
|
||||
episodes = bangumiDetail.value.episodes!;
|
||||
@@ -312,12 +312,15 @@ class BangumiIntroController extends GetxController {
|
||||
nextIndex = 0;
|
||||
}
|
||||
}
|
||||
if (nextIndex <= episodes.length - 1 &&
|
||||
platRepeat == PlayRepeat.listOrder) {}
|
||||
if (nextIndex == episodes.length - 1 &&
|
||||
platRepeat == PlayRepeat.listOrder) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int cid = episodes[nextIndex].cid!;
|
||||
String bvid = episodes[nextIndex].bvid!;
|
||||
int aid = episodes[nextIndex].aid!;
|
||||
changeSeasonOrbangu(bvid, cid, aid);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ class _BangumiIntroPanelState extends State<BangumiIntroPanel>
|
||||
_futureBuilderFuture = bangumiIntroController.queryBangumiIntro();
|
||||
videoDetailCtr.cid.listen((int p0) {
|
||||
cid = p0;
|
||||
if (!mounted) return;
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
@@ -138,7 +139,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
||||
print('cid: $cid');
|
||||
videoDetailCtr.cid.listen((p0) {
|
||||
cid = p0;
|
||||
print('cid: $cid');
|
||||
if (!mounted) return;
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
@@ -371,8 +372,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
||||
(bangumiItem != null
|
||||
? bangumiItem!.episodes!.first.cid
|
||||
: widget.bangumiDetail!.episodes!.first.cid),
|
||||
changeFuc: (bvid, cid, aid) => bangumiIntroController
|
||||
.changeSeasonOrbangu(bvid, cid, aid),
|
||||
changeFuc: bangumiIntroController.changeSeasonOrbangu,
|
||||
)
|
||||
],
|
||||
],
|
||||
|
||||
@@ -6,20 +6,19 @@ import 'package:PiliPalaX/models/bangumi/info.dart';
|
||||
import 'package:PiliPalaX/pages/video/detail/index.dart';
|
||||
import 'package:PiliPalaX/utils/storage.dart';
|
||||
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
||||
|
||||
import '../../../utils/utils.dart';
|
||||
import 'package:PiliPalaX/common/widgets/list_sheet.dart';
|
||||
|
||||
class BangumiPanel extends StatefulWidget {
|
||||
const BangumiPanel({
|
||||
super.key,
|
||||
required this.pages,
|
||||
this.cid,
|
||||
this.changeFuc,
|
||||
required this.changeFuc,
|
||||
});
|
||||
|
||||
final List<EpisodeItem> pages;
|
||||
final int? cid;
|
||||
final Function? changeFuc;
|
||||
final Function changeFuc;
|
||||
|
||||
@override
|
||||
State<BangumiPanel> createState() => _BangumiPanelState();
|
||||
@@ -52,8 +51,9 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
||||
|
||||
videoDetailCtr.cid.listen((int p0) {
|
||||
cid = p0;
|
||||
setState(() {});
|
||||
currentIndex = widget.pages.indexWhere((EpisodeItem e) => e.cid == cid);
|
||||
if (!mounted) return;
|
||||
setState(() {});
|
||||
scrollToIndex();
|
||||
});
|
||||
}
|
||||
@@ -65,131 +65,20 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget buildPageListItem(
|
||||
EpisodeItem page,
|
||||
int index,
|
||||
bool isCurrentIndex,
|
||||
) {
|
||||
Color primary = Theme.of(context).colorScheme.primary;
|
||||
return ListTile(
|
||||
onTap: () {
|
||||
Get.back();
|
||||
setState(() {
|
||||
changeFucCall(page, index);
|
||||
});
|
||||
},
|
||||
dense: false,
|
||||
leading: isCurrentIndex
|
||||
? Image.asset(
|
||||
'assets/images/live.png',
|
||||
color: primary,
|
||||
height: 12,
|
||||
semanticLabel: "正在播放:",
|
||||
)
|
||||
: null,
|
||||
title: Text(
|
||||
'第' + (page.title ?? '${index + 1}') + '话 ${page.longTitle!}',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isCurrentIndex
|
||||
? primary
|
||||
: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
trailing: page.badge != null && page.badge == '会员'
|
||||
? Image.asset(
|
||||
'assets/images/big-vip.png',
|
||||
height: 20,
|
||||
semanticLabel: "大会员",
|
||||
)
|
||||
: Text(page.badge ?? ""),
|
||||
);
|
||||
}
|
||||
|
||||
void showBangumiPanel() {
|
||||
showBottomSheet(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
// await Future.delayed(const Duration(milliseconds: 200));
|
||||
// listViewScrollCtr_2.animateTo(currentIndex * 56,
|
||||
// duration: const Duration(milliseconds: 500),
|
||||
// curve: Curves.easeInOut);
|
||||
itemScrollController.jumpTo(index: currentIndex);
|
||||
});
|
||||
// 在这里使用 setState 更新状态
|
||||
return Container(
|
||||
height: Utils.getSheetHeight(context),
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
child: Column(
|
||||
children: [
|
||||
AppBar(
|
||||
toolbarHeight: 45,
|
||||
automaticallyImplyLeading: false,
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'合集(${widget.pages.length})',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
IconButton(
|
||||
tooltip: '关闭',
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
titleSpacing: 10,
|
||||
),
|
||||
Expanded(
|
||||
child: Material(
|
||||
child: ScrollablePositionedList.builder(
|
||||
itemCount: widget.pages.length + 1,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
bool isLastItem = index == widget.pages.length;
|
||||
bool isCurrentIndex = currentIndex == index;
|
||||
return isLastItem
|
||||
? SizedBox(
|
||||
height:
|
||||
MediaQuery.of(context).padding.bottom +
|
||||
50,
|
||||
)
|
||||
: buildPageListItem(
|
||||
widget.pages[index],
|
||||
index,
|
||||
isCurrentIndex,
|
||||
);
|
||||
},
|
||||
itemScrollController: itemScrollController,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void changeFucCall(item, i) async {
|
||||
if (item.badge != null && item.badge == '会员' && vipStatus != 1) {
|
||||
SmartDialog.showToast('需要大会员');
|
||||
return;
|
||||
}
|
||||
await widget.changeFuc!(
|
||||
item.bvid,
|
||||
item.cid,
|
||||
item.aid,
|
||||
);
|
||||
currentIndex = i;
|
||||
setState(() {});
|
||||
scrollToIndex();
|
||||
}
|
||||
// void changeFucCall(item, i) async {
|
||||
// if (item.badge != null && item.badge == '会员' && vipStatus != 1) {
|
||||
// SmartDialog.showToast('需要大会员');
|
||||
// return;
|
||||
// }
|
||||
// await widget.changeFuc!(
|
||||
// item.bvid,
|
||||
// item.cid,
|
||||
// item.aid,
|
||||
// );
|
||||
// currentIndex = i;
|
||||
// setState(() {});
|
||||
// scrollToIndex();
|
||||
// }
|
||||
|
||||
void scrollToIndex() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
@@ -226,7 +115,16 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
||||
style: ButtonStyle(
|
||||
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
||||
),
|
||||
onPressed: () => showBangumiPanel(),
|
||||
onPressed: () {
|
||||
ListSheet(
|
||||
episodes: widget.pages,
|
||||
bvid: widget.pages[currentIndex].bvid!,
|
||||
aid: widget.pages[currentIndex].aid!,
|
||||
currentCid: cid,
|
||||
changeFucCall: widget.changeFuc,
|
||||
context: context)
|
||||
.buildShowBottomSheet();
|
||||
},
|
||||
child: Text(
|
||||
'全${widget.pages.length}话',
|
||||
style: const TextStyle(fontSize: 13),
|
||||
@@ -252,7 +150,23 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: InkWell(
|
||||
onTap: () => changeFucCall(widget.pages[i], i),
|
||||
onTap: () {
|
||||
if (widget.pages[i].badge != null &&
|
||||
widget.pages[i].badge == '会员' &&
|
||||
vipStatus != 1) {
|
||||
SmartDialog.showToast('需要大会员');
|
||||
return;
|
||||
}
|
||||
widget.changeFuc(
|
||||
widget.pages[i].bvid,
|
||||
widget.pages[i].cid,
|
||||
widget.pages[i].aid,
|
||||
);
|
||||
// currentIndex = i;
|
||||
// setState(() {});
|
||||
// scrollToIndex();
|
||||
},
|
||||
//changeFucCall(widget.pages[i], i),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8, horizontal: 10),
|
||||
|
||||
@@ -532,7 +532,7 @@ class VideoIntroController extends GetxController {
|
||||
}
|
||||
|
||||
/// 列表循环或者顺序播放时,自动播放下一个
|
||||
void nextPlay() {
|
||||
bool nextPlay() {
|
||||
final List episodes = [];
|
||||
bool isPages = false;
|
||||
if (videoDetail.value.ugcSeason != null) {
|
||||
@@ -561,13 +561,14 @@ class VideoIntroController extends GetxController {
|
||||
nextIndex = 0;
|
||||
}
|
||||
if (platRepeat == PlayRepeat.listOrder) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final int cid = episodes[nextIndex].cid!;
|
||||
final String rBvid = isPages ? bvid : episodes[nextIndex].bvid;
|
||||
final int rAid = isPages ? IdUtils.bv2av(bvid) : episodes[nextIndex].aid!;
|
||||
changeSeasonOrbangu(rBvid, cid, rAid);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 设置关注分组
|
||||
|
||||
@@ -374,8 +374,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
cid: videoIntroController.lastPlayCid.value != 0
|
||||
? videoIntroController.lastPlayCid.value
|
||||
: widget.videoDetail!.pages!.first.cid,
|
||||
changeFuc: (bvid, cid, aid) => videoIntroController
|
||||
.changeSeasonOrbangu(bvid, cid, aid),
|
||||
changeFuc: videoIntroController.changeSeasonOrbangu,
|
||||
),
|
||||
)
|
||||
],
|
||||
@@ -385,11 +384,8 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
Obx(() => PagesPanel(
|
||||
pages: widget.videoDetail!.pages!,
|
||||
cid: videoIntroController.lastPlayCid.value,
|
||||
changeFuc: (cid) =>
|
||||
videoIntroController.changeSeasonOrbangu(
|
||||
videoIntroController.bvid,
|
||||
cid,
|
||||
IdUtils.bv2av(videoIntroController.bvid)),
|
||||
bvid: videoIntroController.bvid,
|
||||
changeFuc: videoIntroController.changeSeasonOrbangu,
|
||||
))
|
||||
],
|
||||
GestureDetector(
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPalaX/common/widgets/list_sheet.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPalaX/models/video_detail_res.dart';
|
||||
import 'package:PiliPalaX/pages/video/detail/index.dart';
|
||||
|
||||
import '../../../../../utils/utils.dart';
|
||||
import '../../../../../utils/id_utils.dart';
|
||||
|
||||
class PagesPanel extends StatefulWidget {
|
||||
const PagesPanel({
|
||||
super.key,
|
||||
required this.pages,
|
||||
this.cid,
|
||||
this.changeFuc,
|
||||
required this.bvid,
|
||||
required this.changeFuc,
|
||||
});
|
||||
final List<Part> pages;
|
||||
final int? cid;
|
||||
final Function? changeFuc;
|
||||
final String bvid;
|
||||
final Function changeFuc;
|
||||
|
||||
@override
|
||||
State<PagesPanel> createState() => _PagesPanelState();
|
||||
@@ -28,7 +31,6 @@ class _PagesPanelState extends State<PagesPanel> {
|
||||
late int currentIndex;
|
||||
final String heroTag = Get.arguments['heroTag'];
|
||||
late VideoDetailController _videoDetailController;
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
final ScrollController _scrollController2 = ScrollController();
|
||||
|
||||
@override
|
||||
@@ -40,66 +42,27 @@ class _PagesPanelState extends State<PagesPanel> {
|
||||
currentIndex = episodes.indexWhere((Part e) => e.cid == cid);
|
||||
_videoDetailController.cid.listen((int p0) {
|
||||
cid = p0;
|
||||
setState(() {});
|
||||
currentIndex = episodes.indexWhere((Part e) => e.cid == cid);
|
||||
if (!mounted) return;
|
||||
const double itemWidth = 150; // 每个列表项的宽度
|
||||
final double targetOffset = min(
|
||||
(currentIndex * itemWidth) - (itemWidth / 2),
|
||||
_scrollController2.position.maxScrollExtent);
|
||||
// 滑动至目标位置
|
||||
_scrollController2.animateTo(
|
||||
targetOffset,
|
||||
duration: const Duration(milliseconds: 300), // 滑动动画持续时间
|
||||
curve: Curves.easeInOut, // 滑动动画曲线
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void changeFucCall(item, i) async {
|
||||
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(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollController.dispose();
|
||||
_scrollController2.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget buildEpisodeListItem(
|
||||
Part episode,
|
||||
int index,
|
||||
bool isCurrentIndex,
|
||||
) {
|
||||
Color primary = Theme.of(context).colorScheme.primary;
|
||||
return ListTile(
|
||||
onTap: () {
|
||||
changeFucCall(episode, index);
|
||||
Get.back();
|
||||
},
|
||||
dense: false,
|
||||
leading: isCurrentIndex
|
||||
? Image.asset(
|
||||
'assets/images/live.png',
|
||||
color: primary,
|
||||
height: 12,
|
||||
semanticLabel: "正在播放:",
|
||||
)
|
||||
: null,
|
||||
title: Text(
|
||||
episode.pagePart!,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isCurrentIndex
|
||||
? primary
|
||||
: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
@@ -128,83 +91,14 @@ class _PagesPanelState extends State<PagesPanel> {
|
||||
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
||||
),
|
||||
onPressed: () {
|
||||
showBottomSheet(
|
||||
ListSheet(
|
||||
episodes: episodes,
|
||||
bvid: widget.bvid,
|
||||
aid: IdUtils.bv2av(widget.bvid),
|
||||
currentCid: cid,
|
||||
changeFucCall: widget.changeFuc,
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return StatefulBuilder(builder:
|
||||
(BuildContext context, StateSetter setState) {
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) async {
|
||||
await Future.delayed(
|
||||
const Duration(milliseconds: 200));
|
||||
_scrollController.jumpTo(currentIndex * 56);
|
||||
});
|
||||
return Container(
|
||||
height: Utils.getSheetHeight(context),
|
||||
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(
|
||||
tooltip: '关闭',
|
||||
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(
|
||||
controller: _scrollController,
|
||||
itemCount: episodes.length + 1,
|
||||
itemBuilder:
|
||||
(BuildContext context, int index) {
|
||||
bool isLastItem =
|
||||
index == episodes.length;
|
||||
bool isCurrentIndex =
|
||||
currentIndex == index;
|
||||
return isLastItem
|
||||
? SizedBox(
|
||||
height: MediaQuery.of(context)
|
||||
.padding
|
||||
.bottom +
|
||||
20,
|
||||
)
|
||||
: buildEpisodeListItem(
|
||||
episodes[index],
|
||||
index,
|
||||
isCurrentIndex,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
).buildShowBottomSheet();
|
||||
},
|
||||
child: Text(
|
||||
'共${widget.pages.length}集',
|
||||
@@ -233,7 +127,10 @@ class _PagesPanelState extends State<PagesPanel> {
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: InkWell(
|
||||
onTap: () => changeFucCall(widget.pages[i], i),
|
||||
onTap: () => {
|
||||
widget.changeFuc(widget.bvid, widget.pages[i].cid,
|
||||
IdUtils.bv2av(widget.bvid))
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8, horizontal: 8),
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
|
||||
import 'package:PiliPalaX/common/widgets/list_sheet.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPalaX/models/video_detail_res.dart';
|
||||
import 'package:PiliPalaX/pages/video/detail/index.dart';
|
||||
import 'package:PiliPalaX/utils/id_utils.dart';
|
||||
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
||||
|
||||
import '../../../../../utils/utils.dart';
|
||||
|
||||
class SeasonPanel extends StatefulWidget {
|
||||
const SeasonPanel({
|
||||
super.key,
|
||||
required this.ugcSeason,
|
||||
this.cid,
|
||||
this.changeFuc,
|
||||
required this.changeFuc,
|
||||
});
|
||||
final UgcSeason ugcSeason;
|
||||
final int? cid;
|
||||
final Function? changeFuc;
|
||||
final Function changeFuc;
|
||||
|
||||
@override
|
||||
State<SeasonPanel> createState() => _SeasonPanelState();
|
||||
@@ -30,7 +27,6 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
||||
final String heroTag = Get.arguments['heroTag'];
|
||||
late VideoDetailController _videoDetailController;
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
final ItemScrollController itemScrollController = ItemScrollController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -62,21 +58,22 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
||||
currentIndex = episodes!.indexWhere((EpisodeItem e) => e.cid == cid);
|
||||
_videoDetailController.cid.listen((int p0) {
|
||||
cid = p0;
|
||||
setState(() {});
|
||||
currentIndex = episodes!.indexWhere((EpisodeItem e) => e.cid == cid);
|
||||
if (!mounted) return;
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
void changeFucCall(item, int i) async {
|
||||
await widget.changeFuc!(
|
||||
IdUtils.av2bv(item.aid),
|
||||
item.cid,
|
||||
item.aid,
|
||||
);
|
||||
currentIndex = i;
|
||||
Get.back();
|
||||
setState(() {});
|
||||
}
|
||||
// void changeFucCall(item, int i) async {
|
||||
// await widget.changeFuc!(
|
||||
// IdUtils.av2bv(item.aid),
|
||||
// item.cid,
|
||||
// item.aid,
|
||||
// );
|
||||
// currentIndex = i;
|
||||
// Get.back();
|
||||
// setState(() {});
|
||||
// }
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@@ -84,35 +81,6 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget buildEpisodeListItem(
|
||||
EpisodeItem episode,
|
||||
int index,
|
||||
bool isCurrentIndex,
|
||||
) {
|
||||
Color primary = Theme.of(context).colorScheme.primary;
|
||||
return ListTile(
|
||||
onTap: () => changeFucCall(episode, index),
|
||||
dense: false,
|
||||
leading: isCurrentIndex
|
||||
? Image.asset(
|
||||
'assets/images/live.png',
|
||||
color: primary,
|
||||
height: 12,
|
||||
semanticLabel: "正在播放:",
|
||||
)
|
||||
: null,
|
||||
title: Text(
|
||||
episode.title!,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isCurrentIndex
|
||||
? primary
|
||||
: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (episodes == null) {
|
||||
@@ -131,75 +99,16 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: InkWell(
|
||||
onTap: () => showBottomSheet(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
itemScrollController.jumpTo(index: currentIndex);
|
||||
});
|
||||
return Container(
|
||||
height: Utils.getSheetHeight(context),
|
||||
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(
|
||||
tooltip: '关闭',
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
height: 1,
|
||||
color:
|
||||
Theme.of(context).dividerColor.withOpacity(0.1),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).padding.bottom),
|
||||
child: Material(
|
||||
child: ScrollablePositionedList.builder(
|
||||
itemCount: episodes!.length + 1,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
bool isLastItem = index == episodes!.length;
|
||||
bool isCurrentIndex = currentIndex == index;
|
||||
return isLastItem
|
||||
? SizedBox(
|
||||
height: MediaQuery.of(context)
|
||||
.padding
|
||||
.bottom +
|
||||
20,
|
||||
)
|
||||
: buildEpisodeListItem(
|
||||
episodes![index],
|
||||
index,
|
||||
isCurrentIndex,
|
||||
);
|
||||
},
|
||||
itemScrollController: itemScrollController,
|
||||
),
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
onTap: () {
|
||||
ListSheet(
|
||||
episodes: episodes,
|
||||
// bvid: IdUtils.av2bv(episodes!.first.aid!),
|
||||
// aid: episodes!.first.aid!,
|
||||
currentCid: cid,
|
||||
changeFucCall: widget.changeFuc,
|
||||
context: context)
|
||||
.buildShowBottomSheet();
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(8, 12, 8, 12),
|
||||
child: Row(
|
||||
|
||||
@@ -146,28 +146,30 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
void playerListener(PlayerStatus? status) async {
|
||||
playerStatus = status!;
|
||||
if (status == PlayerStatus.completed) {
|
||||
// 结束播放退出全屏
|
||||
if (autoExitFullcreen) {
|
||||
plPlayerController!.triggerFullScreen(status: false);
|
||||
}
|
||||
shutdownTimerService.handleWaitingFinished();
|
||||
|
||||
bool notExitFlag = false;
|
||||
/// 顺序播放 列表循环
|
||||
if (plPlayerController!.playRepeat != PlayRepeat.pause &&
|
||||
plPlayerController!.playRepeat != PlayRepeat.singleCycle) {
|
||||
if (videoDetailController.videoType == SearchType.video) {
|
||||
videoIntroController.nextPlay();
|
||||
notExitFlag = videoIntroController.nextPlay();
|
||||
}
|
||||
if (videoDetailController.videoType == SearchType.media_bangumi) {
|
||||
bangumiIntroController.nextPlay();
|
||||
notExitFlag = bangumiIntroController.nextPlay();
|
||||
}
|
||||
}
|
||||
|
||||
/// 单个循环
|
||||
if (plPlayerController!.playRepeat == PlayRepeat.singleCycle) {
|
||||
notExitFlag = true;
|
||||
plPlayerController!.seekTo(Duration.zero);
|
||||
plPlayerController!.play();
|
||||
}
|
||||
|
||||
// 结束播放退出全屏
|
||||
if (!notExitFlag && autoExitFullcreen) {
|
||||
plPlayerController!.triggerFullScreen(status: false);
|
||||
}
|
||||
// 播放完展示控制栏
|
||||
if (videoDetailController.floating != null) {
|
||||
PiPStatus currentStatus =
|
||||
@@ -263,6 +265,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
// 离开当前页面时
|
||||
void didPushNext() async {
|
||||
_bufferedListener?.cancel();
|
||||
|
||||
/// 开启
|
||||
if (setting.get(SettingBoxKey.enableAutoBrightness, defaultValue: false)
|
||||
as bool) {
|
||||
@@ -449,6 +452,19 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
: PLVideoPlayer(
|
||||
controller:
|
||||
plPlayerController!,
|
||||
videoIntroController:
|
||||
videoDetailController
|
||||
.videoType ==
|
||||
SearchType.video
|
||||
? videoIntroController
|
||||
: null,
|
||||
bangumiIntroController:
|
||||
videoDetailController
|
||||
.videoType ==
|
||||
SearchType
|
||||
.media_bangumi
|
||||
? bangumiIntroController
|
||||
: null,
|
||||
headerControl:
|
||||
videoDetailController
|
||||
.headerControl,
|
||||
@@ -702,6 +718,20 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
: PLVideoPlayer(
|
||||
controller:
|
||||
plPlayerController!,
|
||||
videoIntroController:
|
||||
videoDetailController
|
||||
.videoType ==
|
||||
SearchType
|
||||
.video
|
||||
? videoIntroController
|
||||
: null,
|
||||
bangumiIntroController:
|
||||
videoDetailController
|
||||
.videoType ==
|
||||
SearchType
|
||||
.media_bangumi
|
||||
? bangumiIntroController
|
||||
: null,
|
||||
headerControl:
|
||||
videoDetailController
|
||||
.headerControl,
|
||||
@@ -875,6 +905,14 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
? const SizedBox()
|
||||
: PLVideoPlayer(
|
||||
controller: plPlayerController!,
|
||||
videoIntroController:
|
||||
videoDetailController.videoType == SearchType.video
|
||||
? videoIntroController
|
||||
: null,
|
||||
bangumiIntroController:
|
||||
videoDetailController.videoType == SearchType.media_bangumi
|
||||
? bangumiIntroController
|
||||
: null,
|
||||
headerControl: HeaderControl(
|
||||
controller: plPlayerController,
|
||||
videoDetailCtr: videoDetailController,
|
||||
|
||||
Reference in New Issue
Block a user