fix emoji only messages
This commit is contained in:
+23
-29
@@ -223,9 +223,10 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
widget.message.attachments?.any((element) => element.type == 'giphy') ==
|
widget.message.attachments?.any((element) => element.type == 'giphy') ==
|
||||||
true;
|
true;
|
||||||
|
|
||||||
var user = StreamChat.of(context).user;
|
final isOnlyEmoji =
|
||||||
|
widget.message.text.characters.every((c) => Emoji.byChar(c) != null);
|
||||||
|
|
||||||
bool hasFiles =
|
final hasFiles =
|
||||||
widget.message.attachments.any((element) => element.type == 'file');
|
widget.message.attachments.any((element) => element.type == 'file');
|
||||||
|
|
||||||
return Portal(
|
return Portal(
|
||||||
@@ -304,16 +305,20 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
shape: widget.shape ??
|
shape: widget.shape ??
|
||||||
RoundedRectangleBorder(
|
RoundedRectangleBorder(
|
||||||
side: widget.borderSide ??
|
side: isOnlyEmoji
|
||||||
BorderSide(
|
? BorderSide.none
|
||||||
color: Theme.of(context)
|
: widget.borderSide ??
|
||||||
.brightness ==
|
BorderSide(
|
||||||
Brightness.dark
|
color: Theme.of(context)
|
||||||
? Colors.white
|
.brightness ==
|
||||||
.withAlpha(24)
|
Brightness
|
||||||
: Colors.black
|
.dark
|
||||||
.withAlpha(24),
|
? Colors.white
|
||||||
),
|
.withAlpha(24)
|
||||||
|
: Colors.black
|
||||||
|
.withAlpha(
|
||||||
|
24),
|
||||||
|
),
|
||||||
borderRadius: widget
|
borderRadius: widget
|
||||||
.borderRadiusGeometry ??
|
.borderRadiusGeometry ??
|
||||||
BorderRadius.zero,
|
BorderRadius.zero,
|
||||||
@@ -821,16 +826,6 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
return SizedBox();
|
return SizedBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _wrapTextInBubble({
|
|
||||||
BuildContext context,
|
|
||||||
Widget child,
|
|
||||||
}) {
|
|
||||||
return Container(
|
|
||||||
color: _getBackgroundColor(),
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildTextBubble(BuildContext context) {
|
Widget _buildTextBubble(BuildContext context) {
|
||||||
final isOnlyEmoji =
|
final isOnlyEmoji =
|
||||||
widget.message.text.characters.every((c) => Emoji.byChar(c) != null);
|
widget.message.text.characters.every((c) => Emoji.byChar(c) != null);
|
||||||
@@ -871,13 +866,6 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!isOnlyEmoji) {
|
|
||||||
child = _wrapTextInBubble(
|
|
||||||
context: context,
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => retryMessage(context),
|
onTap: () => retryMessage(context),
|
||||||
onLongPress: () => onLongPress(context),
|
onLongPress: () => onLongPress(context),
|
||||||
@@ -886,6 +874,9 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Color _getBackgroundColor() {
|
Color _getBackgroundColor() {
|
||||||
|
final isOnlyEmoji =
|
||||||
|
widget.message.text.characters.every((c) => Emoji.byChar(c) != null);
|
||||||
|
|
||||||
if ((widget.message.status == MessageSendingStatus.FAILED ||
|
if ((widget.message.status == MessageSendingStatus.FAILED ||
|
||||||
widget.message.status == MessageSendingStatus.FAILED_UPDATE ||
|
widget.message.status == MessageSendingStatus.FAILED_UPDATE ||
|
||||||
widget.message.status == MessageSendingStatus.FAILED_DELETE)) {
|
widget.message.status == MessageSendingStatus.FAILED_DELETE)) {
|
||||||
@@ -898,6 +889,9 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
return Color(0xFFE9F2FF);
|
return Color(0xFFE9F2FF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isOnlyEmoji) {
|
||||||
|
return Colors.transparent;
|
||||||
|
}
|
||||||
return widget.messageTheme.messageBackgroundColor;
|
return widget.messageTheme.messageBackgroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user