opt: load more

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-11-27 12:42:27 +08:00
parent 05f9384c72
commit 4a145750c0
12 changed files with 65 additions and 156 deletions

View File

@@ -8,6 +8,7 @@ abstract class CommonController extends GetxController {
int currentPage = 1;
bool isLoading = false;
bool isEnd = false;
Rx<LoadingState> loadingState = LoadingState.loading().obs;
Future<LoadingState> customGetData();
@@ -23,7 +24,7 @@ abstract class CommonController extends GetxController {
void handleSuccess(List currentList, List dataList) {}
Future queryData([bool isRefresh = true]) async {
if (isLoading) return;
if (isLoading || (isRefresh.not && isEnd)) return;
isLoading = true;
LoadingState response = await customGetData();
if (response is Success) {
@@ -50,6 +51,7 @@ abstract class CommonController extends GetxController {
Future onRefresh() async {
currentPage = 1;
isEnd = false;
await queryData();
}