Files
PiliPlus/lib/pages/fav/note/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

125 lines
3.8 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:PiliPlus/utils/platform_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;
void onLongPress() {
if (!ctr.enableMultiSelect.value) {
ctr.enableMultiSelect.value = true;
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: onLongPress,
onSecondaryTap: PlatformUtils.isMobile ? null : onLongPress,
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,
),
),
],
);
},
),
),
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,
),
),
],
),
),
],
),
),
),
);
}
}