Skip to content

Commit 64253d7

Browse files
authored
improvements on attachment in quote (#2538)
1 parent a3a9518 commit 64253d7

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

melos.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ command:
9595
stream_core_flutter:
9696
git:
9797
url: https://github.com/GetStream/stream-core-flutter.git
98-
ref: c7a31449e8632ea43f8c769be95a30ef9393a792
98+
ref: 8057a775c2ed764dbd5cbabd2dd60d3cd68d2f08
9999
path: packages/stream_core_flutter
100100
synchronized: ^3.1.0+1
101101
thumblr: ^0.0.4

packages/stream_chat_flutter/lib/src/components/message_composer/message_composer_input_header.dart

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,24 +176,54 @@ class _QuotedMessageInHeader extends StatelessWidget {
176176
if (attachments.isEmpty || attachments.length > 1) return null;
177177

178178
final attachment = attachments.first;
179+
if (attachment.type == AttachmentType.file) return null;
179180
final imageUrl = attachment.imageUrl ?? attachment.thumbUrl ?? attachment.assetUrl;
180181

181182
if (imageUrl == null) return null;
182183
return CachedNetworkImageProvider(imageUrl);
183184
}
184185

186+
String? _mimeTypeAttachment(Message message) {
187+
final attachments = message.attachments;
188+
if (attachments.isEmpty) return null;
189+
final attachment = attachments.first;
190+
191+
if (attachment.type != AttachmentType.file) return null;
192+
if (attachments.any((it) => it.mimeType != attachment.mimeType)) return null;
193+
194+
return attachment.mimeType;
195+
}
196+
185197
@override
186198
Widget build(BuildContext context) {
187199
final isIncoming = currentUserId != quotedMessage.user?.id;
188200

201+
final image = _imageProvider(quotedMessage);
202+
final mimeType = _mimeTypeAttachment(quotedMessage);
203+
204+
Widget? trailing;
205+
if (image != null) {
206+
Container(
207+
width: 40,
208+
height: 40,
209+
decoration: BoxDecoration(
210+
borderRadius: BorderRadius.all(context.streamRadius.md),
211+
image: DecorationImage(image: image, fit: BoxFit.cover),
212+
),
213+
);
214+
} else if (mimeType != null) {
215+
trailing = StreamFileTypeIcon.fromMimeType(mimeType: mimeType);
216+
} else {
217+
trailing = null;
218+
}
219+
189220
return
190-
// TODO: improve attachment and add trailing to the component instead.
191221
// TODO: localize strings
192222
MessageComposerReplyAttachment(
193223
title: Text(isIncoming ? 'Reply to ${quotedMessage.user?.name}' : 'You'),
194224
subtitle: StreamMessagePreviewText(message: quotedMessage),
195225
onRemovePressed: onRemovePressed,
196-
image: _imageProvider(quotedMessage),
226+
trailing: trailing,
197227
style: isIncoming ? .incoming : .outgoing,
198228
);
199229
}

packages/stream_chat_flutter/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ dependencies:
6262
stream_core_flutter:
6363
git:
6464
url: https://github.com/GetStream/stream-core-flutter.git
65-
ref: c7a31449e8632ea43f8c769be95a30ef9393a792
65+
ref: 8057a775c2ed764dbd5cbabd2dd60d3cd68d2f08
6666
path: packages/stream_core_flutter
6767
svg_icon_widget: ^0.0.1
6868
synchronized: ^3.1.0+1

0 commit comments

Comments
 (0)