mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: new pgc rank
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -89,8 +89,12 @@ class _RankPageState extends State<RankPage>
|
||||
child: TabBarView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
controller: _rankController.tabController,
|
||||
children:
|
||||
tabsConfig.map((item) => ZonePage(rid: item['rid'])).toList(),
|
||||
children: tabsConfig
|
||||
.map((item) => ZonePage(
|
||||
rid: item['rid'],
|
||||
seasonType: item['season_type'],
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
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/pages/common/common_list_controller.dart';
|
||||
|
||||
class ZoneController
|
||||
extends CommonListController<List<HotVideoItemModel>, HotVideoItemModel> {
|
||||
ZoneController({required this.zoneID});
|
||||
int zoneID;
|
||||
class ZoneController extends CommonListController {
|
||||
ZoneController({this.rid, this.seasonType});
|
||||
|
||||
int? rid;
|
||||
int? seasonType;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -15,6 +15,13 @@ class ZoneController
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<List<HotVideoItemModel>>> customGetData() =>
|
||||
VideoHttp.getRankVideoList(zoneID);
|
||||
Future<LoadingState> customGetData() {
|
||||
if (rid != null) {
|
||||
return VideoHttp.getRankVideoList(rid!);
|
||||
}
|
||||
if (seasonType == 1) {
|
||||
return VideoHttp.pgcRankList(seasonType: seasonType!);
|
||||
}
|
||||
return VideoHttp.pgcSeasonRankList(seasonType: seasonType!);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/model_hot_video_item.dart';
|
||||
import 'package:PiliPlus/pages/common/common_page.dart';
|
||||
import 'package:PiliPlus/pages/rank/zone/widget/pgc_rank_item.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
@@ -13,9 +14,10 @@ import 'package:PiliPlus/pages/rank/zone/index.dart';
|
||||
import '../../../utils/grid.dart';
|
||||
|
||||
class ZonePage extends CommonPage {
|
||||
const ZonePage({super.key, required this.rid});
|
||||
const ZonePage({super.key, this.rid, this.seasonType});
|
||||
|
||||
final int rid;
|
||||
final int? rid;
|
||||
final int? seasonType;
|
||||
|
||||
@override
|
||||
State<ZonePage> createState() => _ZonePageState();
|
||||
@@ -25,8 +27,8 @@ class _ZonePageState extends CommonPageState<ZonePage, ZoneController>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
@override
|
||||
late ZoneController controller = Get.put(
|
||||
ZoneController(zoneID: widget.rid),
|
||||
tag: widget.rid.toString(),
|
||||
ZoneController(rid: widget.rid, seasonType: widget.seasonType),
|
||||
tag: '${widget.rid}${widget.seasonType}',
|
||||
);
|
||||
|
||||
@override
|
||||
@@ -66,7 +68,7 @@ class _ZonePageState extends CommonPageState<ZonePage, ZoneController>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody(LoadingState<List<HotVideoItemModel>?> loadingState) {
|
||||
Widget _buildBody(LoadingState<List<dynamic>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => _buildSkeleton(),
|
||||
Success() => loadingState.response?.isNotEmpty == true
|
||||
@@ -74,10 +76,14 @@ class _ZonePageState extends CommonPageState<ZonePage, ZoneController>
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
return VideoCardH(
|
||||
videoItem: loadingState.response![index],
|
||||
showPubdate: true,
|
||||
);
|
||||
final item = loadingState.response![index];
|
||||
if (item is HotVideoItemModel) {
|
||||
return VideoCardH(
|
||||
videoItem: item,
|
||||
showPubdate: true,
|
||||
);
|
||||
}
|
||||
return PgcRankItem(item: item);
|
||||
},
|
||||
childCount: loadingState.response!.length,
|
||||
),
|
||||
|
||||
98
lib/pages/rank/zone/widget/pgc_rank_item.dart
Normal file
98
lib/pages/rank/zone/widget/pgc_rank_item.dart
Normal file
@@ -0,0 +1,98 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/image_save.dart';
|
||||
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/stat/stat.dart';
|
||||
import 'package:PiliPlus/models/bangumi/pgc_rank/pgc_rank_item_model.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PgcRankItem extends StatelessWidget {
|
||||
const PgcRankItem({super.key, required this.item});
|
||||
|
||||
final PgcRankItemModel item;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
if (item.url != null) {
|
||||
PiliScheme.routePushFromUrl(item.url!);
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
imageSaveDialog(
|
||||
context: context,
|
||||
title: item.title,
|
||||
cover: item.cover,
|
||||
);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: StyleString.safeSpace,
|
||||
vertical: 5,
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AspectRatio(
|
||||
aspectRatio: 3 / 4,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return NetworkImgLayer(
|
||||
radius: 6,
|
||||
width: constraints.maxWidth,
|
||||
height: constraints.maxHeight,
|
||||
src: item.cover,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(item.title!),
|
||||
),
|
||||
if (item.newEp?.indexShow?.isNotEmpty == true) ...[
|
||||
Text(
|
||||
item.newEp!.indexShow!,
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
height: 1,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
overflow: TextOverflow.clip,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
],
|
||||
Row(
|
||||
children: [
|
||||
StatView(
|
||||
context: context,
|
||||
theme: 'gray',
|
||||
value: item.stat!.view!,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
StatView(
|
||||
context: context,
|
||||
theme: 'gray',
|
||||
goto: 'follow',
|
||||
value: item.stat!.follow!,
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user