mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-02 07:10:13 +08:00
42
lib/pages/common/dyn/reaction/controller.dart
Normal file
42
lib/pages/common/dyn/reaction/controller.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
import 'package:PiliPlus/http/dynamics.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models_new/dynamic/dyn_reaction/data.dart';
|
||||
import 'package:PiliPlus/models_new/dynamic/dyn_reaction/item.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class DynReactController
|
||||
extends CommonListController<DynReactionData, DynReactionItem> {
|
||||
DynReactController(this.id, {int count = -1}) : count = RxInt(count);
|
||||
final Object id;
|
||||
|
||||
String? _offset;
|
||||
final RxInt count;
|
||||
|
||||
@override
|
||||
List<DynReactionItem>? getDataList(DynReactionData response) {
|
||||
_offset = response.offset;
|
||||
if (response.hasMore != true) {
|
||||
isEnd = true;
|
||||
}
|
||||
return response.items;
|
||||
}
|
||||
|
||||
@override
|
||||
bool customHandleResponse(bool isRefresh, Success<DynReactionData> response) {
|
||||
if (isRefresh) {
|
||||
count.value = response.response.total;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<DynReactionData>> customGetData() =>
|
||||
DynamicsHttp.dynReaction(id: id, offset: _offset);
|
||||
|
||||
@override
|
||||
Future<void> onRefresh() {
|
||||
_offset = null;
|
||||
return super.onRefresh();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user