mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix: play all
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -127,22 +127,30 @@ class FavDetailController extends MultiSelectController {
|
||||
|
||||
Future toViewPlayAll() async {
|
||||
if (loadingState.value is Success) {
|
||||
final FavDetailItemData firstItem =
|
||||
(loadingState.value as Success).response.first;
|
||||
final String heroTag = Utils.makeHeroTag(firstItem.bvid);
|
||||
Get.toNamed(
|
||||
'/video?bvid=${firstItem.bvid}&cid=${firstItem.cid}',
|
||||
arguments: {
|
||||
'videoItem': firstItem,
|
||||
'heroTag': heroTag,
|
||||
'sourceType': 'fav',
|
||||
'mediaId': item.value.id,
|
||||
'oid': firstItem.id,
|
||||
'favTitle': item.value.title,
|
||||
// 'favInfo': favInfo,
|
||||
'count': item.value.mediaCount,
|
||||
},
|
||||
);
|
||||
List<FavDetailItemData> list = (loadingState.value as Success).response;
|
||||
for (FavDetailItemData element in list) {
|
||||
if (element.cid == null) {
|
||||
continue;
|
||||
} else {
|
||||
if (element.bvid != list.first.bvid) {
|
||||
SmartDialog.showToast('已跳过不支持播放的视频');
|
||||
}
|
||||
final String heroTag = Utils.makeHeroTag(element.bvid);
|
||||
Get.toNamed(
|
||||
'/video?bvid=${element.bvid}&cid=${element.cid}',
|
||||
arguments: {
|
||||
'videoItem': element,
|
||||
'heroTag': heroTag,
|
||||
'sourceType': 'fav',
|
||||
'mediaId': item.value.id,
|
||||
'oid': element.id,
|
||||
'favTitle': item.value.title,
|
||||
'count': item.value.mediaCount,
|
||||
},
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,18 +167,27 @@ class LaterController extends MultiSelectController {
|
||||
// 稍后再看播放全部
|
||||
Future toViewPlayAll() async {
|
||||
if (loadingState.value is Success) {
|
||||
final HotVideoItemModel firstItem =
|
||||
(loadingState.value as Success).response.first;
|
||||
final String heroTag = Utils.makeHeroTag(firstItem.bvid);
|
||||
Get.toNamed(
|
||||
'/video?bvid=${firstItem.bvid}&cid=${firstItem.cid}',
|
||||
arguments: {
|
||||
'videoItem': firstItem,
|
||||
'heroTag': heroTag,
|
||||
'sourceType': 'watchLater',
|
||||
'count': (loadingState.value as Success).response.length,
|
||||
},
|
||||
);
|
||||
List<HotVideoItemModel> list = (loadingState.value as Success).response;
|
||||
for (HotVideoItemModel item in list) {
|
||||
if (item.cid == null) {
|
||||
continue;
|
||||
} else {
|
||||
if (item.bvid != list.first.bvid) {
|
||||
SmartDialog.showToast('已跳过不支持播放的视频');
|
||||
}
|
||||
final String heroTag = Utils.makeHeroTag(item.bvid);
|
||||
Get.toNamed(
|
||||
'/video?bvid=${item.bvid}&cid=${item.cid}',
|
||||
arguments: {
|
||||
'videoItem': item,
|
||||
'heroTag': heroTag,
|
||||
'sourceType': 'watchLater',
|
||||
'count': (loadingState.value as Success).response.length,
|
||||
},
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'package:PiliPalaX/common/widgets/icon_button.dart';
|
||||
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
|
||||
import 'package:PiliPalaX/common/widgets/pair.dart';
|
||||
import 'package:PiliPalaX/common/widgets/segment_progress_bar.dart';
|
||||
import 'package:PiliPalaX/common/widgets/watch_later_list.dart';
|
||||
import 'package:PiliPalaX/http/danmaku.dart';
|
||||
import 'package:PiliPalaX/http/init.dart';
|
||||
import 'package:PiliPalaX/http/user.dart';
|
||||
@@ -16,6 +15,7 @@ import 'package:PiliPalaX/models/video_detail_res.dart';
|
||||
import 'package:PiliPalaX/pages/video/detail/introduction/controller.dart';
|
||||
import 'package:PiliPalaX/pages/video/detail/related/controller.dart';
|
||||
import 'package:PiliPalaX/pages/video/detail/reply/controller.dart';
|
||||
import 'package:PiliPalaX/pages/video/detail/widgets/watch_later_list.dart';
|
||||
import 'package:PiliPalaX/utils/extension.dart';
|
||||
import 'package:canvas_danmaku/models/danmaku_content_item.dart';
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
@@ -346,6 +346,7 @@ class VideoDetailController extends GetxController
|
||||
bizId: Get.arguments['mediaId'] ?? -1,
|
||||
ps: 20,
|
||||
oid: mediaList.last.id,
|
||||
otype: mediaList.last.type ?? 2,
|
||||
);
|
||||
if (res['status']) {
|
||||
if (res['data'].isNotEmpty) {
|
||||
|
||||
219
lib/pages/video/detail/widgets/watch_later_list.dart
Normal file
219
lib/pages/video/detail/widgets/watch_later_list.dart
Normal file
@@ -0,0 +1,219 @@
|
||||
import 'package:PiliPalaX/common/widgets/stat/danmu.dart';
|
||||
import 'package:PiliPalaX/common/widgets/stat/view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPalaX/common/constants.dart';
|
||||
import 'package:PiliPalaX/common/widgets/badge.dart';
|
||||
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
||||
import 'package:PiliPalaX/http/search.dart';
|
||||
import 'package:PiliPalaX/models/video/later.dart';
|
||||
import 'package:PiliPalaX/utils/utils.dart';
|
||||
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
||||
|
||||
class MediaListPanel extends StatefulWidget {
|
||||
const MediaListPanel({
|
||||
super.key,
|
||||
required this.mediaList,
|
||||
this.changeMediaList,
|
||||
this.panelTitle,
|
||||
this.bvid,
|
||||
required this.loadMoreMedia,
|
||||
required this.count,
|
||||
});
|
||||
|
||||
final List<MediaVideoItemModel> mediaList;
|
||||
final Function? changeMediaList;
|
||||
final String? panelTitle;
|
||||
final String? bvid;
|
||||
final VoidCallback loadMoreMedia;
|
||||
final int count;
|
||||
|
||||
@override
|
||||
State<MediaListPanel> createState() => _MediaListPanelState();
|
||||
}
|
||||
|
||||
class _MediaListPanelState extends State<MediaListPanel> {
|
||||
final _scrollController = ItemScrollController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
int index =
|
||||
widget.mediaList.indexWhere((item) => item.bvid == widget.bvid);
|
||||
if (index != -1 && index != 0) {
|
||||
try {
|
||||
_scrollController.jumpTo(index: index);
|
||||
} catch (_) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
AppBar(
|
||||
toolbarHeight: 45,
|
||||
automaticallyImplyLeading: false,
|
||||
titleSpacing: 16,
|
||||
title: Text(widget.panelTitle ?? '稍后再看'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, size: 20),
|
||||
onPressed: Get.back,
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: Material(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Obx(
|
||||
() => ScrollablePositionedList.builder(
|
||||
itemScrollController: _scrollController,
|
||||
itemCount: widget.mediaList.length,
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.paddingOf(context).bottom + 25,
|
||||
),
|
||||
itemBuilder: ((context, index) {
|
||||
var item = widget.mediaList[index];
|
||||
if (index == widget.mediaList.length - 1 &&
|
||||
widget.mediaList.length < widget.count) {
|
||||
widget.loadMoreMedia();
|
||||
}
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
if (item.type != 2) {
|
||||
SmartDialog.showToast('不支持播放该类型视频');
|
||||
return;
|
||||
}
|
||||
Get.back();
|
||||
String bvid = item.bvid!;
|
||||
int? aid = item.id;
|
||||
String cover = item.cover ?? '';
|
||||
final int cid = item.cid ??
|
||||
await SearchHttp.ab2c(aid: aid, bvid: bvid);
|
||||
widget.changeMediaList?.call(bvid, cid, aid, cover);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 8,
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, boxConstraints) {
|
||||
const double width = 120;
|
||||
return Container(
|
||||
constraints: const BoxConstraints(minHeight: 88),
|
||||
height: width / StyleString.aspectRatio,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
AspectRatio(
|
||||
aspectRatio: StyleString.aspectRatio,
|
||||
child: LayoutBuilder(
|
||||
builder: (BuildContext context,
|
||||
BoxConstraints boxConstraints) {
|
||||
final double maxWidth =
|
||||
boxConstraints.maxWidth;
|
||||
final double maxHeight =
|
||||
boxConstraints.maxHeight;
|
||||
return Stack(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
src: item.cover ?? '',
|
||||
width: maxWidth,
|
||||
height: maxHeight,
|
||||
),
|
||||
PBadge(
|
||||
text: Utils.timeFormat(
|
||||
item.duration!),
|
||||
right: 6.0,
|
||||
bottom: 6.0,
|
||||
type: 'gray',
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
10, 0, 6, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.title as String,
|
||||
textAlign: TextAlign.start,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: item.bvid == widget.bvid
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.primary
|
||||
: null,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
item.upper?.name as String,
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelMedium!
|
||||
.fontSize,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Row(
|
||||
children: [
|
||||
statView(
|
||||
context: context,
|
||||
theme: 'gray',
|
||||
view: item.cntInfo!['play']
|
||||
as int,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
statDanMu(
|
||||
context: context,
|
||||
theme: 'gray',
|
||||
danmu: item.cntInfo!['danmaku']
|
||||
as int,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user