mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-20 18:40:13 +08:00
feat: popular series/precious
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
26
lib/pages/popular_precious/controller.dart
Normal file
26
lib/pages/popular_precious/controller.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/model_hot_video_item.dart';
|
||||
import 'package:PiliPlus/models_new/popular/popular_precious/data.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
|
||||
class PopularPreciousController
|
||||
extends CommonListController<PopularPreciousData, HotVideoItemModel> {
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
queryData();
|
||||
}
|
||||
|
||||
int? mediaId;
|
||||
|
||||
@override
|
||||
List<HotVideoItemModel>? getDataList(PopularPreciousData response) {
|
||||
mediaId = response.mediaId;
|
||||
return response.list;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<PopularPreciousData>> customGetData() =>
|
||||
VideoHttp.popularPrecious(page: page);
|
||||
}
|
||||
80
lib/pages/popular_precious/view.dart
Normal file
80
lib/pages/popular_precious/view.dart
Normal file
@@ -0,0 +1,80 @@
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/common/widgets/video_card/video_card_h.dart';
|
||||
import 'package:PiliPlus/common/widgets/view_sliver_safe_area.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/video/source_type.dart';
|
||||
import 'package:PiliPlus/models/model_hot_video_item.dart';
|
||||
import 'package:PiliPlus/pages/popular_precious/controller.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class PopularPreciousPage extends StatefulWidget {
|
||||
const PopularPreciousPage({super.key});
|
||||
|
||||
@override
|
||||
State<PopularPreciousPage> createState() => _PopularPreciousPageState();
|
||||
}
|
||||
|
||||
class _PopularPreciousPageState extends State<PopularPreciousPage>
|
||||
with GridMixin {
|
||||
final _controller = Get.put(PopularPreciousController());
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: AppBar(title: const Text('入站必刷')),
|
||||
body: refreshIndicator(
|
||||
onRefresh: _controller.onRefresh,
|
||||
child: CustomScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
ViewSliverSafeArea(
|
||||
sliver: Obx(() => _buildBody(_controller.loadingState.value)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody(LoadingState<List<HotVideoItemModel>?> value) {
|
||||
switch (value) {
|
||||
case Loading():
|
||||
return gridSkeleton;
|
||||
case Success<List<HotVideoItemModel>?>(:var response):
|
||||
return SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemCount: response!.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = response[index];
|
||||
return VideoCardH(
|
||||
videoItem: item,
|
||||
onTap: () {
|
||||
PageUtils.toVideoPage(
|
||||
bvid: item.bvid,
|
||||
cid: item.cid!,
|
||||
extraArguments: {
|
||||
'sourceType': SourceType.playlist,
|
||||
'favTitle': '入站必刷',
|
||||
'mediaId': _controller.mediaId,
|
||||
'desc': true,
|
||||
'oid': item.aid,
|
||||
'isContinuePlaying': index != 0,
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
case Error(:var errMsg):
|
||||
return HttpError(
|
||||
errMsg: errMsg,
|
||||
onReload: _controller.onReload,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user