From 5365082e4a10ebb69a90872a85fa93f8227a91c8 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 4 Dec 2020 15:42:26 +0100 Subject: [PATCH] fix giphy background --- lib/src/message_widget.dart | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index e5fe146f..f761f756 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -186,9 +186,7 @@ class MessageWidget extends StatefulWidget { 'giphy': (context, message, attachment) { return GiphyAttachment( attachment: attachment, - messageTheme: messageTheme.copyWith( - messageBackgroundColor: Colors.white, - ), + messageTheme: messageTheme, message: message, size: Size( MediaQuery.of(context).size.width * 0.8, @@ -219,13 +217,6 @@ class _MessageWidgetState extends State { ? widget.messageTheme.avatarTheme.constraints.maxWidth + 16.0 : 6.0; - final isGiphy = - widget.message.attachments?.any((element) => element.type == 'giphy') == - true; - - final isOnlyEmoji = - widget.message.text.characters.every((c) => Emoji.byChar(c) != null); - final hasFiles = widget.message.attachments?.any((element) => element.type == 'file') == true; @@ -484,6 +475,10 @@ class _MessageWidgetState extends State { ); } + bool get isGiphy => + widget.message.attachments?.any((element) => element.type == 'giphy') == + true; + Widget _buildReadIndicator() { var padding = 0.0; return Stack( @@ -675,9 +670,8 @@ class _MessageWidgetState extends State { onTap: () => retryMessage(context), onLongPress: () => onLongPress(context), child: Material( - color: - attachment?.type == 'giphy' ? Colors.white : _getBackgroundColor(), - clipBehavior: Clip.hardEdge, + color: _getBackgroundColor(), + clipBehavior: Clip.antiAlias, shape: attachmentShape, child: Padding( padding: widget.attachmentPadding, @@ -828,9 +822,6 @@ class _MessageWidgetState extends State { } Widget _buildTextBubble(BuildContext context) { - final isOnlyEmoji = - widget.message.text.characters.every((c) => Emoji.byChar(c) != null); - Widget child = Transform( transform: Matrix4.rotationY(widget.reverse ? pi : 0), alignment: Alignment.center, @@ -874,10 +865,11 @@ class _MessageWidgetState extends State { ); } - Color _getBackgroundColor() { - final isOnlyEmoji = - widget.message.text.characters.every((c) => Emoji.byChar(c) != null); + bool get isOnlyEmoji => + widget.message.text.characters.isNotEmpty && + widget.message.text.characters.every((c) => Emoji.byChar(c) != null); + Color _getBackgroundColor() { if ((widget.message.status == MessageSendingStatus.FAILED || widget.message.status == MessageSendingStatus.FAILED_UPDATE || widget.message.status == MessageSendingStatus.FAILED_DELETE)) { @@ -893,6 +885,11 @@ class _MessageWidgetState extends State { if (isOnlyEmoji) { return Colors.transparent; } + + if (isGiphy) { + return Colors.transparent; + } + return widget.messageTheme.messageBackgroundColor; }