mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt del later view
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -13,6 +13,7 @@ import 'package:PiliPlus/pages/fav_sort/view.dart';
|
||||
import 'package:PiliPlus/services/account_service.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:flutter/services.dart' show ValueChanged;
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@@ -23,7 +24,7 @@ mixin BaseFavController
|
||||
bool get isOwner;
|
||||
int get mediaId;
|
||||
|
||||
void updateLength(int count) {}
|
||||
ValueChanged<int>? updateLength;
|
||||
|
||||
void onViewFav(FavDetailItemModel item, int? index);
|
||||
|
||||
@@ -36,7 +37,7 @@ mixin BaseFavController
|
||||
loadingState
|
||||
..value.data!.removeAt(index)
|
||||
..refresh();
|
||||
updateLength(1);
|
||||
updateLength?.call(1);
|
||||
SmartDialog.showToast('取消收藏');
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
@@ -58,7 +59,7 @@ mixin BaseFavController
|
||||
delIds: mediaId.toString(),
|
||||
);
|
||||
if (result['status']) {
|
||||
updateLength(removeList.length);
|
||||
updateLength?.call(removeList.length);
|
||||
afterDelete(removeList);
|
||||
SmartDialog.showToast('取消收藏');
|
||||
} else {
|
||||
@@ -123,11 +124,10 @@ class FavDetailController
|
||||
}
|
||||
|
||||
@override
|
||||
void updateLength(int count) {
|
||||
folderInfo
|
||||
..value.mediaCount -= count
|
||||
..refresh();
|
||||
}
|
||||
ValueChanged<int>? get updateLength =>
|
||||
(count) => folderInfo
|
||||
..value.mediaCount -= count
|
||||
..refresh();
|
||||
|
||||
@override
|
||||
Future<LoadingState<FavDetailData>> customGetData() =>
|
||||
|
||||
@@ -101,11 +101,7 @@ class _LaterViewChildPageState extends State<LaterViewChildPage>
|
||||
context,
|
||||
index,
|
||||
videoItem.aid,
|
||||
onSuccess: () {
|
||||
final counts = _laterController.baseCtr.counts;
|
||||
counts[widget.laterViewType] =
|
||||
counts[widget.laterViewType]! - 1;
|
||||
},
|
||||
onSuccess: () => _laterController.updateLength?.call(1),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -20,7 +20,32 @@ import 'package:get/get.dart';
|
||||
mixin BaseLaterController
|
||||
on
|
||||
CommonListController<LaterData, LaterItemModel>,
|
||||
CommonMultiSelectMixin<LaterItemModel> {
|
||||
CommonMultiSelectMixin<LaterItemModel>,
|
||||
DeleteItemMixin<LaterData, LaterItemModel> {
|
||||
ValueChanged<int>? updateLength;
|
||||
|
||||
@override
|
||||
void onRemove() {
|
||||
showConfirmDialog(
|
||||
context: Get.context!,
|
||||
content: '确认删除所选稍后再看吗?',
|
||||
title: '提示',
|
||||
onConfirm: () async {
|
||||
final removeList = allChecked;
|
||||
SmartDialog.showLoading(msg: '请求中');
|
||||
final res = await UserHttp.toViewDel(
|
||||
aids: removeList.map((item) => item.aid).join(','),
|
||||
);
|
||||
if (res['status']) {
|
||||
updateLength?.call(removeList.length);
|
||||
afterDelete(removeList);
|
||||
}
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast(res['msg']);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// single
|
||||
void toViewDel(
|
||||
BuildContext context,
|
||||
@@ -134,29 +159,6 @@ class LaterController extends MultiSelectController<LaterData, LaterItemModel>
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void onRemove() {
|
||||
showConfirmDialog(
|
||||
context: Get.context!,
|
||||
content: '确认删除所选稍后再看吗?',
|
||||
title: '提示',
|
||||
onConfirm: () async {
|
||||
final removeList = allChecked;
|
||||
SmartDialog.showLoading(msg: '请求中');
|
||||
final res = await UserHttp.toViewDel(
|
||||
aids: removeList.map((item) => item.aid!).join(','),
|
||||
);
|
||||
if (res['status']) {
|
||||
baseCtr.counts[laterViewType] =
|
||||
baseCtr.counts[laterViewType]! - removeList.length;
|
||||
afterDelete(removeList);
|
||||
}
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast(res['msg']);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 稍后再看播放全部
|
||||
void toViewPlayAll() {
|
||||
if (loadingState.value.isSuccess) {
|
||||
@@ -189,6 +191,11 @@ class LaterController extends MultiSelectController<LaterData, LaterItemModel>
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
ValueChanged<int>? get updateLength =>
|
||||
(count) => baseCtr.counts[laterViewType] =
|
||||
baseCtr.counts[laterViewType]! - count;
|
||||
|
||||
@override
|
||||
Future<void> onReload() {
|
||||
scrollController.jumpToTop();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
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_new/later/data.dart';
|
||||
@@ -6,7 +5,6 @@ import 'package:PiliPlus/models_new/later/list.dart';
|
||||
import 'package:PiliPlus/pages/common/multi_select/base.dart';
|
||||
import 'package:PiliPlus/pages/common/search/common_search_controller.dart';
|
||||
import 'package:PiliPlus/pages/later/controller.dart' show BaseLaterController;
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class LaterSearchController
|
||||
@@ -28,25 +26,4 @@ class LaterSearchController
|
||||
List<LaterItemModel>? getDataList(LaterData response) {
|
||||
return response.list;
|
||||
}
|
||||
|
||||
@override
|
||||
void onRemove() {
|
||||
showConfirmDialog(
|
||||
context: Get.context!,
|
||||
content: '确认删除所选稍后再看吗?',
|
||||
title: '提示',
|
||||
onConfirm: () async {
|
||||
final removeList = allChecked;
|
||||
SmartDialog.showLoading(msg: '请求中');
|
||||
var res = await UserHttp.toViewDel(
|
||||
aids: removeList.map((item) => item.aid).join(','),
|
||||
);
|
||||
if (res['status']) {
|
||||
afterDelete(removeList);
|
||||
}
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast(res['msg']);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user