mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-19 00:26:18 +08:00
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user