mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-26 05:16:01 +08:00
@@ -1,6 +1,7 @@
|
||||
import 'package:PiliPlus/http/fav.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/user.dart';
|
||||
import 'package:PiliPlus/models/user/sub_folder.dart';
|
||||
import 'package:PiliPlus/models_new/sub/sub/list.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -8,7 +9,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class SubController
|
||||
extends CommonListController<List<SubFolderItemData>?, SubFolderItemData> {
|
||||
extends CommonListController<List<SubItemModel>?, SubItemModel> {
|
||||
dynamic mid;
|
||||
|
||||
@override
|
||||
@@ -28,7 +29,7 @@ class SubController
|
||||
}
|
||||
|
||||
// 取消订阅
|
||||
void cancelSub(SubFolderItemData subFolderItem) {
|
||||
void cancelSub(SubItemModel subFolderItem) {
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) => AlertDialog(
|
||||
@@ -44,7 +45,7 @@ class SubController
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
var res = await UserHttp.cancelSub(
|
||||
var res = await FavHttp.cancelSub(
|
||||
id: subFolderItem.id!, type: subFolderItem.type!);
|
||||
if (res['status']) {
|
||||
loadingState
|
||||
@@ -64,7 +65,7 @@ class SubController
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<List<SubFolderItemData>?>> customGetData() =>
|
||||
Future<LoadingState<List<SubItemModel>?>> customGetData() =>
|
||||
UserHttp.userSubFolder(
|
||||
pn: page,
|
||||
ps: 20,
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:PiliPlus/common/skeleton/video_card_h.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/user/sub_folder.dart';
|
||||
import 'package:PiliPlus/models_new/sub/sub/list.dart';
|
||||
import 'package:PiliPlus/pages/subscription/controller.dart';
|
||||
import 'package:PiliPlus/pages/subscription/widgets/item.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
@@ -44,7 +44,7 @@ class _SubPageState extends State<SubPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody(LoadingState<List<SubFolderItemData>?> loadingState) {
|
||||
Widget _buildBody(LoadingState<List<SubItemModel>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
@@ -62,9 +62,10 @@ class _SubPageState extends State<SubPage> {
|
||||
if (index == response.length - 1) {
|
||||
_subController.onLoadMore();
|
||||
}
|
||||
final item = response[index];
|
||||
return SubItem(
|
||||
subFolderItem: response[index],
|
||||
cancelSub: _subController.cancelSub,
|
||||
item: item,
|
||||
cancelSub: () => _subController.cancelSub(item),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -1,35 +1,58 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
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/user/sub_folder.dart';
|
||||
import 'package:PiliPlus/models_new/sub/sub/list.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class SubItem extends StatelessWidget {
|
||||
final SubFolderItemData subFolderItem;
|
||||
final Function(SubFolderItemData) cancelSub;
|
||||
final SubItemModel item;
|
||||
final VoidCallback cancelSub;
|
||||
const SubItem({
|
||||
super.key,
|
||||
required this.subFolderItem,
|
||||
required this.item,
|
||||
required this.cancelSub,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String heroTag = Utils.makeHeroTag(subFolderItem.id);
|
||||
String heroTag = Utils.makeHeroTag(item.id);
|
||||
final type = switch (item.type) {
|
||||
11 => '收藏夹',
|
||||
21 => '合集',
|
||||
_ => '其它(${item.type})',
|
||||
};
|
||||
return InkWell(
|
||||
onTap: () => Get.toNamed(
|
||||
'/subDetail',
|
||||
arguments: subFolderItem,
|
||||
parameters: {
|
||||
'heroTag': heroTag,
|
||||
'id': subFolderItem.id.toString(),
|
||||
},
|
||||
),
|
||||
onTap: () {
|
||||
if (item.state == 1) {
|
||||
SmartDialog.showToast('该$type已失效');
|
||||
return;
|
||||
}
|
||||
if (item.type == 11) {
|
||||
Get.toNamed(
|
||||
'/favDetail',
|
||||
parameters: {
|
||||
'mediaId': item.id!.toString(),
|
||||
'heroTag': heroTag,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
Get.toNamed(
|
||||
'/subDetail',
|
||||
arguments: item,
|
||||
parameters: {
|
||||
'heroTag': heroTag,
|
||||
'id': item.id.toString(),
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
onLongPress: () => imageSaveDialog(
|
||||
title: subFolderItem.title,
|
||||
cover: subFolderItem.cover,
|
||||
title: item.title,
|
||||
cover: item.cover,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 5),
|
||||
@@ -43,13 +66,23 @@ class SubItem extends StatelessWidget {
|
||||
builder: (context, boxConstraints) {
|
||||
double maxWidth = boxConstraints.maxWidth;
|
||||
double maxHeight = boxConstraints.maxHeight;
|
||||
return Hero(
|
||||
tag: heroTag,
|
||||
child: NetworkImgLayer(
|
||||
src: subFolderItem.cover,
|
||||
width: maxWidth,
|
||||
height: maxHeight,
|
||||
),
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Hero(
|
||||
tag: heroTag,
|
||||
child: NetworkImgLayer(
|
||||
src: item.cover,
|
||||
width: maxWidth,
|
||||
height: maxHeight,
|
||||
),
|
||||
),
|
||||
PBadge(
|
||||
right: 6,
|
||||
top: 6,
|
||||
text: type,
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -64,47 +97,35 @@ class SubItem extends StatelessWidget {
|
||||
|
||||
Widget videoContent(context) {
|
||||
final theme = Theme.of(context);
|
||||
// subFolderItem.type == 11:播单
|
||||
// subFolderItem.type == 21:合集
|
||||
// 其它:其它
|
||||
String typeString = subFolderItem.type == 11
|
||||
? '播单'
|
||||
: subFolderItem.type == 21
|
||||
? '合集'
|
||||
: '其它:${subFolderItem.type}';
|
||||
final style = TextStyle(
|
||||
fontSize: 13,
|
||||
color: theme.colorScheme.outline,
|
||||
);
|
||||
return Expanded(
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Column(
|
||||
spacing: 4,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
subFolderItem.title!,
|
||||
item.title!,
|
||||
textAlign: TextAlign.start,
|
||||
style: const TextStyle(
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
'[$typeString] UP主:${subFolderItem.upper!.name!}',
|
||||
'UP主: ${item.upper!.name!}',
|
||||
textAlign: TextAlign.start,
|
||||
style: TextStyle(
|
||||
fontSize: theme.textTheme.labelMedium!.fontSize,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
style: style,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
'${subFolderItem.mediaCount}个视频',
|
||||
'${item.mediaCount}个视频',
|
||||
textAlign: TextAlign.start,
|
||||
style: TextStyle(
|
||||
fontSize: theme.textTheme.labelMedium!.fontSize,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
style: style,
|
||||
),
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
@@ -114,7 +135,7 @@ class SubItem extends StatelessWidget {
|
||||
height: 35,
|
||||
width: 35,
|
||||
child: IconButton(
|
||||
onPressed: () => cancelSub(subFolderItem),
|
||||
onPressed: cancelSub,
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: theme.colorScheme.outline,
|
||||
padding: EdgeInsets.zero,
|
||||
|
||||
Reference in New Issue
Block a user