diff --git a/lib/src/message_actions_modal.dart b/lib/src/message_actions_modal.dart index 9b93695e..2f4e0f8b 100644 --- a/lib/src/message_actions_modal.dart +++ b/lib/src/message_actions_modal.dart @@ -32,6 +32,7 @@ class MessageActionsModal extends StatefulWidget { final bool showFlagButton; final bool reverse; final ShapeBorder messageShape; + final ShapeBorder attachmentShape; final DisplayWidget showUserAvatar; const MessageActionsModal({ @@ -51,6 +52,7 @@ class MessageActionsModal extends StatefulWidget { this.showUserAvatar = DisplayWidget.show, this.editMessageInputBuilder, this.messageShape, + this.attachmentShape, this.reverse = false, }) : super(key: key); @@ -173,6 +175,7 @@ class _MessageActionsModalState extends State { showInChannelIndicator: false, showSendingIndicator: false, shape: widget.messageShape, + attachmentShape: widget.attachmentShape, ), ), SizedBox(height: 8), diff --git a/lib/src/message_reactions_modal.dart b/lib/src/message_reactions_modal.dart index c96b3afa..e09e21db 100644 --- a/lib/src/message_reactions_modal.dart +++ b/lib/src/message_reactions_modal.dart @@ -20,6 +20,7 @@ class MessageReactionsModal extends StatelessWidget { final bool showReactions; final DisplayWidget showUserAvatar; final ShapeBorder messageShape; + final ShapeBorder attachmentShape; final void Function(User) onUserAvatarTap; const MessageReactionsModal({ @@ -30,6 +31,7 @@ class MessageReactionsModal extends StatelessWidget { this.onThreadTap, this.editMessageInputBuilder, this.messageShape, + this.attachmentShape, this.reverse = false, this.showUserAvatar = DisplayWidget.show, this.onUserAvatarTap, @@ -127,6 +129,7 @@ class MessageReactionsModal extends StatelessWidget { translateUserAvatar: false, showSendingIndicator: false, shape: messageShape, + attachmentShape: attachmentShape, padding: const EdgeInsets.all(0), attachmentPadding: EdgeInsets.all( hasFileAttachment ? 4 : 2, diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 070bdad5..bec93cc1 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -295,10 +295,6 @@ class _MessageWidgetState extends State { var leftPadding = widget.showUserAvatar != DisplayWidget.gone ? avatarWidth + 8.5 : 0.5; - final hasFiles = - widget.message.attachments?.any((element) => element.type == 'file') == - true; - return Material( type: MaterialType.transparency, child: Portal( @@ -406,29 +402,19 @@ class _MessageWidgetState extends State { BorderRadius.zero, ), color: _getBackgroundColor(), - child: Padding( - padding: EdgeInsets.all( - hasFiles ? 2.0 : 0.0), - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .end, - mainAxisSize: - MainAxisSize.min, - children: [ - if (hasQuotedMessage) - _buildQuotedMessage(), - if (hasNonUrlAttachments) - _parseAttachments( - context), - if (widget.message.text - .trim() - .isNotEmpty && - !isGiphy) - _buildTextBubble( - context), - ], - ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.end, + mainAxisSize: + MainAxisSize.min, + children: [ + if (hasQuotedMessage) + _buildQuotedMessage(), + if (hasNonUrlAttachments) + _parseAttachments(), + if (!isGiphy) + _buildTextBubble(), + ], ), ), ), @@ -718,6 +704,8 @@ class _MessageWidgetState extends State { : DisplayWidget.show, messageTheme: widget.messageTheme, messageShape: widget.shape ?? _getDefaultShape(context), + attachmentShape: + widget.attachmentShape ?? _getDefaultAttachmentShape(context), reverse: widget.reverse, showDeleteMessage: widget.showDeleteMessage || isDeleteFailed, message: widget.message, @@ -763,6 +751,8 @@ class _MessageWidgetState extends State { onUserAvatarTap: widget.onUserAvatarTap, messageTheme: widget.messageTheme, messageShape: widget.shape ?? _getDefaultShape(context), + attachmentShape: + widget.attachmentShape ?? _getDefaultAttachmentShape(context), reverse: widget.reverse, message: widget.message, editMessageInputBuilder: widget.editMessageInputBuilder, @@ -773,20 +763,31 @@ class _MessageWidgetState extends State { }); } - ShapeBorder _getDefaultShape(BuildContext context) { + ShapeBorder _getDefaultAttachmentShape(BuildContext context) { + final hasFiles = + widget.message.attachments?.any((it) => it.type == 'file') == true; return RoundedRectangleBorder( - side: widget.attachmentBorderSide ?? - widget.borderSide ?? - BorderSide( - color: StreamChatTheme.of(context).colorTheme.greyWhisper, - ), - borderRadius: widget.attachmentBorderRadiusGeometry ?? - widget.borderRadiusGeometry ?? - BorderRadius.zero, + side: hasFiles + ? widget.attachmentBorderSide ?? + BorderSide( + color: StreamChatTheme.of(context).colorTheme.greyWhisper, + ) + : BorderSide.none, + borderRadius: widget.attachmentBorderRadiusGeometry ?? BorderRadius.zero, ); } - Widget _parseAttachments(BuildContext context) { + ShapeBorder _getDefaultShape(BuildContext context) { + return RoundedRectangleBorder( + side: widget.borderSide ?? + BorderSide( + color: StreamChatTheme.of(context).colorTheme.greyWhisper, + ), + borderRadius: widget.borderRadiusGeometry ?? BorderRadius.zero, + ); + } + + Widget _parseAttachments() { final images = widget.message.attachments ?.where((element) => element.type == 'image' && element.ogScrapeUrl == null) @@ -849,7 +850,7 @@ class _MessageWidgetState extends State { Attachment attachment, }) { final attachmentShape = - widget.attachmentShape ?? widget.shape ?? _getDefaultShape(context); + widget.attachmentShape ?? _getDefaultAttachmentShape(context); return Material( clipBehavior: Clip.antiAlias, shape: attachmentShape, @@ -920,7 +921,8 @@ class _MessageWidgetState extends State { ), ); - Widget _buildTextBubble(BuildContext context) { + Widget _buildTextBubble() { + if (widget.message.text.trim().isNotEmpty) return Offstage(); return Transform( transform: Matrix4.rotationY(widget.reverse ? pi : 0), alignment: Alignment.center,