Merge pull request #718 from GetStream/cds-437

feat(ui): copy linkBg theme property in message theme.
This commit is contained in:
Salvatore Giordano
2021-10-04 16:57:15 +02:00
committed by GitHub
7 changed files with 29 additions and 7 deletions
@@ -11,6 +11,7 @@
- Added `MessageInput.customOverlays` property to add custom overlays to the message input. - Added `MessageInput.customOverlays` property to add custom overlays to the message input.
- Added `MessageInput.mentionAllAppUsers` property to mention all app users in the message input. - Added `MessageInput.mentionAllAppUsers` property to mention all app users in the message input.
- The `MessageInput` now supports local search for channels with less than 100 members. - The `MessageInput` now supports local search for channels with less than 100 members.
- Added new `linkBackgroundColor` in `MessageTheme` for setting background colors of link attachments.
⚠️ Deprecated ⚠️ Deprecated
@@ -10,6 +10,7 @@ class UrlAttachment extends StatelessWidget {
Key? key, Key? key,
required this.urlAttachment, required this.urlAttachment,
required this.hostDisplayName, required this.hostDisplayName,
required this.messageTheme,
this.textPadding = const EdgeInsets.symmetric( this.textPadding = const EdgeInsets.symmetric(
horizontal: 16, horizontal: 16,
vertical: 8, vertical: 8,
@@ -25,6 +26,9 @@ class UrlAttachment extends StatelessWidget {
/// Padding for text /// Padding for text
final EdgeInsets textPadding; final EdgeInsets textPadding;
/// [MessageThemeData] for showing image title
final MessageThemeData messageTheme;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final chatThemeData = StreamChatTheme.of(context); final chatThemeData = StreamChatTheme.of(context);
@@ -58,7 +62,7 @@ class UrlAttachment extends StatelessWidget {
borderRadius: const BorderRadius.only( borderRadius: const BorderRadius.only(
topRight: Radius.circular(16), topRight: Radius.circular(16),
), ),
color: chatThemeData.colorTheme.linkBg, color: messageTheme.linkBackgroundColor,
), ),
child: Padding( child: Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
@@ -7,6 +7,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_portal/flutter_portal.dart'; import 'package:flutter_portal/flutter_portal.dart';
import 'package:jiffy/jiffy.dart'; import 'package:jiffy/jiffy.dart';
import 'package:stream_chat_flutter/src/attachment/url_attachment.dart';
import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/src/extension.dart';
import 'package:stream_chat_flutter/src/image_group.dart'; import 'package:stream_chat_flutter/src/image_group.dart';
import 'package:stream_chat_flutter/src/message_action.dart'; import 'package:stream_chat_flutter/src/message_action.dart';
@@ -15,7 +16,6 @@ import 'package:stream_chat_flutter/src/message_reactions_modal.dart';
import 'package:stream_chat_flutter/src/quoted_message_widget.dart'; import 'package:stream_chat_flutter/src/quoted_message_widget.dart';
import 'package:stream_chat_flutter/src/reaction_bubble.dart'; import 'package:stream_chat_flutter/src/reaction_bubble.dart';
import 'package:stream_chat_flutter/src/theme/themes.dart'; import 'package:stream_chat_flutter/src/theme/themes.dart';
import 'package:stream_chat_flutter/src/url_attachment.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart';
/// Widget builder for building attachments /// Widget builder for building attachments
@@ -1002,6 +1002,7 @@ class _MessageWidgetState extends State<MessageWidget>
urlAttachment: urlAttachment, urlAttachment: urlAttachment,
hostDisplayName: hostDisplayName, hostDisplayName: hostDisplayName,
textPadding: widget.textPadding, textPadding: widget.textPadding,
messageTheme: widget.messageTheme,
); );
} }
@@ -1339,7 +1340,7 @@ class _MessageWidgetState extends State<MessageWidget>
} }
if (hasUrlAttachments) { if (hasUrlAttachments) {
return _streamChatTheme.colorTheme.linkBg; return widget.messageTheme.linkBackgroundColor;
} }
if (isOnlyEmoji) { if (isOnlyEmoji) {
@@ -281,7 +281,7 @@ class QuotedMessageWidget extends StatelessWidget {
Color? _getBackgroundColor(BuildContext context) { Color? _getBackgroundColor(BuildContext context) {
if (_containsLinkAttachment) { if (_containsLinkAttachment) {
return StreamChatTheme.of(context).colorTheme.linkBg; return messageTheme.linkBackgroundColor;
} }
return messageTheme.messageBackgroundColor; return messageTheme.messageBackgroundColor;
} }
@@ -223,6 +223,7 @@ class StreamChatThemeData {
messageLinksStyle: TextStyle( messageLinksStyle: TextStyle(
color: accentColor, color: accentColor,
), ),
linkBackgroundColor: colorTheme.linkBg,
), ),
otherMessageTheme: MessageThemeData( otherMessageTheme: MessageThemeData(
reactionsBackgroundColor: colorTheme.disabled, reactionsBackgroundColor: colorTheme.disabled,
@@ -246,6 +247,7 @@ class StreamChatThemeData {
width: 32, width: 32,
), ),
), ),
linkBackgroundColor: colorTheme.linkBg,
), ),
messageInputTheme: MessageInputThemeData( messageInputTheme: MessageInputThemeData(
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
@@ -17,6 +17,7 @@ class MessageThemeData with Diagnosticable {
this.reactionsMaskColor, this.reactionsMaskColor,
this.avatarTheme, this.avatarTheme,
this.createdAtStyle, this.createdAtStyle,
this.linkBackgroundColor,
}); });
/// Text style for message text /// Text style for message text
@@ -52,6 +53,9 @@ class MessageThemeData with Diagnosticable {
/// Theme of the avatar /// Theme of the avatar
final AvatarThemeData? avatarTheme; final AvatarThemeData? avatarTheme;
/// Background color for messages with url attachments.
final Color? linkBackgroundColor;
/// Copy with a theme /// Copy with a theme
MessageThemeData copyWith({ MessageThemeData copyWith({
TextStyle? messageTextStyle, TextStyle? messageTextStyle,
@@ -65,6 +69,7 @@ class MessageThemeData with Diagnosticable {
Color? reactionsBackgroundColor, Color? reactionsBackgroundColor,
Color? reactionsBorderColor, Color? reactionsBorderColor,
Color? reactionsMaskColor, Color? reactionsMaskColor,
Color? linkBackgroundColor,
}) => }) =>
MessageThemeData( MessageThemeData(
messageTextStyle: messageTextStyle ?? this.messageTextStyle, messageTextStyle: messageTextStyle ?? this.messageTextStyle,
@@ -80,6 +85,7 @@ class MessageThemeData with Diagnosticable {
reactionsBackgroundColor ?? this.reactionsBackgroundColor, reactionsBackgroundColor ?? this.reactionsBackgroundColor,
reactionsBorderColor: reactionsBorderColor ?? this.reactionsBorderColor, reactionsBorderColor: reactionsBorderColor ?? this.reactionsBorderColor,
reactionsMaskColor: reactionsMaskColor ?? this.reactionsMaskColor, reactionsMaskColor: reactionsMaskColor ?? this.reactionsMaskColor,
linkBackgroundColor: linkBackgroundColor ?? this.linkBackgroundColor,
); );
/// Linearly interpolate from one [MessageThemeData] to another. /// Linearly interpolate from one [MessageThemeData] to another.
@@ -105,6 +111,8 @@ class MessageThemeData with Diagnosticable {
reactionsMaskColor: reactionsMaskColor:
Color.lerp(a.reactionsMaskColor, b.reactionsMaskColor, t), Color.lerp(a.reactionsMaskColor, b.reactionsMaskColor, t),
repliesStyle: TextStyle.lerp(a.repliesStyle, b.repliesStyle, t), repliesStyle: TextStyle.lerp(a.repliesStyle, b.repliesStyle, t),
linkBackgroundColor:
Color.lerp(a.linkBackgroundColor, b.linkBackgroundColor, t),
); );
/// Merge with a theme /// Merge with a theme
@@ -127,6 +135,7 @@ class MessageThemeData with Diagnosticable {
reactionsBackgroundColor: other.reactionsBackgroundColor, reactionsBackgroundColor: other.reactionsBackgroundColor,
reactionsBorderColor: other.reactionsBorderColor, reactionsBorderColor: other.reactionsBorderColor,
reactionsMaskColor: other.reactionsMaskColor, reactionsMaskColor: other.reactionsMaskColor,
linkBackgroundColor: other.linkBackgroundColor,
); );
} }
@@ -145,7 +154,8 @@ class MessageThemeData with Diagnosticable {
reactionsBackgroundColor == other.reactionsBackgroundColor && reactionsBackgroundColor == other.reactionsBackgroundColor &&
reactionsBorderColor == other.reactionsBorderColor && reactionsBorderColor == other.reactionsBorderColor &&
reactionsMaskColor == other.reactionsMaskColor && reactionsMaskColor == other.reactionsMaskColor &&
avatarTheme == other.avatarTheme; avatarTheme == other.avatarTheme &&
linkBackgroundColor == other.linkBackgroundColor;
@override @override
int get hashCode => int get hashCode =>
@@ -159,7 +169,8 @@ class MessageThemeData with Diagnosticable {
reactionsBackgroundColor.hashCode ^ reactionsBackgroundColor.hashCode ^
reactionsBorderColor.hashCode ^ reactionsBorderColor.hashCode ^
reactionsMaskColor.hashCode ^ reactionsMaskColor.hashCode ^
avatarTheme.hashCode; avatarTheme.hashCode ^
linkBackgroundColor.hashCode;
@override @override
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
@@ -175,6 +186,7 @@ class MessageThemeData with Diagnosticable {
..add(DiagnosticsProperty('avatarTheme', avatarTheme)) ..add(DiagnosticsProperty('avatarTheme', avatarTheme))
..add(ColorProperty('reactionsBackgroundColor', reactionsBackgroundColor)) ..add(ColorProperty('reactionsBackgroundColor', reactionsBackgroundColor))
..add(ColorProperty('reactionsBorderColor', reactionsBorderColor)) ..add(ColorProperty('reactionsBorderColor', reactionsBorderColor))
..add(ColorProperty('reactionsMaskColor', reactionsMaskColor)); ..add(ColorProperty('reactionsMaskColor', reactionsMaskColor))
..add(ColorProperty('linkBackgroundColor', linkBackgroundColor));
} }
} }
@@ -59,6 +59,7 @@ final _messageThemeControl = MessageThemeData(
messageLinksStyle: TextStyle( messageLinksStyle: TextStyle(
color: ColorTheme.light().accentPrimary, color: ColorTheme.light().accentPrimary,
), ),
linkBackgroundColor: ColorTheme.light().linkBg,
); );
final _messageThemeControlDark = MessageThemeData( final _messageThemeControlDark = MessageThemeData(
@@ -87,4 +88,5 @@ final _messageThemeControlDark = MessageThemeData(
messageLinksStyle: TextStyle( messageLinksStyle: TextStyle(
color: ColorTheme.dark().accentPrimary, color: ColorTheme.dark().accentPrimary,
), ),
linkBackgroundColor: ColorTheme.dark().linkBg,
); );