mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-24 11:06:51 +08:00
feat: later page: multi select
feat: fav detail page: multi select opt: reply item opt: load more Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -21,7 +21,7 @@ abstract class CommonController extends GetxController {
|
||||
return false;
|
||||
}
|
||||
|
||||
void handleSuccess(List currentList, List dataList) {}
|
||||
// void handleSuccess(List currentList, List dataList) {}
|
||||
|
||||
Future queryData([bool isRefresh = true]) async {
|
||||
if (isLoading || (isRefresh.not && isEnd)) return;
|
||||
@@ -29,6 +29,7 @@ abstract class CommonController extends GetxController {
|
||||
LoadingState response = await customGetData();
|
||||
if (response is Success) {
|
||||
if (!customHandleResponse(response)) {
|
||||
isEnd = response.response.isEmpty;
|
||||
List currentList = loadingState.value is Success
|
||||
? (loadingState.value as Success).response
|
||||
: [];
|
||||
@@ -38,7 +39,7 @@ abstract class CommonController extends GetxController {
|
||||
? LoadingState.success(handleList)
|
||||
: response
|
||||
: LoadingState.success(currentList + response.response);
|
||||
handleSuccess(currentList, response.response);
|
||||
// handleSuccess(currentList, response.response);
|
||||
}
|
||||
currentPage++;
|
||||
} else {
|
||||
|
||||
31
lib/pages/common/multi_select_controller.dart
Normal file
31
lib/pages/common/multi_select_controller.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:PiliPalaX/http/loading_state.dart';
|
||||
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPalaX/utils/extension.dart';
|
||||
|
||||
abstract class MultiSelectController extends CommonController {
|
||||
RxBool enableMultiSelect = false.obs;
|
||||
RxInt checkedCount = 0.obs;
|
||||
|
||||
onSelect(int index) {
|
||||
List list = (loadingState.value as Success).response;
|
||||
list[index].checked = !list[index].checked;
|
||||
checkedCount.value = list.where((item) => item.checked).length;
|
||||
loadingState.value = LoadingState.success(list);
|
||||
if (checkedCount.value == 0) {
|
||||
enableMultiSelect.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
void handleSelect([bool checked = false]) {
|
||||
List? list = (loadingState.value as Success?)?.response;
|
||||
if (list.isNullOrEmpty.not) {
|
||||
loadingState.value = LoadingState.success(
|
||||
list!.map((item) => item..checked = checked).toList());
|
||||
checkedCount.value = checked ? list.length : 0;
|
||||
}
|
||||
if (checked.not) {
|
||||
enableMultiSelect.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user