mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-27 12:36:27 +08:00
@@ -3,11 +3,11 @@ import 'package:PiliPlus/common/skeleton/video_card_h.dart';
|
||||
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/common/widgets/video_card/video_card_h.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/later_view_type.dart';
|
||||
import 'package:PiliPlus/models/model_hot_video_item.dart';
|
||||
import 'package:PiliPlus/models_new/later/list.dart';
|
||||
import 'package:PiliPlus/pages/later/controller.dart';
|
||||
import 'package:PiliPlus/pages/later/widgets/video_card_h_later.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
@@ -56,7 +56,7 @@ class _LaterViewChildPageState extends State<LaterViewChildPage>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody(LoadingState<List<HotVideoItemModel>?> loadingState) {
|
||||
Widget _buildBody(LoadingState<List<LaterItemModel>?> loadingState) {
|
||||
final theme = Theme.of(context);
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverGrid(
|
||||
@@ -80,9 +80,8 @@ class _LaterViewChildPageState extends State<LaterViewChildPage>
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
VideoCardH(
|
||||
VideoCardHLater(
|
||||
videoItem: videoItem,
|
||||
source: 'later',
|
||||
onViewLater: (cid) {
|
||||
PageUtils.toVideoPage(
|
||||
'bvid=${videoItem.bvid}&cid=$cid',
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/user.dart';
|
||||
import 'package:PiliPlus/models/common/later_view_type.dart';
|
||||
import 'package:PiliPlus/models/model_hot_video_item.dart';
|
||||
import 'package:PiliPlus/models_new/later/data.dart';
|
||||
import 'package:PiliPlus/models_new/later/list.dart';
|
||||
import 'package:PiliPlus/pages/common/multi_select_controller.dart';
|
||||
import 'package:PiliPlus/pages/later/base_controller.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
@@ -13,8 +15,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class LaterController extends MultiSelectController<Map, HotVideoItemModel> {
|
||||
LaterController(this.laterViewType);
|
||||
class LaterController extends MultiSelectController<LaterData, LaterItemModel> {
|
||||
LaterController(
|
||||
this.laterViewType,
|
||||
);
|
||||
final LaterViewType laterViewType;
|
||||
|
||||
dynamic mid;
|
||||
@@ -23,7 +27,7 @@ class LaterController extends MultiSelectController<Map, HotVideoItemModel> {
|
||||
final LaterBaseController baseCtr = Get.put(LaterBaseController());
|
||||
|
||||
@override
|
||||
Future<LoadingState<Map>> customGetData() => UserHttp.seeYouLater(
|
||||
Future<LoadingState<LaterData>> customGetData() => UserHttp.seeYouLater(
|
||||
page: page,
|
||||
viewed: laterViewType.type,
|
||||
asc: asc.value,
|
||||
@@ -31,7 +35,7 @@ class LaterController extends MultiSelectController<Map, HotVideoItemModel> {
|
||||
|
||||
@override
|
||||
void onSelect(int index, [bool disableSelect = true]) {
|
||||
List<HotVideoItemModel> list = loadingState.value.data!;
|
||||
List<LaterItemModel> list = loadingState.value.data!;
|
||||
list[index].checked = !(list[index].checked ?? false);
|
||||
baseCtr.checkedCount.value =
|
||||
list.where((item) => item.checked == true).length;
|
||||
@@ -44,9 +48,9 @@ class LaterController extends MultiSelectController<Map, HotVideoItemModel> {
|
||||
@override
|
||||
void handleSelect([bool checked = false, bool disableSelect = true]) {
|
||||
if (loadingState.value.isSuccess) {
|
||||
List<HotVideoItemModel>? list = loadingState.value.data;
|
||||
List<LaterItemModel>? list = loadingState.value.data;
|
||||
if (list?.isNotEmpty == true) {
|
||||
for (HotVideoItemModel item in list!) {
|
||||
for (LaterItemModel item in list!) {
|
||||
item.checked = checked;
|
||||
}
|
||||
baseCtr.checkedCount.value = checked ? list.length : 0;
|
||||
@@ -66,8 +70,9 @@ class LaterController extends MultiSelectController<Map, HotVideoItemModel> {
|
||||
}
|
||||
|
||||
@override
|
||||
List<HotVideoItemModel>? getDataList(response) {
|
||||
return response['list'];
|
||||
List<LaterItemModel>? getDataList(response) {
|
||||
baseCtr.counts[laterViewType] = response.count ?? 0;
|
||||
return response.list;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -77,12 +82,6 @@ class LaterController extends MultiSelectController<Map, HotVideoItemModel> {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool customHandleResponse(bool isRefresh, Success response) {
|
||||
baseCtr.counts[laterViewType] = response.response['count'];
|
||||
return false;
|
||||
}
|
||||
|
||||
// single
|
||||
void toViewDel(BuildContext context, int index, int? aid) {
|
||||
showDialog(
|
||||
@@ -180,12 +179,12 @@ class LaterController extends MultiSelectController<Map, HotVideoItemModel> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _onDelete(List<HotVideoItemModel> result) async {
|
||||
Future<void> _onDelete(List<LaterItemModel> result) async {
|
||||
SmartDialog.showLoading(msg: '请求中');
|
||||
List<int?> aids = result.map((item) => item.aid).toList();
|
||||
var res = await UserHttp.toViewDel(aids: aids);
|
||||
if (res['status']) {
|
||||
Set<HotVideoItemModel> remainList =
|
||||
Set<LaterItemModel> remainList =
|
||||
loadingState.value.data!.toSet().difference(result.toSet());
|
||||
baseCtr.counts[laterViewType] =
|
||||
baseCtr.counts[laterViewType]! - aids.length;
|
||||
@@ -202,10 +201,10 @@ class LaterController extends MultiSelectController<Map, HotVideoItemModel> {
|
||||
// 稍后再看播放全部
|
||||
void toViewPlayAll() {
|
||||
if (loadingState.value.isSuccess) {
|
||||
List<HotVideoItemModel>? list = loadingState.value.data;
|
||||
List<LaterItemModel>? list = loadingState.value.data;
|
||||
if (list.isNullOrEmpty) return;
|
||||
|
||||
for (HotVideoItemModel item in list!) {
|
||||
for (LaterItemModel item in list!) {
|
||||
if (item.cid == null || item.pgcLabel?.isNotEmpty == true) {
|
||||
continue;
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:PiliPlus/common/widgets/scroll_physics.dart';
|
||||
import 'package:PiliPlus/models/common/later_view_type.dart';
|
||||
import 'package:PiliPlus/models/model_hot_video_item.dart';
|
||||
import 'package:PiliPlus/models_new/later/data.dart';
|
||||
import 'package:PiliPlus/models_new/later/list.dart';
|
||||
import 'package:PiliPlus/pages/history/view.dart' show AppBarWidget;
|
||||
import 'package:PiliPlus/pages/later/base_controller.dart';
|
||||
import 'package:PiliPlus/pages/later/controller.dart';
|
||||
@@ -266,7 +267,7 @@ class _LaterPageState extends State<LaterPage>
|
||||
),
|
||||
onPressed: () {
|
||||
final ctr = currCtr();
|
||||
RequestUtils.onCopyOrMove<Map, HotVideoItemModel>(
|
||||
RequestUtils.onCopyOrMove<LaterData, LaterItemModel>(
|
||||
context: context,
|
||||
isCopy: true,
|
||||
ctr: ctr,
|
||||
@@ -287,7 +288,7 @@ class _LaterPageState extends State<LaterPage>
|
||||
),
|
||||
onPressed: () {
|
||||
final ctr = currCtr();
|
||||
RequestUtils.onCopyOrMove<Map, HotVideoItemModel>(
|
||||
RequestUtils.onCopyOrMove<LaterData, LaterItemModel>(
|
||||
context: context,
|
||||
isCopy: false,
|
||||
ctr: ctr,
|
||||
|
||||
226
lib/pages/later/widgets/video_card_h_later.dart
Normal file
226
lib/pages/later/widgets/video_card_h_later.dart
Normal file
@@ -0,0 +1,226 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/badge.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/image_save.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/progress_bar/video_progress_indicator.dart';
|
||||
import 'package:PiliPlus/common/widgets/stat/stat.dart';
|
||||
import 'package:PiliPlus/http/search.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/models/search/result.dart';
|
||||
import 'package:PiliPlus/models_new/later/list.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
// 视频卡片 - 水平布局
|
||||
class VideoCardHLater extends StatelessWidget {
|
||||
const VideoCardHLater({
|
||||
super.key,
|
||||
required this.videoItem,
|
||||
this.onTap,
|
||||
this.onLongPress,
|
||||
this.onViewLater,
|
||||
});
|
||||
final LaterItemModel videoItem;
|
||||
final VoidCallback? onTap;
|
||||
final VoidCallback? onLongPress;
|
||||
final ValueChanged<int>? onViewLater;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String type = 'video';
|
||||
if (videoItem case SearchVideoItemModel item) {
|
||||
var typeOrNull = item.type;
|
||||
if (typeOrNull?.isNotEmpty == true) {
|
||||
type = typeOrNull!;
|
||||
}
|
||||
}
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onLongPress: onLongPress ??
|
||||
() => imageSaveDialog(
|
||||
title: videoItem.title,
|
||||
cover: videoItem.pic,
|
||||
),
|
||||
onTap: onTap ??
|
||||
() async {
|
||||
if (type == 'ketang') {
|
||||
SmartDialog.showToast('课堂视频暂不支持播放');
|
||||
return;
|
||||
}
|
||||
if (videoItem.isPgc == true) {
|
||||
if (videoItem.bangumi?.epId != null) {
|
||||
PageUtils.viewPgc(epId: videoItem.bangumi!.epId);
|
||||
} else if (videoItem.redirectUrl?.isNotEmpty == true) {
|
||||
PageUtils.viewPgcFromUri(videoItem.redirectUrl!);
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final int? cid = videoItem.cid ??
|
||||
await SearchHttp.ab2c(
|
||||
aid: videoItem.aid, bvid: videoItem.bvid);
|
||||
if (cid != null) {
|
||||
onViewLater!(cid);
|
||||
}
|
||||
} catch (err) {
|
||||
SmartDialog.showToast(err.toString());
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: StyleString.safeSpace,
|
||||
vertical: 5,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
AspectRatio(
|
||||
aspectRatio: StyleString.aspectRatio,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, boxConstraints) {
|
||||
final double maxWidth = boxConstraints.maxWidth;
|
||||
final double maxHeight = boxConstraints.maxHeight;
|
||||
num? progress = videoItem.progress;
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
src: videoItem.pic,
|
||||
width: maxWidth,
|
||||
height: maxHeight,
|
||||
),
|
||||
PBadge(
|
||||
text: videoItem.pgcLabel,
|
||||
top: 6.0,
|
||||
right: 6.0,
|
||||
),
|
||||
if (progress != null && progress != 0) ...[
|
||||
PBadge(
|
||||
text: progress == -1
|
||||
? '已看完'
|
||||
: '${Utils.timeFormat(progress)}/${Utils.timeFormat(videoItem.duration)}',
|
||||
right: 6,
|
||||
bottom: 8,
|
||||
type: PBadgeType.gray,
|
||||
),
|
||||
Positioned(
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: videoProgressIndicator(
|
||||
progress == -1
|
||||
? 1
|
||||
: progress / videoItem.duration!,
|
||||
),
|
||||
)
|
||||
] else if (videoItem.duration! > 0)
|
||||
PBadge(
|
||||
text: Utils.timeFormat(videoItem.duration),
|
||||
right: 6.0,
|
||||
bottom: 6.0,
|
||||
type: PBadgeType.gray,
|
||||
),
|
||||
if (type != 'video')
|
||||
PBadge(
|
||||
text: type,
|
||||
left: 6.0,
|
||||
bottom: 6.0,
|
||||
type: PBadgeType.primary,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
content(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget content(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (videoItem.isPgc == true && videoItem.bangumi != null) ...[
|
||||
Text(
|
||||
videoItem.bangumi!.season!.title!,
|
||||
style: TextStyle(
|
||||
fontSize: theme.textTheme.bodyMedium!.fontSize,
|
||||
height: 1.42,
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
videoItem.subtitle!,
|
||||
textAlign: TextAlign.start,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const Spacer(),
|
||||
StatView(
|
||||
context: context,
|
||||
theme: 'gray',
|
||||
value: Utils.numFormat(videoItem.stat?.view),
|
||||
),
|
||||
] else ...[
|
||||
Expanded(
|
||||
child: Text(
|
||||
videoItem.title!,
|
||||
style: TextStyle(
|
||||
fontSize: theme.textTheme.bodyMedium!.fontSize,
|
||||
height: 1.42,
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
videoItem.owner!.name!,
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
height: 1,
|
||||
color: theme.colorScheme.outline,
|
||||
overflow: TextOverflow.clip,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
StatView(
|
||||
context: context,
|
||||
theme: 'gray',
|
||||
value: Utils.numFormat(videoItem.stat?.view),
|
||||
),
|
||||
StatDanMu(
|
||||
context: context,
|
||||
theme: 'gray',
|
||||
value: Utils.numFormat(videoItem.stat?.danmaku),
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user