Files
PiliPlus/lib/pages/fav/note/widget/item.dart
bggRGjQaUbCoE 422b413778 opt ui
opt req

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
2025-08-15 11:18:10 +08:00

121 lines
3.7 KiB
Dart

import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
import 'package:PiliPlus/common/widgets/select_mask.dart';
import 'package:PiliPlus/models_new/fav/fav_note/list.dart';
import 'package:PiliPlus/pages/fav/note/controller.dart';
import 'package:PiliPlus/utils/page_utils.dart';
import 'package:flutter/material.dart';
class FavNoteItem extends StatelessWidget {
const FavNoteItem({
super.key,
required this.item,
required this.ctr,
required this.onSelect,
});
final FavNoteItemModel item;
final FavNoteController ctr;
final VoidCallback onSelect;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Material(
type: MaterialType.transparency,
child: InkWell(
onTap: () {
if (ctr.enableMultiSelect.value) {
onSelect();
return;
}
if (item.webUrl?.isNotEmpty == true) {
PageUtils.handleWebview(
item.webUrl!,
inApp: true,
);
}
},
onLongPress: () {
if (!ctr.enableMultiSelect.value) {
ctr.enableMultiSelect.value = true;
onSelect();
}
},
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: StyleString.safeSpace,
vertical: 5,
),
child: Row(
spacing: 10,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (item.pic?.isNotEmpty == true)
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(
builder: (context, boxConstraints) {
return Stack(
clipBehavior: Clip.none,
children: [
NetworkImgLayer(
src: item.pic,
width: boxConstraints.maxWidth,
height: boxConstraints.maxHeight,
),
Positioned.fill(
child: selectMask(
theme,
item.checked == true,
),
),
],
);
},
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item.title ?? '',
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
height: 1.4,
fontSize: 14,
),
),
const Spacer(),
Text(
item.summary ?? '',
maxLines: 1,
style: TextStyle(
fontSize: 14,
height: 1,
color: theme.colorScheme.outline,
),
),
const Spacer(),
Text(
item.message ?? '',
maxLines: 1,
style: TextStyle(
fontSize: 13,
height: 1,
color: theme.colorScheme.outline,
),
),
],
),
),
],
),
),
),
);
}
}