mod: 合集season数据解析

This commit is contained in:
guozhigq
2023-06-24 12:14:25 +08:00
parent 4a94b6ba8c
commit f113cdc364
7 changed files with 231 additions and 5 deletions

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/utils/utils.dart';
@ -11,7 +12,10 @@ Widget searchMbangumiPanel(BuildContext context, ctr, list) {
itemBuilder: (context, index) {
var i = list![index];
return InkWell(
onTap: () {},
onTap: () {
Get.toNamed('/video?bvid=${i.bvid}&cid=${i.cid}',
arguments: {'videoItem': i, 'heroTag': Utils.makeHeroTag(i.id)});
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
child: Row(

View File

@ -113,7 +113,6 @@ class VideoDetailController extends GetxController {
// 视频链接
queryVideoUrl() async {
print('🐶🐶🐶');
var result = await VideoHttp.videoUrl(cid: cid, bvid: bvid);
// log('result: ${result.toString()}');
if (result['status']) {

View File

@ -76,7 +76,7 @@ class VideoIntroController extends GetxController {
userLogin = user.get(UserBoxKey.userLogin) != null;
}
// 获取视频简介
// 获取视频简介&分p
Future queryVideoIntro() async {
var result = await VideoHttp.videoIntro(bvid: bvid);
if (result['status']) {

View File

@ -16,6 +16,8 @@ import 'package:pilipala/pages/video/detail/introduction/controller.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/utils/utils.dart';
import 'widgets/season.dart';
class VideoIntroPanel extends StatefulWidget {
const VideoIntroPanel({Key? key}) : super(key: key);
@ -342,7 +344,14 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
),
),
const SizedBox(height: 8),
// 点赞收藏转发
_actionGrid(context, videoIntroController),
// 合集
if (!widget.loadingStatus &&
widget.videoDetail!.ugcSeason != null) ...[
seasonPanel(widget.videoDetail!.ugcSeason!,
widget.videoDetail!.pages!.first.cid)
],
Divider(
height: 26,
color: Theme.of(context).dividerColor.withOpacity(0.1),

View File

@ -0,0 +1,99 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/models/video_detail_res.dart';
Widget seasonPanel(UgcSeason ugcSeason, cid) {
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: 15,
left: 2,
right: 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: Get.size.height - Get.size.width * 9 / 16 - 45,
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(10, 10, 10, 10),
child: Row(
children: [
Text('合集:${ugcSeason.title!}'),
const Spacer(),
Text(
'${currentIndex + 1} / ${ugcSeason.epCount}',
style: Theme.of(context).textTheme.labelSmall,
),
const SizedBox(width: 2),
const Icon(
Icons.arrow_forward_ios_outlined,
size: 13,
)
],
),
),
),
),
);
});
}

View File

@ -59,6 +59,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
setState(() {});
Wakelock.disable();
}
// 播放完成停止 or 切换下一个
if (status == PlayerStatus.completed) {
_meeduPlayerController!.pause();
}
},
);
@ -67,8 +71,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
_extendNestCtr.addListener(
() {
print(_extendNestCtr.position.pixels);
double offset = _extendNestCtr.position.pixels;
if (offset > doubleOffset) {
animationController.forward();