opt: multiSelect (#935)

This commit is contained in:
My-Responsitories
2025-08-04 12:57:37 +08:00
committed by GitHub
parent d246462535
commit 7b51f15753
23 changed files with 488 additions and 457 deletions

View File

@@ -115,11 +115,11 @@ class _FavNoteChildPageState extends State<FavNoteChildPage>
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
onPressed: () {
if (_favNoteController.checkedCount.value != 0) {
if (_favNoteController.checkedCount != 0) {
showConfirmDialog(
context: context,
title: '确定删除已选中的笔记吗?',
onConfirm: _favNoteController.onRemove,
onConfirm: _favNoteController.onConfirm,
);
}
},

View File

@@ -34,24 +34,15 @@ class FavNoteController
: FavHttp.noteList(page: page);
}
Future<void> onRemove() async {
List<FavNoteItemModel> dataList = loadingState.value.data!;
Set<FavNoteItemModel> removeList = dataList
.where((item) => item.checked == true)
.toSet();
@override
Future<void> onConfirm() async {
Set<FavNoteItemModel> removeList = allChecked.toSet();
final res = await FavHttp.delNote(
isPublish: isPublish,
noteIds: removeList
.map((item) => isPublish ? item.cvid : item.noteId)
.toList(),
noteIds: removeList.map((item) => isPublish ? item.cvid : item.noteId),
);
if (res['status']) {
List<FavNoteItemModel> remainList = dataList
.toSet()
.difference(removeList)
.toList();
loadingState.value = Success(remainList);
enableMultiSelect.value = false;
afterDelete(removeList);
SmartDialog.showToast('删除成功');
} else {
SmartDialog.showToast(res['msg']);
@@ -59,7 +50,7 @@ class FavNoteController
}
void onDisable() {
if (checkedCount.value != 0) {
if (checkedCount != 0) {
handleSelect();
}
enableMultiSelect.value = false;

View File

@@ -128,8 +128,7 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (_favPgcController.checkedCount.value !=
0) {
if (_favPgcController.checkedCount != 0) {
_favPgcController.onUpdateList(
item.followStatus,
);

View File

@@ -48,7 +48,7 @@ class FavPgcController
);
void onDisable() {
if (checkedCount.value != 0) {
if (checkedCount != 0) {
handleSelect();
}
enableMultiSelect.value = false;
@@ -65,22 +65,19 @@ class FavPgcController
SmartDialog.showToast(result['msg']);
}
@override
void onConfirm() {
assert(false, 'call onUpdateList');
}
Future<void> onUpdateList(int followStatus) async {
List<FavPgcItemModel> dataList = loadingState.value.data!;
Set<FavPgcItemModel> updateList = dataList
.where((item) => item.checked == true)
.toSet();
final updateList = allChecked.toSet();
final res = await VideoHttp.pgcUpdate(
seasonId: updateList.map((item) => item.seasonId).toList(),
status: followStatus,
);
if (res['status']) {
List<FavPgcItemModel> remainList = dataList
.toSet()
.difference(updateList)
.toList();
loadingState.value = Success(remainList);
enableMultiSelect.value = false;
afterDelete(updateList);
try {
final ctr = Get.find<FavPgcController>(tag: '$type$followStatus');
if (ctr.loadingState.value.isSuccess) {

View File

@@ -18,7 +18,7 @@ class FavPgcItem extends StatelessWidget {
});
final FavPgcItemModel item;
final MultiSelectController ctr;
final MultiSelectMixin ctr;
final VoidCallback onSelect;
final VoidCallback onUpdateStatus;