🐛 Fix content previewing will show attachments
This commit is contained in:
parent
47d03ce1e5
commit
9765b200b9
@ -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',
|
||||
|
@ -124,7 +124,7 @@ const i18nSimplifiedChinese = {
|
||||
'postEdited': '编辑于 @date',
|
||||
'postNewCreated': '创建于 @date',
|
||||
'postInRealm': '发表于 @realm',
|
||||
'postAttachmentTip': '@count 个附件',
|
||||
'attachmentHint': '@count 个附件',
|
||||
'postDetail': '帖子详情',
|
||||
'postReplies': '帖子回复',
|
||||
'postPublish': '编辑帖子',
|
||||
|
@ -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<int>.from(item.body['attachments'].map((x) => x))
|
||||
: List<int>.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) {
|
||||
|
@ -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),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ class _PostItemState extends State<PostItem> {
|
||||
color: _unFocusColor,
|
||||
).paddingOnly(right: 6),
|
||||
Text(
|
||||
'postAttachmentTip'.trParams(
|
||||
'attachmentHint'.trParams(
|
||||
{'count': attachments.length.toString()},
|
||||
),
|
||||
style: TextStyle(color: _unFocusColor),
|
||||
|
Loading…
Reference in New Issue
Block a user