Articles writing

This commit is contained in:
2024-07-09 23:06:55 +08:00
parent fa600d6c69
commit 065cda27e9
5 changed files with 176 additions and 168 deletions

View File

@ -275,22 +275,25 @@ class _PostItemState extends State<PostItem> {
attachmentsId: item.attachments ?? List.empty(),
divided: true,
),
PostQuickAction(
isShowReply: widget.isShowReply,
isReactable: widget.isReactable,
item: widget.item,
onReact: (symbol, changes) {
setState(() {
item.reactionList[symbol] =
(item.reactionList[symbol] ?? 0) + changes;
});
},
).paddingOnly(
top: hasAttachment ? 10 : 6,
left: hasAttachment ? 24 : 60,
right: 16,
bottom: 10,
),
if (!widget.isShowReply && widget.isReactable)
PostQuickAction(
isShowReply: widget.isShowReply,
isReactable: widget.isReactable,
item: widget.item,
onReact: (symbol, changes) {
setState(() {
item.reactionList[symbol] =
(item.reactionList[symbol] ?? 0) + changes;
});
},
).paddingOnly(
top: hasAttachment ? 10 : 6,
left: hasAttachment ? 24 : 60,
right: 16,
bottom: 10,
)
else
const SizedBox(height: 10),
],
);
}

View File

@ -1,9 +1,7 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:solian/models/post.dart';
import 'package:solian/widgets/feed/feed_content.dart';
import 'package:solian/widgets/feed/feed_tags.dart';
import 'package:solian/widgets/posts/post_item.dart';
class PostOwnedListEntry extends StatelessWidget {
final Post item;
@ -15,61 +13,6 @@ class PostOwnedListEntry extends StatelessWidget {
required this.onTap,
});
Widget buildFooter(BuildContext context) {
List<String> labels = List.empty(growable: true);
if (item.createdAt == item.updatedAt) {
labels.add('postNewCreated'.trParams({
'date': DateFormat('yyyy/MM/dd HH:mm').format(item.updatedAt.toLocal()),
}));
} else {
labels.add('postEdited'.trParams({
'date': DateFormat('yyyy/MM/dd HH:mm').format(item.updatedAt.toLocal()),
}));
}
if (item.realm != null) {
labels.add('postInRealm'.trParams({
'realm': '#${item.realm!.alias}',
}));
}
final color = Theme.of(context).colorScheme.onSurface.withOpacity(0.75);
List<Widget> widgets = List.from([
Row(
children: [
Text(
'post'.tr,
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 12,
color: color,
),
),
Icon(Icons.text_snippet, size: 14, color: color).paddingOnly(left: 4),
],
),
], growable: true);
if (item.tags?.isNotEmpty ?? false) {
widgets.add(FeedTagsList(tags: item.tags!));
}
if (labels.isNotEmpty) {
widgets.add(Text(
labels.join(' · '),
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 12,
color: color,
),
));
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: widgets,
);
}
@override
Widget build(BuildContext context) {
return Card(
@ -78,12 +21,14 @@ class PostOwnedListEntry extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
FeedContent(content: item.content).paddingOnly(
left: 12,
right: 12,
top: 8,
),
buildFooter(context).paddingOnly(left: 12, top: 6, bottom: 8),
PostItem(
key: Key('p${item.alias}'),
item: item,
isShowEmbed: false,
isClickable: false,
isShowReply: false,
isReactable: false,
).paddingSymmetric(vertical: 8),
],
),
onTap: () => onTap(),