mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-26 12:07:11 +08:00
feat: live area page
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
38
lib/pages/live_area_detail/controller.dart
Normal file
38
lib/pages/live_area_detail/controller.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/http/live.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/live/live_area_list/area_item.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
|
||||
class LiveAreaDatailController
|
||||
extends CommonListController<List<AreaItem>?, AreaItem> {
|
||||
LiveAreaDatailController(this.areaId, this.parentAreaId);
|
||||
final dynamic areaId;
|
||||
final dynamic parentAreaId;
|
||||
|
||||
late int initialIndex = 0;
|
||||
final isLogin = Accounts.main.isLogin;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
queryData();
|
||||
}
|
||||
|
||||
@override
|
||||
List<AreaItem>? getDataList(List<AreaItem>? response) {
|
||||
if (response?.isNotEmpty == true) {
|
||||
initialIndex = max(0, response!.indexWhere((e) => e.id == areaId));
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<List<AreaItem>?>> customGetData() =>
|
||||
LiveHttp.liveRoomAreaList(
|
||||
isLogin: isLogin,
|
||||
parentid: parentAreaId,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user