chore: update message_theme.dart
Includes Diagnosticable, more descriptive field names, lerp, ==, and hashCode
This commit is contained in:
@@ -63,9 +63,9 @@ class MyApp extends StatelessWidget {
|
|||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
otherMessageTheme: MessageTheme(
|
otherMessageTheme: MessageThemeData(
|
||||||
messageBackgroundColor: colorTheme.textHighEmphasis,
|
messageBackgroundColor: colorTheme.textHighEmphasis,
|
||||||
messageText: TextStyle(
|
messageTextStyle: TextStyle(
|
||||||
color: colorTheme.barsBg,
|
color: colorTheme.barsBg,
|
||||||
),
|
),
|
||||||
avatarTheme: AvatarThemeData(
|
avatarTheme: AvatarThemeData(
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class AttachmentTitle extends StatelessWidget {
|
|||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// Theme to apply to text
|
/// Theme to apply to text
|
||||||
final MessageTheme messageTheme;
|
final MessageThemeData messageTheme;
|
||||||
|
|
||||||
/// Attachment data to display
|
/// Attachment data to display
|
||||||
final Attachment attachment;
|
final Attachment attachment;
|
||||||
@@ -35,7 +35,7 @@ class AttachmentTitle extends StatelessWidget {
|
|||||||
Text(
|
Text(
|
||||||
attachment.title!,
|
attachment.title!,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: messageTheme.messageText?.copyWith(
|
style: messageTheme.messageTextStyle?.copyWith(
|
||||||
color: StreamChatTheme.of(context).colorTheme.accentPrimary,
|
color: StreamChatTheme.of(context).colorTheme.accentPrimary,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
@@ -51,7 +51,7 @@ class AttachmentTitle extends StatelessWidget {
|
|||||||
.toList()
|
.toList()
|
||||||
.reversed
|
.reversed
|
||||||
.join('.'),
|
.join('.'),
|
||||||
style: messageTheme.messageText,
|
style: messageTheme.messageTextStyle,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ class ImageAttachment extends AttachmentWidget {
|
|||||||
size: size,
|
size: size,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// [MessageTheme] for showing image title
|
/// [MessageThemeData] for showing image title
|
||||||
final MessageTheme messageTheme;
|
final MessageThemeData messageTheme;
|
||||||
|
|
||||||
/// Flag for showing title
|
/// Flag for showing title
|
||||||
final bool showTitle;
|
final bool showTitle;
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ class VideoAttachment extends AttachmentWidget {
|
|||||||
size: size,
|
size: size,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// [MessageTheme] for showing title
|
/// [MessageThemeData] for showing title
|
||||||
final MessageTheme messageTheme;
|
final MessageThemeData messageTheme;
|
||||||
|
|
||||||
/// Callback when show message is tapped
|
/// Callback when show message is tapped
|
||||||
final ShowMessageCallback? onShowMessage;
|
final ShowMessageCallback? onShowMessage;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class DeletedMessage extends StatelessWidget {
|
|||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// The theme of the message
|
/// The theme of the message
|
||||||
final MessageTheme messageTheme;
|
final MessageThemeData messageTheme;
|
||||||
|
|
||||||
/// The border radius of the message text
|
/// The border radius of the message text
|
||||||
final BorderRadiusGeometry? borderRadiusGeometry;
|
final BorderRadiusGeometry? borderRadiusGeometry;
|
||||||
@@ -51,9 +51,9 @@ class DeletedMessage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Message deleted',
|
'Message deleted',
|
||||||
style: messageTheme.messageText?.copyWith(
|
style: messageTheme.messageTextStyle?.copyWith(
|
||||||
fontStyle: FontStyle.italic,
|
fontStyle: FontStyle.italic,
|
||||||
color: messageTheme.createdAt?.color,
|
color: messageTheme.createdAtStyle?.color,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ class ImageGroup extends StatelessWidget {
|
|||||||
/// Message which images are attached to
|
/// Message which images are attached to
|
||||||
final Message message;
|
final Message message;
|
||||||
|
|
||||||
/// [MessageTheme] to apply to message
|
/// [MessageThemeData] to apply to message
|
||||||
final MessageTheme messageTheme;
|
final MessageThemeData messageTheme;
|
||||||
|
|
||||||
/// Size of iamges
|
/// Size of iamges
|
||||||
final Size size;
|
final Size size;
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ class MessageActionsModal extends StatefulWidget {
|
|||||||
/// Message in focus for actions
|
/// Message in focus for actions
|
||||||
final Message message;
|
final Message message;
|
||||||
|
|
||||||
/// [MessageTheme] for message
|
/// [MessageThemeData] for message
|
||||||
final MessageTheme messageTheme;
|
final MessageThemeData messageTheme;
|
||||||
|
|
||||||
/// Flag for showing reactions
|
/// Flag for showing reactions
|
||||||
final bool showReactions;
|
final bool showReactions;
|
||||||
@@ -117,7 +117,7 @@ class _MessageActionsModalState extends State<MessageActionsModal> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final roughSentenceSize = messageTextLength *
|
final roughSentenceSize = messageTextLength *
|
||||||
(widget.messageTheme.messageText?.fontSize ?? 1) *
|
(widget.messageTheme.messageTextStyle?.fontSize ?? 1) *
|
||||||
1.2;
|
1.2;
|
||||||
final divFactor = widget.message.attachments.isNotEmpty == true
|
final divFactor = widget.message.attachments.isNotEmpty == true
|
||||||
? 1
|
? 1
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ class MessageReactionsModal extends StatelessWidget {
|
|||||||
/// Message to display reactions of
|
/// Message to display reactions of
|
||||||
final Message message;
|
final Message message;
|
||||||
|
|
||||||
/// [MessageTheme] to apply to [message]
|
/// [MessageThemeData] to apply to [message]
|
||||||
final MessageTheme messageTheme;
|
final MessageThemeData messageTheme;
|
||||||
|
|
||||||
/// Flag to reverse message
|
/// Flag to reverse message
|
||||||
final bool reverse;
|
final bool reverse;
|
||||||
@@ -56,8 +56,9 @@ class MessageReactionsModal extends StatelessWidget {
|
|||||||
messageTextLength = quotedMessageLength;
|
messageTextLength = quotedMessageLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final roughSentenceSize =
|
final roughSentenceSize = messageTextLength *
|
||||||
messageTextLength * (messageTheme.messageText?.fontSize ?? 1) * 1.2;
|
(messageTheme.messageTextStyle?.fontSize ?? 1) *
|
||||||
|
1.2;
|
||||||
final divFactor = message.attachments.isNotEmpty == true
|
final divFactor = message.attachments.isNotEmpty == true
|
||||||
? 1
|
? 1
|
||||||
: (roughSentenceSize == 0 ? 1 : (roughSentenceSize / roughMaxSize));
|
: (roughSentenceSize == 0 ? 1 : (roughSentenceSize / roughMaxSize));
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ class MessageText extends StatelessWidget {
|
|||||||
/// Callback for when link is tapped
|
/// Callback for when link is tapped
|
||||||
final void Function(String)? onLinkTap;
|
final void Function(String)? onLinkTap;
|
||||||
|
|
||||||
/// [MessageTheme] whose text theme is to be applied
|
/// [MessageThemeData] whose text theme is to be applied
|
||||||
final MessageTheme messageTheme;
|
final MessageThemeData messageTheme;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -64,16 +64,16 @@ class MessageText extends StatelessWidget {
|
|||||||
styleSheet: MarkdownStyleSheet.fromTheme(
|
styleSheet: MarkdownStyleSheet.fromTheme(
|
||||||
themeData.copyWith(
|
themeData.copyWith(
|
||||||
textTheme: themeData.textTheme.apply(
|
textTheme: themeData.textTheme.apply(
|
||||||
bodyColor: messageTheme.messageText?.color,
|
bodyColor: messageTheme.messageTextStyle?.color,
|
||||||
decoration: messageTheme.messageText?.decoration,
|
decoration: messageTheme.messageTextStyle?.decoration,
|
||||||
decorationColor: messageTheme.messageText?.decorationColor,
|
decorationColor: messageTheme.messageTextStyle?.decorationColor,
|
||||||
decorationStyle: messageTheme.messageText?.decorationStyle,
|
decorationStyle: messageTheme.messageTextStyle?.decorationStyle,
|
||||||
fontFamily: messageTheme.messageText?.fontFamily,
|
fontFamily: messageTheme.messageTextStyle?.fontFamily,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
).copyWith(
|
).copyWith(
|
||||||
a: messageTheme.messageLinks,
|
a: messageTheme.messageLinksStyle,
|
||||||
p: messageTheme.messageText,
|
p: messageTheme.messageTextStyle,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ class MessageWidget extends StatefulWidget {
|
|||||||
final Message message;
|
final Message message;
|
||||||
|
|
||||||
/// The message theme
|
/// The message theme
|
||||||
final MessageTheme messageTheme;
|
final MessageThemeData messageTheme;
|
||||||
|
|
||||||
/// If true the widget will be mirrored
|
/// If true the widget will be mirrored
|
||||||
final bool reverse;
|
final bool reverse;
|
||||||
@@ -413,7 +413,7 @@ class MessageWidget extends StatefulWidget {
|
|||||||
Widget Function(BuildContext, Message)? usernameBuilder,
|
Widget Function(BuildContext, Message)? usernameBuilder,
|
||||||
void Function(BuildContext, Message)? onMessageActions,
|
void Function(BuildContext, Message)? onMessageActions,
|
||||||
Message? message,
|
Message? message,
|
||||||
MessageTheme? messageTheme,
|
MessageThemeData? messageTheme,
|
||||||
bool? reverse,
|
bool? reverse,
|
||||||
ShapeBorder? shape,
|
ShapeBorder? shape,
|
||||||
ShapeBorder? attachmentShape,
|
ShapeBorder? attachmentShape,
|
||||||
@@ -888,14 +888,14 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
),
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: widget.onThreadTap != null ? onThreadTap : null,
|
onTap: widget.onThreadTap != null ? onThreadTap : null,
|
||||||
child: Text(msg, style: widget.messageTheme.replies),
|
child: Text(msg, style: widget.messageTheme.repliesStyle),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
if (showUsername) _buildUsername(usernameKey),
|
if (showUsername) _buildUsername(usernameKey),
|
||||||
if (showTimeStamp)
|
if (showTimeStamp)
|
||||||
Text(
|
Text(
|
||||||
Jiffy(widget.message.createdAt.toLocal()).jm,
|
Jiffy(widget.message.createdAt.toLocal()).jm,
|
||||||
style: widget.messageTheme.createdAt,
|
style: widget.messageTheme.createdAtStyle,
|
||||||
),
|
),
|
||||||
if (showSendingIndicator) _buildSendingIndicator(),
|
if (showSendingIndicator) _buildSendingIndicator(),
|
||||||
]);
|
]);
|
||||||
@@ -912,7 +912,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.only(
|
margin: EdgeInsets.only(
|
||||||
bottom: context.textScaleFactor *
|
bottom: context.textScaleFactor *
|
||||||
((widget.messageTheme.replies?.fontSize ?? 1) / 2),
|
((widget.messageTheme.repliesStyle?.fontSize ?? 1) / 2),
|
||||||
),
|
),
|
||||||
child: CustomPaint(
|
child: CustomPaint(
|
||||||
size: const Size(16, 32) * context.textScaleFactor,
|
size: const Size(16, 32) * context.textScaleFactor,
|
||||||
@@ -939,7 +939,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.only(
|
margin: EdgeInsets.only(
|
||||||
bottom: context.textScaleFactor *
|
bottom: context.textScaleFactor *
|
||||||
((widget.messageTheme.replies?.fontSize ?? 1) / 2),
|
((widget.messageTheme.repliesStyle?.fontSize ?? 1) / 2),
|
||||||
),
|
),
|
||||||
child: CustomPaint(
|
child: CustomPaint(
|
||||||
size: const Size(16, 32) * context.textScaleFactor,
|
size: const Size(16, 32) * context.textScaleFactor,
|
||||||
@@ -962,7 +962,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
widget.message.user!.name,
|
widget.message.user!.name,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
key: usernameKey,
|
key: usernameKey,
|
||||||
style: widget.messageTheme.messageAuthor,
|
style: widget.messageTheme.messageAuthorStyle,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1186,7 +1186,7 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildSendingIndicator() {
|
Widget _buildSendingIndicator() {
|
||||||
final style = widget.messageTheme.createdAt;
|
final style = widget.messageTheme.createdAtStyle;
|
||||||
final message = widget.message;
|
final message = widget.message;
|
||||||
|
|
||||||
if (hasNonUrlAttachments &&
|
if (hasNonUrlAttachments &&
|
||||||
@@ -1263,8 +1263,8 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
onMentionTap: widget.onMentionTap,
|
onMentionTap: widget.onMentionTap,
|
||||||
messageTheme: isOnlyEmoji
|
messageTheme: isOnlyEmoji
|
||||||
? widget.messageTheme.copyWith(
|
? widget.messageTheme.copyWith(
|
||||||
messageText:
|
messageTextStyle:
|
||||||
widget.messageTheme.messageText!.copyWith(
|
widget.messageTheme.messageTextStyle!.copyWith(
|
||||||
fontSize: 42,
|
fontSize: 42,
|
||||||
))
|
))
|
||||||
: widget.messageTheme,
|
: widget.messageTheme,
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class QuotedMessageWidget extends StatelessWidget {
|
|||||||
final Message message;
|
final Message message;
|
||||||
|
|
||||||
/// The message theme
|
/// The message theme
|
||||||
final MessageTheme messageTheme;
|
final MessageThemeData messageTheme;
|
||||||
|
|
||||||
/// If true the widget will be mirrored
|
/// If true the widget will be mirrored
|
||||||
final bool reverse;
|
final bool reverse;
|
||||||
@@ -139,11 +139,11 @@ class QuotedMessageWidget extends StatelessWidget {
|
|||||||
message: msg,
|
message: msg,
|
||||||
messageTheme: isOnlyEmoji && _containsText
|
messageTheme: isOnlyEmoji && _containsText
|
||||||
? messageTheme.copyWith(
|
? messageTheme.copyWith(
|
||||||
messageText: messageTheme.messageText?.copyWith(
|
messageTextStyle: messageTheme.messageTextStyle?.copyWith(
|
||||||
fontSize: 32,
|
fontSize: 32,
|
||||||
))
|
))
|
||||||
: messageTheme.copyWith(
|
: messageTheme.copyWith(
|
||||||
messageText: messageTheme.messageText?.copyWith(
|
messageTextStyle: messageTheme.messageTextStyle?.copyWith(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ class StreamChatThemeData {
|
|||||||
ChannelListHeaderTheme? channelListHeaderTheme,
|
ChannelListHeaderTheme? channelListHeaderTheme,
|
||||||
ChannelPreviewThemeData? channelPreviewTheme,
|
ChannelPreviewThemeData? channelPreviewTheme,
|
||||||
ChannelHeaderThemeData? channelHeaderTheme,
|
ChannelHeaderThemeData? channelHeaderTheme,
|
||||||
MessageTheme? otherMessageTheme,
|
MessageThemeData? otherMessageTheme,
|
||||||
MessageTheme? ownMessageTheme,
|
MessageThemeData? ownMessageTheme,
|
||||||
MessageInputThemeData? messageInputTheme,
|
MessageInputThemeData? messageInputTheme,
|
||||||
Widget Function(BuildContext, User)? defaultUserImage,
|
Widget Function(BuildContext, User)? defaultUserImage,
|
||||||
IconThemeData? primaryIconTheme,
|
IconThemeData? primaryIconTheme,
|
||||||
@@ -159,10 +159,10 @@ class StreamChatThemeData {
|
|||||||
final GalleryFooterThemeData galleryFooterTheme;
|
final GalleryFooterThemeData galleryFooterTheme;
|
||||||
|
|
||||||
/// Theme of the current user messages
|
/// Theme of the current user messages
|
||||||
final MessageTheme ownMessageTheme;
|
final MessageThemeData ownMessageTheme;
|
||||||
|
|
||||||
/// Theme of other users messages
|
/// Theme of other users messages
|
||||||
final MessageTheme otherMessageTheme;
|
final MessageThemeData otherMessageTheme;
|
||||||
|
|
||||||
/// Theme dedicated to the [MessageInput] widget
|
/// Theme dedicated to the [MessageInput] widget
|
||||||
final MessageInputThemeData messageInputTheme;
|
final MessageInputThemeData messageInputTheme;
|
||||||
@@ -195,8 +195,8 @@ class StreamChatThemeData {
|
|||||||
ColorTheme? colorTheme,
|
ColorTheme? colorTheme,
|
||||||
ChannelPreviewThemeData? channelPreviewTheme,
|
ChannelPreviewThemeData? channelPreviewTheme,
|
||||||
ChannelHeaderThemeData? channelHeaderTheme,
|
ChannelHeaderThemeData? channelHeaderTheme,
|
||||||
MessageTheme? ownMessageTheme,
|
MessageThemeData? ownMessageTheme,
|
||||||
MessageTheme? otherMessageTheme,
|
MessageThemeData? otherMessageTheme,
|
||||||
MessageInputThemeData? messageInputTheme,
|
MessageInputThemeData? messageInputTheme,
|
||||||
Widget Function(BuildContext, User)? defaultUserImage,
|
Widget Function(BuildContext, User)? defaultUserImage,
|
||||||
IconThemeData? primaryIconTheme,
|
IconThemeData? primaryIconTheme,
|
||||||
@@ -324,13 +324,13 @@ class StreamChatThemeData {
|
|||||||
title: textTheme.headlineBold,
|
title: textTheme.headlineBold,
|
||||||
),
|
),
|
||||||
channelHeaderTheme: channelHeaderTheme,
|
channelHeaderTheme: channelHeaderTheme,
|
||||||
ownMessageTheme: MessageTheme(
|
ownMessageTheme: MessageThemeData(
|
||||||
messageAuthor:
|
messageAuthorStyle:
|
||||||
textTheme.footnote.copyWith(color: colorTheme.textLowEmphasis),
|
textTheme.footnote.copyWith(color: colorTheme.textLowEmphasis),
|
||||||
messageText: textTheme.body,
|
messageTextStyle: textTheme.body,
|
||||||
createdAt:
|
createdAtStyle:
|
||||||
textTheme.footnote.copyWith(color: colorTheme.textLowEmphasis),
|
textTheme.footnote.copyWith(color: colorTheme.textLowEmphasis),
|
||||||
replies: textTheme.footnoteBold.copyWith(color: accentColor),
|
repliesStyle: textTheme.footnoteBold.copyWith(color: accentColor),
|
||||||
messageBackgroundColor: colorTheme.disabled,
|
messageBackgroundColor: colorTheme.disabled,
|
||||||
reactionsBackgroundColor: colorTheme.barsBg,
|
reactionsBackgroundColor: colorTheme.barsBg,
|
||||||
reactionsBorderColor: colorTheme.borders,
|
reactionsBorderColor: colorTheme.borders,
|
||||||
@@ -343,21 +343,21 @@ class StreamChatThemeData {
|
|||||||
width: 32,
|
width: 32,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
messageLinks: TextStyle(
|
messageLinksStyle: TextStyle(
|
||||||
color: accentColor,
|
color: accentColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
otherMessageTheme: MessageTheme(
|
otherMessageTheme: MessageThemeData(
|
||||||
reactionsBackgroundColor: colorTheme.disabled,
|
reactionsBackgroundColor: colorTheme.disabled,
|
||||||
reactionsBorderColor: colorTheme.barsBg,
|
reactionsBorderColor: colorTheme.barsBg,
|
||||||
reactionsMaskColor: colorTheme.appBg,
|
reactionsMaskColor: colorTheme.appBg,
|
||||||
messageText: textTheme.body,
|
messageTextStyle: textTheme.body,
|
||||||
createdAt:
|
createdAtStyle:
|
||||||
textTheme.footnote.copyWith(color: colorTheme.textLowEmphasis),
|
textTheme.footnote.copyWith(color: colorTheme.textLowEmphasis),
|
||||||
messageAuthor:
|
messageAuthorStyle:
|
||||||
textTheme.footnote.copyWith(color: colorTheme.textLowEmphasis),
|
textTheme.footnote.copyWith(color: colorTheme.textLowEmphasis),
|
||||||
replies: textTheme.footnoteBold.copyWith(color: accentColor),
|
repliesStyle: textTheme.footnoteBold.copyWith(color: accentColor),
|
||||||
messageLinks: TextStyle(
|
messageLinksStyle: TextStyle(
|
||||||
color: accentColor,
|
color: accentColor,
|
||||||
),
|
),
|
||||||
messageBackgroundColor: colorTheme.barsBg,
|
messageBackgroundColor: colorTheme.barsBg,
|
||||||
|
|||||||
@@ -1,37 +1,38 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:stream_chat_flutter/src/theme/avatar_theme.dart';
|
import 'package:stream_chat_flutter/src/theme/avatar_theme.dart';
|
||||||
|
|
||||||
/// Class for getting message theme
|
/// Class for getting message theme
|
||||||
class MessageTheme {
|
class MessageThemeData with Diagnosticable {
|
||||||
/// Constructor into [MessageTheme]
|
/// Creates a [MessageThemeData].
|
||||||
const MessageTheme({
|
const MessageThemeData({
|
||||||
this.replies,
|
this.repliesStyle,
|
||||||
this.messageText,
|
this.messageTextStyle,
|
||||||
this.messageAuthor,
|
this.messageAuthorStyle,
|
||||||
this.messageLinks,
|
this.messageLinksStyle,
|
||||||
this.messageBackgroundColor,
|
this.messageBackgroundColor,
|
||||||
this.messageBorderColor,
|
this.messageBorderColor,
|
||||||
this.reactionsBackgroundColor,
|
this.reactionsBackgroundColor,
|
||||||
this.reactionsBorderColor,
|
this.reactionsBorderColor,
|
||||||
this.reactionsMaskColor,
|
this.reactionsMaskColor,
|
||||||
this.avatarTheme,
|
this.avatarTheme,
|
||||||
this.createdAt,
|
this.createdAtStyle,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Text style for message text
|
/// Text style for message text
|
||||||
final TextStyle? messageText;
|
final TextStyle? messageTextStyle;
|
||||||
|
|
||||||
/// Text style for message author
|
/// Text style for message author
|
||||||
final TextStyle? messageAuthor;
|
final TextStyle? messageAuthorStyle;
|
||||||
|
|
||||||
/// Text style for message links
|
/// Text style for message links
|
||||||
final TextStyle? messageLinks;
|
final TextStyle? messageLinksStyle;
|
||||||
|
|
||||||
/// Text style for created at text
|
/// Text style for created at text
|
||||||
final TextStyle? createdAt;
|
final TextStyle? createdAtStyle;
|
||||||
|
|
||||||
/// Text style for replies
|
/// Text style for replies
|
||||||
final TextStyle? replies;
|
final TextStyle? repliesStyle;
|
||||||
|
|
||||||
/// Color for messageBackgroundColor
|
/// Color for messageBackgroundColor
|
||||||
final Color? messageBackgroundColor;
|
final Color? messageBackgroundColor;
|
||||||
@@ -52,12 +53,12 @@ class MessageTheme {
|
|||||||
final AvatarThemeData? avatarTheme;
|
final AvatarThemeData? avatarTheme;
|
||||||
|
|
||||||
/// Copy with a theme
|
/// Copy with a theme
|
||||||
MessageTheme copyWith({
|
MessageThemeData copyWith({
|
||||||
TextStyle? messageText,
|
TextStyle? messageTextStyle,
|
||||||
TextStyle? messageAuthor,
|
TextStyle? messageAuthorStyle,
|
||||||
TextStyle? messageLinks,
|
TextStyle? messageLinksStyle,
|
||||||
TextStyle? createdAt,
|
TextStyle? createdAtStyle,
|
||||||
TextStyle? replies,
|
TextStyle? repliesStyle,
|
||||||
Color? messageBackgroundColor,
|
Color? messageBackgroundColor,
|
||||||
Color? messageBorderColor,
|
Color? messageBorderColor,
|
||||||
AvatarThemeData? avatarTheme,
|
AvatarThemeData? avatarTheme,
|
||||||
@@ -65,33 +66,61 @@ class MessageTheme {
|
|||||||
Color? reactionsBorderColor,
|
Color? reactionsBorderColor,
|
||||||
Color? reactionsMaskColor,
|
Color? reactionsMaskColor,
|
||||||
}) =>
|
}) =>
|
||||||
MessageTheme(
|
MessageThemeData(
|
||||||
messageText: messageText ?? this.messageText,
|
messageTextStyle: messageTextStyle ?? this.messageTextStyle,
|
||||||
messageAuthor: messageAuthor ?? this.messageAuthor,
|
messageAuthorStyle: messageAuthorStyle ?? this.messageAuthorStyle,
|
||||||
messageLinks: messageLinks ?? this.messageLinks,
|
messageLinksStyle: messageLinksStyle ?? this.messageLinksStyle,
|
||||||
createdAt: createdAt ?? this.createdAt,
|
createdAtStyle: createdAtStyle ?? this.createdAtStyle,
|
||||||
messageBackgroundColor:
|
messageBackgroundColor:
|
||||||
messageBackgroundColor ?? this.messageBackgroundColor,
|
messageBackgroundColor ?? this.messageBackgroundColor,
|
||||||
messageBorderColor: messageBorderColor ?? this.messageBorderColor,
|
messageBorderColor: messageBorderColor ?? this.messageBorderColor,
|
||||||
avatarTheme: avatarTheme ?? this.avatarTheme,
|
avatarTheme: avatarTheme ?? this.avatarTheme,
|
||||||
replies: replies ?? this.replies,
|
repliesStyle: repliesStyle ?? this.repliesStyle,
|
||||||
reactionsBackgroundColor:
|
reactionsBackgroundColor:
|
||||||
reactionsBackgroundColor ?? this.reactionsBackgroundColor,
|
reactionsBackgroundColor ?? this.reactionsBackgroundColor,
|
||||||
reactionsBorderColor: reactionsBorderColor ?? this.reactionsBorderColor,
|
reactionsBorderColor: reactionsBorderColor ?? this.reactionsBorderColor,
|
||||||
reactionsMaskColor: reactionsMaskColor ?? this.reactionsMaskColor,
|
reactionsMaskColor: reactionsMaskColor ?? this.reactionsMaskColor,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// Linearly interpolate from one [MessageThemeData] to another.
|
||||||
|
MessageThemeData lerp(MessageThemeData a, MessageThemeData b, double t) =>
|
||||||
|
MessageThemeData(
|
||||||
|
avatarTheme:
|
||||||
|
const AvatarThemeData().lerp(a.avatarTheme!, b.avatarTheme!, t),
|
||||||
|
createdAtStyle: TextStyle.lerp(a.createdAtStyle, b.createdAtStyle, t),
|
||||||
|
messageAuthorStyle:
|
||||||
|
TextStyle.lerp(a.messageAuthorStyle, b.messageAuthorStyle, t),
|
||||||
|
messageBackgroundColor:
|
||||||
|
Color.lerp(a.messageBackgroundColor, b.messageBackgroundColor, t),
|
||||||
|
messageBorderColor:
|
||||||
|
Color.lerp(a.messageBorderColor, b.messageBorderColor, t),
|
||||||
|
messageLinksStyle:
|
||||||
|
TextStyle.lerp(a.messageLinksStyle, b.messageLinksStyle, t),
|
||||||
|
messageTextStyle:
|
||||||
|
TextStyle.lerp(a.messageTextStyle, b.messageTextStyle, t),
|
||||||
|
reactionsBackgroundColor: Color.lerp(
|
||||||
|
a.reactionsBackgroundColor, b.reactionsBackgroundColor, t),
|
||||||
|
reactionsBorderColor:
|
||||||
|
Color.lerp(a.messageBorderColor, b.reactionsBorderColor, t),
|
||||||
|
reactionsMaskColor:
|
||||||
|
Color.lerp(a.reactionsMaskColor, b.reactionsMaskColor, t),
|
||||||
|
repliesStyle: TextStyle.lerp(a.repliesStyle, b.repliesStyle, t),
|
||||||
|
);
|
||||||
|
|
||||||
/// Merge with a theme
|
/// Merge with a theme
|
||||||
MessageTheme merge(MessageTheme? other) {
|
MessageThemeData merge(MessageThemeData? other) {
|
||||||
if (other == null) return this;
|
if (other == null) return this;
|
||||||
return copyWith(
|
return copyWith(
|
||||||
messageText: messageText?.merge(other.messageText) ?? other.messageText,
|
messageTextStyle: messageTextStyle?.merge(other.messageTextStyle) ??
|
||||||
messageAuthor:
|
other.messageTextStyle,
|
||||||
messageAuthor?.merge(other.messageAuthor) ?? other.messageAuthor,
|
messageAuthorStyle: messageAuthorStyle?.merge(other.messageAuthorStyle) ??
|
||||||
messageLinks:
|
other.messageAuthorStyle,
|
||||||
messageLinks?.merge(other.messageLinks) ?? other.messageLinks,
|
messageLinksStyle: messageLinksStyle?.merge(other.messageLinksStyle) ??
|
||||||
createdAt: createdAt?.merge(other.createdAt) ?? other.createdAt,
|
other.messageLinksStyle,
|
||||||
replies: replies?.merge(other.replies) ?? other.replies,
|
createdAtStyle:
|
||||||
|
createdAtStyle?.merge(other.createdAtStyle) ?? other.createdAtStyle,
|
||||||
|
repliesStyle:
|
||||||
|
repliesStyle?.merge(other.repliesStyle) ?? other.repliesStyle,
|
||||||
messageBackgroundColor: other.messageBackgroundColor,
|
messageBackgroundColor: other.messageBackgroundColor,
|
||||||
messageBorderColor: other.messageBorderColor,
|
messageBorderColor: other.messageBorderColor,
|
||||||
avatarTheme: avatarTheme?.merge(other.avatarTheme) ?? other.avatarTheme,
|
avatarTheme: avatarTheme?.merge(other.avatarTheme) ?? other.avatarTheme,
|
||||||
@@ -100,4 +129,52 @@ class MessageTheme {
|
|||||||
reactionsMaskColor: other.reactionsMaskColor,
|
reactionsMaskColor: other.reactionsMaskColor,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
identical(this, other) ||
|
||||||
|
other is MessageThemeData &&
|
||||||
|
runtimeType == other.runtimeType &&
|
||||||
|
messageTextStyle == other.messageTextStyle &&
|
||||||
|
messageAuthorStyle == other.messageAuthorStyle &&
|
||||||
|
messageLinksStyle == other.messageLinksStyle &&
|
||||||
|
createdAtStyle == other.createdAtStyle &&
|
||||||
|
repliesStyle == other.repliesStyle &&
|
||||||
|
messageBackgroundColor == other.messageBackgroundColor &&
|
||||||
|
messageBorderColor == other.messageBorderColor &&
|
||||||
|
reactionsBackgroundColor == other.reactionsBackgroundColor &&
|
||||||
|
reactionsBorderColor == other.reactionsBorderColor &&
|
||||||
|
reactionsMaskColor == other.reactionsMaskColor &&
|
||||||
|
avatarTheme == other.avatarTheme;
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode =>
|
||||||
|
messageTextStyle.hashCode ^
|
||||||
|
messageAuthorStyle.hashCode ^
|
||||||
|
messageLinksStyle.hashCode ^
|
||||||
|
createdAtStyle.hashCode ^
|
||||||
|
repliesStyle.hashCode ^
|
||||||
|
messageBackgroundColor.hashCode ^
|
||||||
|
messageBorderColor.hashCode ^
|
||||||
|
reactionsBackgroundColor.hashCode ^
|
||||||
|
reactionsBorderColor.hashCode ^
|
||||||
|
reactionsMaskColor.hashCode ^
|
||||||
|
avatarTheme.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||||
|
super.debugFillProperties(properties);
|
||||||
|
properties
|
||||||
|
..add(DiagnosticsProperty('messageTextStyle', messageTextStyle))
|
||||||
|
..add(DiagnosticsProperty('messageAuthorStyle', messageAuthorStyle))
|
||||||
|
..add(DiagnosticsProperty('messageLinksStyle', messageLinksStyle))
|
||||||
|
..add(DiagnosticsProperty('createdAtStyle', createdAtStyle))
|
||||||
|
..add(DiagnosticsProperty('repliesStyle', repliesStyle))
|
||||||
|
..add(ColorProperty('messageBackgroundColor', messageBackgroundColor))
|
||||||
|
..add(ColorProperty('messageBorderColor', messageBorderColor))
|
||||||
|
..add(DiagnosticsProperty('avatarTheme', avatarTheme))
|
||||||
|
..add(ColorProperty('reactionsBackgroundColor', reactionsBackgroundColor))
|
||||||
|
..add(ColorProperty('reactionsBorderColor', reactionsBorderColor))
|
||||||
|
..add(ColorProperty('reactionsMaskColor', reactionsMaskColor));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ void main() {
|
|||||||
client: client,
|
client: client,
|
||||||
child: const Scaffold(
|
child: const Scaffold(
|
||||||
body: DeletedMessage(
|
body: DeletedMessage(
|
||||||
messageTheme: MessageTheme(
|
messageTheme: MessageThemeData(
|
||||||
createdAt: TextStyle(
|
createdAtStyle: TextStyle(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
),
|
),
|
||||||
messageText: TextStyle(),
|
messageTextStyle: TextStyle(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user