feat: 视频切换分p
This commit is contained in:
@ -8,6 +8,7 @@ import 'package:pilipala/http/video.dart';
|
||||
import 'package:pilipala/models/user/fav_folder.dart';
|
||||
import 'package:pilipala/models/video_detail_res.dart';
|
||||
import 'package:pilipala/pages/video/detail/controller.dart';
|
||||
import 'package:pilipala/pages/video/detail/reply/index.dart';
|
||||
import 'package:pilipala/utils/feed_back.dart';
|
||||
import 'package:pilipala/utils/id_utils.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
@ -391,11 +392,22 @@ class VideoIntroController extends GetxController {
|
||||
}
|
||||
|
||||
// 修改分P或番剧分集
|
||||
Future changeSeasonOrbangu(bvid, cid) async {
|
||||
var _videoDetailCtr =
|
||||
Future changeSeasonOrbangu(bvid, cid, aid) async {
|
||||
// 重新获取视频资源
|
||||
VideoDetailController videoDetailCtr =
|
||||
Get.find<VideoDetailController>(tag: Get.arguments['heroTag']);
|
||||
_videoDetailCtr.bvid = bvid;
|
||||
_videoDetailCtr.cid = cid;
|
||||
_videoDetailCtr.queryVideoUrl();
|
||||
videoDetailCtr.bvid = bvid;
|
||||
videoDetailCtr.cid = cid;
|
||||
videoDetailCtr.queryVideoUrl();
|
||||
// 重新请求评论
|
||||
try {
|
||||
/// 未渲染回复组件时可能异常
|
||||
VideoReplyController videoReplyCtr =
|
||||
Get.find<VideoReplyController>(tag: Get.arguments['heroTag']);
|
||||
videoReplyCtr.aid = aid;
|
||||
videoReplyCtr.queryReplyList(type: 'init');
|
||||
} catch (_) {}
|
||||
this.bvid = bvid;
|
||||
await queryVideoIntro();
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,11 @@ class _VideoIntroPanelState extends State<VideoIntroPanel>
|
||||
if (snapshot.data['status']) {
|
||||
// 请求成功
|
||||
// return _buildView(context, false, videoDetail);
|
||||
return VideoInfo(loadingStatus: false, videoDetail: videoDetail);
|
||||
return Obx(
|
||||
() => VideoInfo(
|
||||
loadingStatus: false,
|
||||
videoDetail: videoIntroController.videoDetail.value),
|
||||
);
|
||||
} else {
|
||||
// 请求错误
|
||||
return HttpError(
|
||||
@ -235,8 +239,13 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
// 合集
|
||||
if (!widget.loadingStatus &&
|
||||
widget.videoDetail!.ugcSeason != null) ...[
|
||||
seasonPanel(widget.videoDetail!.ugcSeason!,
|
||||
widget.videoDetail!.pages!.first.cid, sheetHeight)
|
||||
SeasonPanel(
|
||||
ugcSeason: widget.videoDetail!.ugcSeason!,
|
||||
cid: widget.videoDetail!.pages!.first.cid,
|
||||
sheetHeight: sheetHeight,
|
||||
changeFuc: (bvid, cid, aid) => videoIntroController
|
||||
.changeSeasonOrbangu(bvid, cid, aid),
|
||||
)
|
||||
],
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
|
@ -1,111 +1,263 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/models/video_detail_res.dart';
|
||||
import 'package:pilipala/utils/id_utils.dart';
|
||||
|
||||
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),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
class SeasonPanel extends StatefulWidget {
|
||||
final UgcSeason ugcSeason;
|
||||
final int? cid;
|
||||
final double? sheetHeight;
|
||||
final Function? changeFuc;
|
||||
|
||||
const SeasonPanel({
|
||||
super.key,
|
||||
required this.ugcSeason,
|
||||
this.cid,
|
||||
this.sheetHeight,
|
||||
this.changeFuc,
|
||||
});
|
||||
|
||||
@override
|
||||
State<SeasonPanel> createState() => _SeasonPanelState();
|
||||
}
|
||||
|
||||
class _SeasonPanelState extends State<SeasonPanel> {
|
||||
late List<EpisodeItem> episodes;
|
||||
late int currentIndex;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
episodes = widget.ugcSeason.sections!.first.episodes!;
|
||||
currentIndex = episodes.indexWhere((e) => e.cid == widget.cid);
|
||||
}
|
||||
|
||||
void changeFucCall(item, i) async {
|
||||
await widget.changeFuc!(
|
||||
IdUtils.av2bv(item.aid),
|
||||
item.cid,
|
||||
item.aid,
|
||||
);
|
||||
Get.back();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Builder(builder: (context) {
|
||||
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: widget.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: () =>
|
||||
changeFucCall(episodes[index], index),
|
||||
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(
|
||||
'合集:${widget.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}/${widget.ugcSeason.epCount}',
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
const Icon(
|
||||
Icons.arrow_forward_ios_outlined,
|
||||
size: 13,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
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,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 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,
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// });
|
||||
// }
|
||||
|
Reference in New Issue
Block a user