mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-25 04:45:54 +08:00
@@ -1,17 +1,18 @@
|
||||
import 'package:PiliPlus/http/bangumi.dart';
|
||||
import 'package:PiliPlus/http/pgc.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/pgc/pgc_index/condition.dart';
|
||||
import 'package:PiliPlus/models/pgc/pgc_index_item/data.dart';
|
||||
import 'package:PiliPlus/models/pgc/pgc_index_item/list.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_index_condition/data.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_index_condition/filter.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_index_result/data.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_index_result/list.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class PgcIndexController
|
||||
extends CommonListController<PgcIndexItemData, PgcIndexItemModel> {
|
||||
extends CommonListController<PgcIndexResult, PgcIndexItem> {
|
||||
PgcIndexController(this.indexType);
|
||||
int? indexType;
|
||||
Rx<LoadingState<PgcIndexCondition>> conditionState =
|
||||
LoadingState<PgcIndexCondition>.loading().obs;
|
||||
Rx<LoadingState<PgcIndexConditionData>> conditionState =
|
||||
LoadingState<PgcIndexConditionData>.loading().obs;
|
||||
|
||||
late final RxBool isExpand = false.obs;
|
||||
|
||||
@@ -24,18 +25,18 @@ class PgcIndexController
|
||||
}
|
||||
|
||||
Future<void> getPgcIndexCondition() async {
|
||||
var res = await BangumiHttp.pgcIndexCondition(
|
||||
var res = await PgcHttp.pgcIndexCondition(
|
||||
seasonType: indexType == null ? 1 : null,
|
||||
type: 0,
|
||||
indexType: indexType,
|
||||
);
|
||||
if (res.isSuccess) {
|
||||
PgcIndexCondition data = res.data;
|
||||
PgcIndexConditionData data = res.data;
|
||||
if (data.order?.isNotEmpty == true) {
|
||||
indexParams['order'] = data.order!.first.field;
|
||||
}
|
||||
if (data.filter?.isNotEmpty == true) {
|
||||
for (Filter item in data.filter!) {
|
||||
for (PgcConditionFilter item in data.filter!) {
|
||||
indexParams['${item.field}'] = item.values?.firstOrNull?.keyword;
|
||||
}
|
||||
}
|
||||
@@ -45,8 +46,8 @@ class PgcIndexController
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<PgcIndexItemData>> customGetData() =>
|
||||
BangumiHttp.pgcIndexResult(
|
||||
Future<LoadingState<PgcIndexResult>> customGetData() =>
|
||||
PgcHttp.pgcIndexResult(
|
||||
page: page,
|
||||
params: indexParams,
|
||||
seasonType: indexType == null ? 1 : null,
|
||||
@@ -55,7 +56,7 @@ class PgcIndexController
|
||||
);
|
||||
|
||||
@override
|
||||
List<PgcIndexItemModel>? getDataList(PgcIndexItemData response) {
|
||||
List<PgcIndexItem>? getDataList(PgcIndexResult response) {
|
||||
if (response.hasNext == null || response.hasNext == 0) {
|
||||
isEnd = true;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@ import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/loading_widget.dart';
|
||||
import 'package:PiliPlus/common/widgets/self_sized_horizontal_list.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/pgc/pgc_index/condition.dart';
|
||||
import 'package:PiliPlus/models/pgc/pgc_index_item/list.dart';
|
||||
import 'package:PiliPlus/pages/bangumi/widgets/bangumi_card_v_pgc_index.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_index_condition/data.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_index_condition/order.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_index_result/list.dart';
|
||||
import 'package:PiliPlus/pages/pgc_index/controller.dart';
|
||||
import 'package:PiliPlus/pages/pgc_index/widgets/pgc_card_v_pgc_index.dart';
|
||||
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -44,7 +45,7 @@ class _PgcIndexPageState extends State<PgcIndexPage>
|
||||
}
|
||||
|
||||
Widget _buildBody(
|
||||
ThemeData theme, LoadingState<PgcIndexCondition> loadingState) {
|
||||
ThemeData theme, LoadingState<PgcIndexConditionData> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => loadingWidget,
|
||||
Success(:var response) => Builder(builder: (context) {
|
||||
@@ -118,7 +119,7 @@ class _PgcIndexPageState extends State<PgcIndexPage>
|
||||
),
|
||||
childBuilder: (childIndex) => Obx(
|
||||
() => SearchText(
|
||||
bgColor: (item[childIndex] is Order
|
||||
bgColor: (item[childIndex] is PgcConditionOrder
|
||||
? _ctr.indexParams['order']
|
||||
: _ctr.indexParams[data
|
||||
.filter![
|
||||
@@ -126,12 +127,12 @@ class _PgcIndexPageState extends State<PgcIndexPage>
|
||||
? index - 1
|
||||
: index]
|
||||
.field]) ==
|
||||
(item[childIndex] is Order
|
||||
(item[childIndex] is PgcConditionOrder
|
||||
? item[childIndex].field
|
||||
: item[childIndex].keyword)
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: Colors.transparent,
|
||||
textColor: (item[childIndex] is Order
|
||||
textColor: (item[childIndex] is PgcConditionOrder
|
||||
? _ctr.indexParams['order']
|
||||
: _ctr.indexParams[data
|
||||
.filter![
|
||||
@@ -139,7 +140,7 @@ class _PgcIndexPageState extends State<PgcIndexPage>
|
||||
? index - 1
|
||||
: index]
|
||||
.field]) ==
|
||||
(item[childIndex] is Order
|
||||
(item[childIndex] is PgcConditionOrder
|
||||
? item[childIndex].field
|
||||
: item[childIndex].keyword)
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
@@ -150,7 +151,8 @@ class _PgcIndexPageState extends State<PgcIndexPage>
|
||||
vertical: 3,
|
||||
),
|
||||
onTap: (_) {
|
||||
String name = item[childIndex] is Order
|
||||
String name = item[childIndex]
|
||||
is PgcConditionOrder
|
||||
? 'order'
|
||||
: data
|
||||
.filter![data.order?.isNotEmpty == true
|
||||
@@ -158,7 +160,7 @@ class _PgcIndexPageState extends State<PgcIndexPage>
|
||||
: index]
|
||||
.field!;
|
||||
_ctr.indexParams[name] =
|
||||
(item[childIndex] is Order
|
||||
(item[childIndex] is PgcConditionOrder
|
||||
? item[childIndex].field
|
||||
: item[childIndex].keyword);
|
||||
_ctr.onReload();
|
||||
@@ -201,7 +203,7 @@ class _PgcIndexPageState extends State<PgcIndexPage>
|
||||
],
|
||||
);
|
||||
|
||||
Widget _buildList(LoadingState<List<PgcIndexItemModel>?> loadingState) {
|
||||
Widget _buildList(LoadingState<List<PgcIndexItem>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => const SliverToBoxAdapter(child: LinearProgressIndicator()),
|
||||
Success(:var response) => response?.isNotEmpty == true
|
||||
@@ -218,7 +220,7 @@ class _PgcIndexPageState extends State<PgcIndexPage>
|
||||
if (index == response.length - 1) {
|
||||
_ctr.onLoadMore();
|
||||
}
|
||||
return BangumiCardVPgcIndex(bangumiItem: response[index]);
|
||||
return PgcCardVPgcIndex(item: response[index]);
|
||||
},
|
||||
childCount: response!.length,
|
||||
),
|
||||
|
||||
103
lib/pages/pgc_index/widgets/pgc_card_v_pgc_index.dart
Normal file
103
lib/pages/pgc_index/widgets/pgc_card_v_pgc_index.dart
Normal file
@@ -0,0 +1,103 @@
|
||||
import 'package:PiliPlus/common/widgets/badge.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/image_save.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_index_result/list.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// 视频卡片 - 垂直布局
|
||||
class PgcCardVPgcIndex extends StatelessWidget {
|
||||
const PgcCardVPgcIndex({
|
||||
super.key,
|
||||
required this.item,
|
||||
});
|
||||
|
||||
final PgcIndexItem item;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
margin: EdgeInsets.zero,
|
||||
child: InkWell(
|
||||
onLongPress: () => imageSaveDialog(
|
||||
title: item.title,
|
||||
cover: item.cover,
|
||||
),
|
||||
onTap: () => PageUtils.viewPgc(seasonId: item.seasonId),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AspectRatio(
|
||||
aspectRatio: 0.75,
|
||||
child: LayoutBuilder(builder: (context, boxConstraints) {
|
||||
final double maxWidth = boxConstraints.maxWidth;
|
||||
final double maxHeight = boxConstraints.maxHeight;
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
src: item.cover,
|
||||
width: maxWidth,
|
||||
height: maxHeight,
|
||||
),
|
||||
PBadge(
|
||||
text: item.badge,
|
||||
top: 6,
|
||||
right: 6,
|
||||
bottom: null,
|
||||
left: null,
|
||||
),
|
||||
PBadge(
|
||||
text: item.order,
|
||||
top: null,
|
||||
right: null,
|
||||
bottom: 6,
|
||||
left: 6,
|
||||
type: PBadgeType.gray,
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
bagumiContent(context)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget bagumiContent(context) {
|
||||
final theme = Theme.of(context);
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(4, 5, 0, 3),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.title!,
|
||||
textAlign: TextAlign.start,
|
||||
style: const TextStyle(
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 1),
|
||||
if (item.indexShow != null)
|
||||
Text(
|
||||
item.indexShow!,
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
fontSize: theme.textTheme.labelMedium!.fontSize,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user