🐛 Fix content previewing will show attachments
This commit is contained in:
parent
47d03ce1e5
commit
9765b200b9
@ -129,7 +129,7 @@ const i18nEnglish = {
|
|||||||
'postAction': 'Post',
|
'postAction': 'Post',
|
||||||
'postEdited': 'Edited at @date',
|
'postEdited': 'Edited at @date',
|
||||||
'postNewCreated': 'Created at @date',
|
'postNewCreated': 'Created at @date',
|
||||||
'postAttachmentTip': '@count attachment(s)',
|
'attachmentHint': '@count attachment(s)',
|
||||||
'postInRealm': 'In @realm',
|
'postInRealm': 'In @realm',
|
||||||
'postDetail': 'Post',
|
'postDetail': 'Post',
|
||||||
'postReplies': 'Replies',
|
'postReplies': 'Replies',
|
||||||
|
@ -124,7 +124,7 @@ const i18nSimplifiedChinese = {
|
|||||||
'postEdited': '编辑于 @date',
|
'postEdited': '编辑于 @date',
|
||||||
'postNewCreated': '创建于 @date',
|
'postNewCreated': '创建于 @date',
|
||||||
'postInRealm': '发表于 @realm',
|
'postInRealm': '发表于 @realm',
|
||||||
'postAttachmentTip': '@count 个附件',
|
'attachmentHint': '@count 个附件',
|
||||||
'postDetail': '帖子详情',
|
'postDetail': '帖子详情',
|
||||||
'postReplies': '帖子回复',
|
'postReplies': '帖子回复',
|
||||||
'postPublish': '编辑帖子',
|
'postPublish': '编辑帖子',
|
||||||
|
@ -37,13 +37,33 @@ class ChatEvent extends StatelessWidget {
|
|||||||
return '$negativeSign${twoDigits(duration.inHours)}:$twoDigitMinutes:$twoDigitSeconds';
|
return '$negativeSign${twoDigits(duration.inHours)}:$twoDigitMinutes:$twoDigitSeconds';
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAttachment(BuildContext context) {
|
Widget _buildAttachment(BuildContext context, {bool isMinimal = false}) {
|
||||||
final attachments = item.body['attachments'] != null
|
final attachments = item.body['attachments'] != null
|
||||||
? List<int>.from(item.body['attachments'].map((x) => x))
|
? List<int>.from(item.body['attachments'].map((x) => x))
|
||||||
: List<int>.empty();
|
: List<int>.empty();
|
||||||
|
|
||||||
if (attachments.isEmpty) return const SizedBox();
|
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(
|
return Container(
|
||||||
key: Key('m${item.uuid}attachments-box'),
|
key: Key('m${item.uuid}attachments-box'),
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
@ -164,7 +184,8 @@ class ChatEvent extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
).paddingOnly(right: 12),
|
).paddingOnly(right: 12),
|
||||||
_buildAttachment(context),
|
_buildAttachment(context, isMinimal: isContentPreviewing)
|
||||||
|
.paddingOnly(left: isContentPreviewing ? 12 : 0),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else if (isQuote) {
|
} else if (isQuote) {
|
||||||
|
@ -24,7 +24,8 @@ class ChatEventMessage extends StatelessWidget {
|
|||||||
final hasAttachment = body.attachments?.isNotEmpty ?? false;
|
final hasAttachment = body.attachments?.isNotEmpty ?? false;
|
||||||
|
|
||||||
if (body.text.isEmpty && hasAttachment) {
|
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(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
@ -33,7 +34,7 @@ class ChatEventMessage extends StatelessWidget {
|
|||||||
color: unFocusColor,
|
color: unFocusColor,
|
||||||
).paddingOnly(right: 6),
|
).paddingOnly(right: 6),
|
||||||
Text(
|
Text(
|
||||||
'postAttachmentTip'.trParams(
|
'attachmentHint'.trParams(
|
||||||
{'count': body.attachments?.length.toString() ?? 0.toString()},
|
{'count': body.attachments?.length.toString() ?? 0.toString()},
|
||||||
),
|
),
|
||||||
style: TextStyle(color: unFocusColor),
|
style: TextStyle(color: unFocusColor),
|
||||||
@ -46,9 +47,7 @@ class ChatEventMessage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody(BuildContext context) {
|
Widget _buildBody(BuildContext context) {
|
||||||
if (isContentPreviewing) {
|
if (isMerged) {
|
||||||
return _buildContent(context);
|
|
||||||
} else if (isMerged) {
|
|
||||||
return _buildContent(context).paddingOnly(left: 52);
|
return _buildContent(context).paddingOnly(left: 52);
|
||||||
} else {
|
} else {
|
||||||
return _buildContent(context);
|
return _buildContent(context);
|
||||||
@ -64,7 +63,7 @@ class ChatEventMessage extends StatelessWidget {
|
|||||||
left: isQuote ? 0 : 12,
|
left: isQuote ? 0 : 12,
|
||||||
right: isQuote ? 0 : 12,
|
right: isQuote ? 0 : 12,
|
||||||
top: body.quoteEvent == null ? 2 : 0,
|
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,
|
color: _unFocusColor,
|
||||||
).paddingOnly(right: 6),
|
).paddingOnly(right: 6),
|
||||||
Text(
|
Text(
|
||||||
'postAttachmentTip'.trParams(
|
'attachmentHint'.trParams(
|
||||||
{'count': attachments.length.toString()},
|
{'count': attachments.length.toString()},
|
||||||
),
|
),
|
||||||
style: TextStyle(color: _unFocusColor),
|
style: TextStyle(color: _unFocusColor),
|
||||||
|
Loading…
Reference in New Issue
Block a user