From 7e314f86db2dcfa8119c9a95505ff7ae0e33f974 Mon Sep 17 00:00:00 2001 From: TinhHuynh Date: Wed, 10 Jul 2024 15:48:05 +0700 Subject: [PATCH] added showFailedIndicator parameter to MessageCard --- .../lib/src/message_widget/message_card.dart | 9 +++++++-- .../lib/src/message_widget/message_widget.dart | 2 ++ .../lib/src/message_widget/message_widget_content.dart | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_widget/message_card.dart b/packages/stream_chat_flutter/lib/src/message_widget/message_card.dart index 0c981ad79..0fe2eeba2 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/message_card.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/message_card.dart @@ -28,6 +28,7 @@ class MessageCard extends StatefulWidget { required this.attachmentActionsModalBuilder, required this.textPadding, required this.reverse, + required this.showFailedIndicator, this.shape, this.borderSide, this.borderRadiusGeometry, @@ -116,6 +117,9 @@ class MessageCard extends StatefulWidget { /// {@macro reverse} final bool reverse; + /// {@macro showFailedIndicator} + final bool showFailedIndicator; + @override State createState() => _MessageCardState(); } @@ -161,8 +165,9 @@ class _MessageCardState extends State { return Container( constraints: const BoxConstraints().copyWith(maxWidth: widthLimit), margin: EdgeInsets.symmetric( - horizontal: (widget.isFailedState ? 15.0 : 0.0) + - (widget.showUserAvatar == DisplayWidget.gone ? 0 : 4.0), + horizontal: + (widget.isFailedState && widget.showFailedIndicator ? 15.0 : 0.0) + + (widget.showUserAvatar == DisplayWidget.gone ? 0 : 4.0), ), clipBehavior: Clip.hardEdge, decoration: ShapeDecoration( diff --git a/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart b/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart index 963309e18..bb3c03519 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/message_widget.dart @@ -451,6 +451,7 @@ class StreamMessageWidget extends StatefulWidget { String? imageAttachmentThumbnailResizeType, String? imageAttachmentThumbnailCropType, AttachmentActionsBuilder? attachmentActionsModalBuilder, + bool? showFailedIndicator }) { return StreamMessageWidget( key: key ?? this.key, @@ -520,6 +521,7 @@ class StreamMessageWidget extends StatefulWidget { this.imageAttachmentThumbnailCropType, attachmentActionsModalBuilder: attachmentActionsModalBuilder ?? this.attachmentActionsModalBuilder, + showFailedIndicator: showFailedIndicator ?? this.showFailedIndicator, ); } diff --git a/packages/stream_chat_flutter/lib/src/message_widget/message_widget_content.dart b/packages/stream_chat_flutter/lib/src/message_widget/message_widget_content.dart index 440e2d31b..4148b1142 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/message_widget_content.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/message_widget_content.dart @@ -332,6 +332,8 @@ class MessageWidgetContent extends StatelessWidget { : MessageCard( message: message, isFailedState: isFailedState, + showFailedIndicator: + showFailedIndicator, showUserAvatar: showUserAvatar, messageTheme: messageTheme, hasQuotedMessage: hasQuotedMessage,