opt models

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-06-04 15:20:35 +08:00
parent f50b1d2beb
commit b960359a39
858 changed files with 11000 additions and 12588 deletions

View File

@@ -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,