2024-04-02 12:24:08 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:get/get_rx/src/rx_types/rx_types.dart';
|
|
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
2024-04-03 13:45:34 +08:00
|
|
|
import 'package:sk_base_mobile/models/base_search_more.model.dart';
|
2024-04-02 12:24:08 +08:00
|
|
|
|
2024-04-03 13:45:34 +08:00
|
|
|
mixin BaseSearchMoreController<T extends BaseSearchMoreModel> {
|
2024-04-02 12:24:08 +08:00
|
|
|
RxList<T> list = RxList([]);
|
|
|
|
RxString searchKey = ''.obs;
|
|
|
|
final searchBarTextConroller = TextEditingController();
|
|
|
|
RefreshController refreshController = RefreshController(initialRefresh: true);
|
|
|
|
int page = 1;
|
|
|
|
int limit = 15;
|
|
|
|
int total = 0;
|
2024-04-03 13:45:34 +08:00
|
|
|
RxList<int> selectedIndex = RxList([]);
|
2024-04-02 12:24:08 +08:00
|
|
|
getData({bool isRefresh = false}) {}
|
|
|
|
|
|
|
|
Future<void> onRefresh() async {
|
|
|
|
await getData(isRefresh: true).then((_) {
|
|
|
|
refreshController.refreshCompleted(resetFooterState: true);
|
|
|
|
}).catchError((_) {
|
|
|
|
refreshController.refreshFailed();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> onLoading() async {
|
|
|
|
await getData().then((_) {
|
|
|
|
if (_.isEmpty) {
|
|
|
|
refreshController.loadNoData();
|
|
|
|
} else {
|
|
|
|
refreshController.loadComplete();
|
|
|
|
}
|
|
|
|
}).catchError((_) {
|
|
|
|
refreshController.loadFailed();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|