Files
PiliPlus/lib/pages/member_favorite/widget/item.dart
My-Responsitories ce5e85e64b tweaks (#1780)
* opt: sized

* fix: self send

* feat: ctrl enter to send

* opt: checked

* opt: download notifier

* opt: Future.syncValue

* mod: account

* mod: loading state

* opt: DebounceStreamMixin

* opt: report

* opt: enum map

* opt: file handler

* opt: dyn color

* opt: Uint8List subview

* opt: FileExt

* opt: computeLuminance

* opt: isNullOrEmpty

* opt: Get context

* update [skip ci]

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>

* opt dynamicColor [skip ci]

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>

* fixes [skip ci]

* update

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>

* update

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>

---------

Signed-off-by: My-Responsitories <107370289+My-Responsitories@users.noreply.github.com>
Co-authored-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
2025-12-17 17:01:10 +08:00

124 lines
4.2 KiB
Dart

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_new/space/space_fav/list.dart';
import 'package:PiliPlus/pages/subscription_detail/view.dart';
import 'package:PiliPlus/utils/fav_utils.dart';
import 'package:PiliPlus/utils/num_utils.dart';
import 'package:PiliPlus/utils/platform_utils.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class MemberFavItem extends StatelessWidget {
const MemberFavItem({super.key, required this.item, this.onDelete});
final SpaceFavItemModel item;
final ValueChanged<bool?>? onDelete;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
void onLongPress() => imageSaveDialog(
title: item.title,
cover: item.cover,
);
return Material(
type: MaterialType.transparency,
child: InkWell(
onTap: () async {
if (item.state == 1) {
// invalid
return;
}
if (item.type == 0 || item.type == 11) {
final isDeleted = await Get.toNamed(
'/favDetail',
parameters: {
'mediaId': item.id.toString(),
'heroTag': Utils.makeHeroTag(item.id),
},
);
onDelete?.call(isDeleted);
} else {
SubDetailPage.toSubDetailPage(
item.id!,
subInfo: item,
);
}
},
onLongPress: onLongPress,
onSecondaryTap: PlatformUtils.isMobile ? null : onLongPress,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: StyleString.safeSpace,
vertical: 5,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Stack(
clipBehavior: Clip.none,
children: [
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(
builder: (context, constraints) => NetworkImgLayer(
src: item.cover,
width: constraints.maxWidth,
height: constraints.maxHeight,
),
),
),
if (item.type == 21)
const PBadge(
right: 6,
top: 6,
text: '合集',
)
else if (item.type == 11)
const PBadge(
right: 6,
top: 6,
text: '收藏夹',
),
],
),
const SizedBox(width: 10),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item.title ?? '',
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
const Spacer(),
Text(
item.type == 0
? '${item.mediaCount}个内容 · ${FavUtils.isPublicFavText(item.attr)}'
: item.type == 11
? '${item.mediaCount}个内容 · ${item.upper?.name}'
: item.type == 21
? '创建者: ${item.upper?.name}\n${item.mediaCount}个视频 · ${NumUtils.numFormat(item.viewCount)}播放'
: '${item.mediaCount}个内容',
style: TextStyle(
fontSize: 12,
color: theme.colorScheme.outline,
),
),
],
),
),
],
),
),
),
);
}
}