feat: 全屏选择合集

This commit is contained in:
guozhigq
2024-04-06 21:32:29 +08:00
parent d1e83e4d1c
commit c2a4d80c79
10 changed files with 222 additions and 65 deletions

View File

@ -18,6 +18,9 @@ import 'package:pilipala/utils/id_utils.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:share_plus/share_plus.dart';
import '../../../../common/pages_bottom_sheet.dart';
import '../../../../models/common/video_episode_type.dart';
import '../../../../utils/drawer.dart';
import '../related/index.dart';
import 'widgets/group_panel.dart';
@ -54,7 +57,7 @@ class VideoIntroController extends GetxController {
bool isPaused = false;
String heroTag = '';
late ModelResult modelResult;
late PersistentBottomSheetController? bottomSheetController;
PersistentBottomSheetController? bottomSheetController;
@override
void onInit() {
@ -562,4 +565,48 @@ class VideoIntroController extends GetxController {
hiddenEpisodeBottomSheet() {
bottomSheetController?.close();
}
// 播放器底栏 选集 回调
void showEposideHandler() {
late List episodes;
VideoEpidoesType dataType = VideoEpidoesType.videoEpisode;
if (videoDetail.value.ugcSeason != null) {
dataType = VideoEpidoesType.videoEpisode;
final List<SectionItem> sections = videoDetail.value.ugcSeason!.sections!;
for (int i = 0; i < sections.length; i++) {
final List<EpisodeItem> episodesList = sections[i].episodes!;
for (int j = 0; j < episodesList.length; j++) {
if (episodesList[j].cid == lastPlayCid.value) {
episodes = episodesList;
continue;
}
}
}
}
if (videoDetail.value.pages != null &&
videoDetail.value.pages!.length > 1) {
dataType = VideoEpidoesType.videoPart;
episodes = videoDetail.value.pages!;
}
DrawerUtils.showRightDialog(
child: EpisodeBottomSheet(
episodes: episodes,
currentCid: lastPlayCid.value,
dataType: dataType,
context: Get.context!,
sheetHeight: Get.size.height,
isFullScreen: true,
changeFucCall: (item, index) {
if (dataType == VideoEpidoesType.videoEpisode) {
changeSeasonOrbangu(IdUtils.av2bv(item.aid), item.cid, item.aid);
}
if (dataType == VideoEpidoesType.videoPart) {
changeSeasonOrbangu(bvid, item.cid, null);
}
SmartDialog.dismiss();
},
).buildShowContent(Get.context!),
);
}
}

View File

@ -373,7 +373,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
/// 点赞收藏转发
actionGrid(context, videoIntroController),
// 合集
// 合集 videoPart 简洁
if (widget.videoDetail!.ugcSeason != null) ...[
Obx(
() => SeasonPanel(
@ -383,11 +383,16 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
: widget.videoDetail!.pages!.first.cid,
sheetHeight: sheetHeight,
changeFuc: (bvid, cid, aid) =>
videoIntroController.changeSeasonOrbangu(bvid, cid, aid),
videoIntroController.changeSeasonOrbangu(
bvid,
cid,
aid,
),
videoIntroCtr: videoIntroController,
),
)
],
// 合集 videoEpisode
if (widget.videoDetail!.pages != null &&
widget.videoDetail!.pages!.length > 1) ...[
Obx(

View File

@ -60,6 +60,7 @@ class _PagesPanelState extends State<PagesPanel> {
}
void changeFucCall(item, i) async {
print('pages changeFucCall');
widget.changeFuc?.call(item.cid);
currentIndex.value = i;
_bottomSheetController?.close();

View File

@ -30,7 +30,7 @@ class SeasonPanel extends StatefulWidget {
class _SeasonPanelState extends State<SeasonPanel> {
late List<EpisodeItem> episodes;
late int cid;
late int currentIndex;
late RxInt currentIndex = (-1).obs;
final String heroTag = Get.arguments['heroTag'];
late VideoDetailController _videoDetailController;
final ItemScrollController itemScrollController = ItemScrollController();
@ -57,11 +57,10 @@ class _SeasonPanelState extends State<SeasonPanel> {
}
/// 取对应 season_id 的 episodes
currentIndex = episodes.indexWhere((EpisodeItem e) => e.cid == cid);
currentIndex.value = episodes.indexWhere((EpisodeItem e) => e.cid == cid);
_videoDetailController.cid.listen((int p0) {
cid = p0;
setState(() {});
currentIndex = episodes.indexWhere((EpisodeItem e) => e.cid == cid);
currentIndex.value = episodes.indexWhere((EpisodeItem e) => e.cid == cid);
});
}
@ -71,9 +70,8 @@ class _SeasonPanelState extends State<SeasonPanel> {
item.cid,
item.aid,
);
currentIndex = i;
currentIndex.value = i;
_bottomSheetController?.close();
setState(() {});
}
Widget buildEpisodeListItem(
@ -148,10 +146,10 @@ class _SeasonPanelState extends State<SeasonPanel> {
height: 12,
),
const SizedBox(width: 10),
Text(
'${currentIndex + 1}/${episodes.length}',
style: Theme.of(context).textTheme.labelMedium,
),
Obx(() => Text(
'${currentIndex.value + 1}/${episodes.length}',
style: Theme.of(context).textTheme.labelMedium,
)),
const SizedBox(width: 6),
const Icon(
Icons.arrow_forward_ios_outlined,

View File

@ -178,6 +178,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
if (isFullScreen) {
vdCtr.hiddenReplyReplyPanel();
videoIntroController.hiddenEpisodeBottomSheet();
vdCtr.bottomList.insert(3, BottomControlType.episode);
} else {
vdCtr.bottomList.removeAt(3);
}
});
}
@ -294,17 +297,20 @@ class _VideoDetailPageState extends State<VideoDetailPage>
() {
return !vdCtr.autoPlay.value
? const SizedBox()
: PLVideoPlayer(
controller: plPlayerController!,
headerControl: vdCtr.headerControl,
danmuWidget: Obx(
() => PlDanmaku(
: Obx(
() => PLVideoPlayer(
controller: plPlayerController!,
headerControl: vdCtr.headerControl,
danmuWidget: PlDanmaku(
key: Key(vdCtr.danmakuCid.value.toString()),
cid: vdCtr.danmakuCid.value,
playerController: plPlayerController!,
),
bottomList: vdCtr.bottomList,
showEposideCb: () => vdCtr.videoType == SearchType.video
? videoIntroController.showEposideHandler()
: bangumiIntroController.showEposideHandler(),
),
bottomList: vdCtr.bottomList,
);
},
);