From fff72891fc326883223413df786acbccaf06e2e2 Mon Sep 17 00:00:00 2001 From: Rene Floor Date: Thu, 12 Mar 2026 17:00:31 +0100 Subject: [PATCH] improvements on attachment in quote --- melos.yaml | 2 +- .../message_composer_input_header.dart | 34 +++++++++++++++++-- packages/stream_chat_flutter/pubspec.yaml | 2 +- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/melos.yaml b/melos.yaml index a2ef7e684..a38797071 100644 --- a/melos.yaml +++ b/melos.yaml @@ -95,7 +95,7 @@ command: stream_core_flutter: git: url: https://github.com/GetStream/stream-core-flutter.git - ref: 213dfb64b1d0c22a668a4a0924503703ff9a33e9 + ref: cfd8698d92b23aac55d846989534919fced432eb path: packages/stream_core_flutter synchronized: ^3.1.0+1 thumblr: ^0.0.4 diff --git a/packages/stream_chat_flutter/lib/src/components/message_composer/message_composer_input_header.dart b/packages/stream_chat_flutter/lib/src/components/message_composer/message_composer_input_header.dart index 4f4a5e97d..257985c7d 100644 --- a/packages/stream_chat_flutter/lib/src/components/message_composer/message_composer_input_header.dart +++ b/packages/stream_chat_flutter/lib/src/components/message_composer/message_composer_input_header.dart @@ -176,24 +176,54 @@ class _QuotedMessageInHeader extends StatelessWidget { if (attachments.isEmpty || attachments.length > 1) return null; final attachment = attachments.first; + if (attachment.type == AttachmentType.file) return null; final imageUrl = attachment.imageUrl ?? attachment.thumbUrl ?? attachment.assetUrl; if (imageUrl == null) return null; return CachedNetworkImageProvider(imageUrl); } + String? _mimeTypeAttachment(Message message) { + final attachments = message.attachments; + if (attachments.isEmpty) return null; + final attachment = attachments.first; + + if (attachment.type != AttachmentType.file) return null; + if (attachments.any((it) => it.mimeType != attachment.mimeType)) return null; + + return attachment.mimeType; + } + @override Widget build(BuildContext context) { final isIncoming = currentUserId != quotedMessage.user?.id; + final image = _imageProvider(quotedMessage); + final mimeType = _mimeTypeAttachment(quotedMessage); + + Widget? trailing; + if (image != null) { + Container( + width: 40, + height: 40, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(context.streamRadius.md), + image: DecorationImage(image: image, fit: BoxFit.cover), + ), + ); + } else if (mimeType != null) { + trailing = StreamFileTypeIcon.fromMimeType(mimeType: mimeType); + } else { + trailing = null; + } + return - // TODO: improve attachment and add trailing to the component instead. // TODO: localize strings MessageComposerReplyAttachment( title: Text(isIncoming ? 'Reply to ${quotedMessage.user?.name}' : 'You'), subtitle: StreamMessagePreviewText(message: quotedMessage), onRemovePressed: onRemovePressed, - image: _imageProvider(quotedMessage), + trailing: trailing, style: isIncoming ? .incoming : .outgoing, ); } diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index ab86210cd..fce77b0d2 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -62,7 +62,7 @@ dependencies: stream_core_flutter: git: url: https://github.com/GetStream/stream-core-flutter.git - ref: 213dfb64b1d0c22a668a4a0924503703ff9a33e9 + ref: cfd8698d92b23aac55d846989534919fced432eb path: packages/stream_core_flutter svg_icon_widget: ^0.0.1 synchronized: ^3.1.0+1