✨ Embedded reply post and repost
This commit is contained in:
parent
c7afa7e8e4
commit
57ff5e44ba
@ -47,6 +47,8 @@ class SolianMessages extends Translations {
|
||||
'postContentPlaceholder': 'What\'s happened?!',
|
||||
'postReaction': 'Reactions of the Post',
|
||||
'postActionList': 'Actions of Post',
|
||||
'postRepliedNotify': 'Replied a post from @username.',
|
||||
'postRepostedNotify': 'Reposted a post from @username.',
|
||||
'postEditingNotify': 'You\'re editing as post from you.',
|
||||
'postReplyingNotify': 'You\'re replying a post from @username.',
|
||||
'postRepostingNotify': 'You\'re reposting a post from @username.',
|
||||
@ -105,6 +107,8 @@ class SolianMessages extends Translations {
|
||||
'postContentPlaceholder': '发生什么事了?!',
|
||||
'postReaction': '帖子的反应',
|
||||
'postActionList': '帖子的操作',
|
||||
'postRepliedNotify': '回了一个 @username 的帖子',
|
||||
'postRepostedNotify': '转了一个 @username 的帖子',
|
||||
'postEditingNotify': '你正在编辑一个你发布的帖子',
|
||||
'postReplyingNotify': '你正在回一个来自 @username 的帖子',
|
||||
'postRepostingNotify': '你正在转一个来自 @username 的帖子',
|
||||
|
@ -6,7 +6,8 @@ class AccountAvatar extends StatelessWidget {
|
||||
final Color? color;
|
||||
final double? radius;
|
||||
|
||||
const AccountAvatar({super.key, required this.content, this.color, this.radius});
|
||||
const AccountAvatar(
|
||||
{super.key, required this.content, this.color, this.radius});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -21,10 +22,19 @@ class AccountAvatar extends StatelessWidget {
|
||||
key: Key('a$content'),
|
||||
radius: radius,
|
||||
backgroundColor: color,
|
||||
backgroundImage: !isEmpty ? NetworkImage(
|
||||
direct ? content : '${ServiceFinder.services['paperclip']}/api/attachments/$content',
|
||||
) : null,
|
||||
child: isEmpty ? const Icon(Icons.account_circle) : null,
|
||||
backgroundImage: !isEmpty
|
||||
? NetworkImage(
|
||||
direct
|
||||
? content
|
||||
: '${ServiceFinder.services['paperclip']}/api/attachments/$content',
|
||||
)
|
||||
: null,
|
||||
child: isEmpty
|
||||
? Icon(
|
||||
Icons.account_circle,
|
||||
size: radius != null ? radius! * 1.2 : 24,
|
||||
)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -10,11 +10,13 @@ import 'package:timeago/timeago.dart' show format;
|
||||
|
||||
class PostItem extends StatefulWidget {
|
||||
final Post item;
|
||||
final bool isCompact;
|
||||
final bool isReactable;
|
||||
|
||||
const PostItem({
|
||||
super.key,
|
||||
required this.item,
|
||||
this.isCompact = false,
|
||||
this.isReactable = true,
|
||||
});
|
||||
|
||||
@ -31,10 +33,104 @@ class _PostItemState extends State<PostItem> {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Widget buildReply(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.reply,
|
||||
size: 18,
|
||||
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.75),
|
||||
),
|
||||
Text(
|
||||
'postRepliedNotify'.trParams(
|
||||
{'username': '@${widget.item.author.name}'},
|
||||
),
|
||||
style: TextStyle(
|
||||
color:
|
||||
Theme.of(context).colorScheme.onSurface.withOpacity(0.75),
|
||||
),
|
||||
).paddingOnly(left: 6),
|
||||
],
|
||||
).paddingOnly(left: 12),
|
||||
Card(
|
||||
elevation: 1,
|
||||
child: PostItem(
|
||||
item: widget.item.replyTo!,
|
||||
isCompact: true,
|
||||
).paddingSymmetric(vertical: 8),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildRepost(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.redo,
|
||||
size: 18,
|
||||
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.75),
|
||||
),
|
||||
Text(
|
||||
'postRepostedNotify'.trParams(
|
||||
{'username': '@${widget.item.author.name}'},
|
||||
),
|
||||
style: TextStyle(
|
||||
color:
|
||||
Theme.of(context).colorScheme.onSurface.withOpacity(0.75),
|
||||
),
|
||||
).paddingOnly(left: 6),
|
||||
],
|
||||
).paddingOnly(left: 12),
|
||||
Card(
|
||||
elevation: 1,
|
||||
child: PostItem(
|
||||
item: widget.item.repostTo!,
|
||||
isCompact: true,
|
||||
).paddingSymmetric(vertical: 8),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final hasAttachment = item.attachments?.isNotEmpty ?? false;
|
||||
|
||||
if (widget.isCompact) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
AccountAvatar(content: item.author.avatar.toString(), radius: 10),
|
||||
Text(
|
||||
item.author.nick,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
).paddingOnly(left: 6),
|
||||
Text(format(item.createdAt, locale: 'en_short'))
|
||||
.paddingOnly(left: 4),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 12),
|
||||
Markdown(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
data: item.content,
|
||||
padding: const EdgeInsets.all(0),
|
||||
).paddingOnly(
|
||||
left: 16,
|
||||
right: 12,
|
||||
top: 2,
|
||||
bottom: hasAttachment ? 4 : 0,
|
||||
),
|
||||
AttachmentList(attachmentsId: item.attachments ?? List.empty()),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
@ -54,6 +150,8 @@ class _PostItemState extends State<PostItem> {
|
||||
.paddingOnly(left: 4),
|
||||
],
|
||||
),
|
||||
if (widget.item.replyTo != null) buildReply(context),
|
||||
if (widget.item.repostTo != null) buildRepost(context),
|
||||
Markdown(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
|
Loading…
Reference in New Issue
Block a user