getMessageBubble static method
Widget
getMessageBubble({
- required BaseMessage message,
- CometChatMessageTemplate? template,
- required BubbleAlignment bubbleAlignment,
- required CometChatColorPalette colorPalette,
- required CometChatTypography typography,
- required CometChatSpacing spacing,
- required BuildContext context,
- List<
CometChatTextFormatter> ? textFormatters, - CometChatOutgoingMessageBubbleStyle? outgoingMessageBubbleStyle,
- CometChatIncomingMessageBubbleStyle? incomingMessageBubbleStyle,
- Key? key,
- bool? receiptsVisibility,
Implementation
static Widget getMessageBubble({
required BaseMessage message,
CometChatMessageTemplate? template,
required BubbleAlignment bubbleAlignment,
required CometChatColorPalette colorPalette,
required CometChatTypography typography,
required CometChatSpacing spacing,
required BuildContext context,
List<CometChatTextFormatter>? textFormatters,
CometChatOutgoingMessageBubbleStyle? outgoingMessageBubbleStyle,
CometChatIncomingMessageBubbleStyle? incomingMessageBubbleStyle,
Key? key,
bool? receiptsVisibility,
}) {
if (message.deletedAt == null && template?.bubbleView != null) {
return template?.bubbleView!(message, context, BubbleAlignment.left) ??
const SizedBox();
}
Widget? contentView;
Widget? statusInfoView;
Widget? leadingView;
Widget? headerView;
final outgoingMessageBubbleStyle0 =
CometChatThemeHelper.getTheme<CometChatOutgoingMessageBubbleStyle>(
context: context,
defaultTheme: CometChatOutgoingMessageBubbleStyle.of)
.merge(outgoingMessageBubbleStyle);
final incomingMessageBubbleStyle0 =
CometChatThemeHelper.getTheme<CometChatIncomingMessageBubbleStyle>(
context: context,
defaultTheme: CometChatIncomingMessageBubbleStyle.of)
.merge(incomingMessageBubbleStyle);
final bubbleStyleData = BubbleUIBuilder.getBubbleStyle(
message,
outgoingMessageBubbleStyle0,
incomingMessageBubbleStyle0,
colorPalette,
typography,
spacing);
final additionalConfigurations =
BubbleUIBuilder.getAdditionalConfigurations(
context,
message,
textFormatters,
incomingMessageBubbleStyle0,
outgoingMessageBubbleStyle0,
null);
contentView = _getSuitableContentView(message, colorPalette, context,
template, bubbleAlignment, additionalConfigurations);
statusInfoView = _getStatusInfoView(
bubbleAlignment,
message,
context,
colorPalette,
typography,
spacing,
template,
bubbleStyleData?.messageBubbleDateStyle,
bubbleStyleData?.messageReceiptStyle,
receiptsVisibility,
);
leadingView = _getAvatar(
bubbleAlignment,
message,
context,
colorPalette,
typography,
spacing,
template,
bubbleStyleData?.messageBubbleAvatarStyle,
);
headerView = _getHeaderView(
bubbleAlignment,
message,
context,
colorPalette,
typography,
spacing,
template,
bubbleStyleData,
);
Color backgroundColor = bubbleStyleData?.backgroundColor ??
_getBubbleBackgroundColor(
message,
template,
colorPalette,
bubbleAlignment,
);
return Column(
key: key,
children: [
Row(
mainAxisAlignment: bubbleAlignment == BubbleAlignment.left
? MainAxisAlignment.start
: bubbleAlignment == BubbleAlignment.center
? MainAxisAlignment.center
: MainAxisAlignment.end,
children: [
CometChatMessageBubble(
style: CometChatMessageBubbleStyle(
backgroundColor: backgroundColor,
border: bubbleStyleData?.border,
borderRadius: bubbleStyleData?.borderRadius,
backgroundImage: bubbleStyleData?.messageBubbleBackgroundImage,
),
headerView: headerView,
alignment: bubbleAlignment,
contentView: contentView,
footerView: const SizedBox(),
leadingView: leadingView,
statusInfoView: statusInfoView,
),
],
),
],
);
}