diff --git a/lib/translations/en_us.dart b/lib/translations/en_us.dart index b3effa0..1bfaf18 100644 --- a/lib/translations/en_us.dart +++ b/lib/translations/en_us.dart @@ -129,7 +129,7 @@ const i18nEnglish = { 'postAction': 'Post', 'postEdited': 'Edited at @date', 'postNewCreated': 'Created at @date', - 'postAttachmentTip': '@count attachment(s)', + 'attachmentHint': '@count attachment(s)', 'postInRealm': 'In @realm', 'postDetail': 'Post', 'postReplies': 'Replies', diff --git a/lib/translations/zh_cn.dart b/lib/translations/zh_cn.dart index 2216f85..1c60f8b 100644 --- a/lib/translations/zh_cn.dart +++ b/lib/translations/zh_cn.dart @@ -124,7 +124,7 @@ const i18nSimplifiedChinese = { 'postEdited': '编辑于 @date', 'postNewCreated': '创建于 @date', 'postInRealm': '发表于 @realm', - 'postAttachmentTip': '@count 个附件', + 'attachmentHint': '@count 个附件', 'postDetail': '帖子详情', 'postReplies': '帖子回复', 'postPublish': '编辑帖子', diff --git a/lib/widgets/chat/chat_event.dart b/lib/widgets/chat/chat_event.dart index 7c7049b..119d3b7 100644 --- a/lib/widgets/chat/chat_event.dart +++ b/lib/widgets/chat/chat_event.dart @@ -37,13 +37,33 @@ class ChatEvent extends StatelessWidget { return '$negativeSign${twoDigits(duration.inHours)}:$twoDigitMinutes:$twoDigitSeconds'; } - Widget _buildAttachment(BuildContext context) { + Widget _buildAttachment(BuildContext context, {bool isMinimal = false}) { final attachments = item.body['attachments'] != null ? List.from(item.body['attachments'].map((x) => x)) : List.empty(); if (attachments.isEmpty) return const SizedBox(); + if (isMinimal) { + final unFocusColor = + Theme.of(context).colorScheme.onSurface.withOpacity(0.75); + return Row( + children: [ + Icon( + Icons.attachment, + size: 18, + color: unFocusColor, + ).paddingOnly(right: 6), + Text( + 'attachmentHint'.trParams( + {'count': attachments.length.toString()}, + ), + style: TextStyle(color: unFocusColor), + ) + ], + ); + } + return Container( key: Key('m${item.uuid}attachments-box'), width: MediaQuery.of(context).size.width, @@ -164,7 +184,8 @@ class ChatEvent extends StatelessWidget { ), ], ).paddingOnly(right: 12), - _buildAttachment(context), + _buildAttachment(context, isMinimal: isContentPreviewing) + .paddingOnly(left: isContentPreviewing ? 12 : 0), ], ); } else if (isQuote) { diff --git a/lib/widgets/chat/chat_event_message.dart b/lib/widgets/chat/chat_event_message.dart index 2fdbdaa..146dccd 100644 --- a/lib/widgets/chat/chat_event_message.dart +++ b/lib/widgets/chat/chat_event_message.dart @@ -24,7 +24,8 @@ class ChatEventMessage extends StatelessWidget { final hasAttachment = body.attachments?.isNotEmpty ?? false; if (body.text.isEmpty && hasAttachment) { - final unFocusColor = Theme.of(context).colorScheme.onSurface.withOpacity(0.75); + final unFocusColor = + Theme.of(context).colorScheme.onSurface.withOpacity(0.75); return Row( children: [ Icon( @@ -33,7 +34,7 @@ class ChatEventMessage extends StatelessWidget { color: unFocusColor, ).paddingOnly(right: 6), Text( - 'postAttachmentTip'.trParams( + 'attachmentHint'.trParams( {'count': body.attachments?.length.toString() ?? 0.toString()}, ), style: TextStyle(color: unFocusColor), @@ -46,9 +47,7 @@ class ChatEventMessage extends StatelessWidget { } Widget _buildBody(BuildContext context) { - if (isContentPreviewing) { - return _buildContent(context); - } else if (isMerged) { + if (isMerged) { return _buildContent(context).paddingOnly(left: 52); } else { return _buildContent(context); @@ -64,7 +63,7 @@ class ChatEventMessage extends StatelessWidget { left: isQuote ? 0 : 12, right: isQuote ? 0 : 12, top: body.quoteEvent == null ? 2 : 0, - bottom: hasAttachment ? 4 : (isHasMerged ? 2 : 0), + bottom: hasAttachment && !isContentPreviewing ? 4 : (isHasMerged ? 2 : 0), ); } } diff --git a/lib/widgets/posts/post_item.dart b/lib/widgets/posts/post_item.dart index 3f18c9e..ffeef16 100644 --- a/lib/widgets/posts/post_item.dart +++ b/lib/widgets/posts/post_item.dart @@ -253,7 +253,7 @@ class _PostItemState extends State { color: _unFocusColor, ).paddingOnly(right: 6), Text( - 'postAttachmentTip'.trParams( + 'attachmentHint'.trParams( {'count': attachments.length.toString()}, ), style: TextStyle(color: _unFocusColor),