diff --git a/packages/stream_chat_flutter/lib/src/channel_header.dart b/packages/stream_chat_flutter/lib/src/channel_header.dart index 8f586516..4df44765 100644 --- a/packages/stream_chat_flutter/lib/src/channel_header.dart +++ b/packages/stream_chat_flutter/lib/src/channel_header.dart @@ -169,7 +169,7 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget { title ?? ChannelName( textStyle: chatThemeData - .channelTheme.channelHeaderTheme.title, + .channelTheme.channelHeaderTheme.titleStyle, ), const SizedBox(height: 2), subtitle ?? @@ -177,7 +177,7 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget { showTypingIndicator: showTypingIndicator, channel: channel, textStyle: chatThemeData - .channelTheme.channelHeaderTheme.subtitle, + .channelTheme.channelHeaderTheme.subtitleStyle, ), ], ), diff --git a/packages/stream_chat_flutter/lib/src/channel_info.dart b/packages/stream_chat_flutter/lib/src/channel_info.dart index 89894324..67e18801 100644 --- a/packages/stream_chat_flutter/lib/src/channel_info.dart +++ b/packages/stream_chat_flutter/lib/src/channel_info.dart @@ -64,7 +64,7 @@ class ChannelInfo extends StatelessWidget { style: StreamChatTheme.of(context) .channelTheme .channelHeaderTheme - .subtitle, + .subtitleStyle, ); } else { final userId = StreamChat.of(context).currentUser?.id; diff --git a/packages/stream_chat_flutter/lib/src/message_list_view.dart b/packages/stream_chat_flutter/lib/src/message_list_view.dart index e7279579..303c76db 100644 --- a/packages/stream_chat_flutter/lib/src/message_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/message_list_view.dart @@ -628,7 +628,7 @@ class _MessageListViewState extends State { child: Text( '$replyCount ${replyCount == 1 ? 'Reply' : 'Replies'}', textAlign: TextAlign.center, - style: _streamTheme.channelTheme.channelHeaderTheme.subtitle, + style: _streamTheme.channelTheme.channelHeaderTheme.subtitleStyle, ), ), ); diff --git a/packages/stream_chat_flutter/lib/src/stream_chat_theme.dart b/packages/stream_chat_flutter/lib/src/stream_chat_theme.dart index 38511e38..dad5dadb 100644 --- a/packages/stream_chat_flutter/lib/src/stream_chat_theme.dart +++ b/packages/stream_chat_flutter/lib/src/stream_chat_theme.dart @@ -288,8 +288,8 @@ class StreamChatThemeData { ), ), color: colorTheme.barsBg, - title: textTheme.headlineBold, - subtitle: textTheme.footnote.copyWith( + titleStyle: textTheme.headlineBold, + subtitleStyle: textTheme.footnote.copyWith( color: const Color(0xff7A7A7A), ), ), diff --git a/packages/stream_chat_flutter/lib/src/theme/channel_header_theme.dart b/packages/stream_chat_flutter/lib/src/theme/channel_header_theme.dart index 8ea92615..2d3253dc 100644 --- a/packages/stream_chat_flutter/lib/src/theme/channel_header_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/channel_header_theme.dart @@ -2,6 +2,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; import 'package:stream_chat_flutter/src/theme/avatar_theme.dart'; +import 'package:stream_chat_flutter/src/theme/themes.dart'; /// Overrides the default style of [ChannelHeader] descendants. /// @@ -59,17 +60,17 @@ class ChannelHeaderTheme extends InheritedTheme { class ChannelHeaderThemeData with Diagnosticable { /// Creates a [ChannelHeaderThemeData] const ChannelHeaderThemeData({ - this.title, - this.subtitle, + this.titleStyle, + this.subtitleStyle, this.avatarTheme, this.color, }); /// Theme for title - final TextStyle? title; + final TextStyle? titleStyle; /// Theme for subtitle - final TextStyle? subtitle; + final TextStyle? subtitleStyle; /// Theme for avatar final AvatarThemeData? avatarTheme; @@ -79,26 +80,70 @@ class ChannelHeaderThemeData with Diagnosticable { /// Copy with theme ChannelHeaderThemeData copyWith({ - TextStyle? title, - TextStyle? subtitle, + TextStyle? titleStyle, + TextStyle? subtitleStyle, AvatarThemeData? avatarTheme, Color? color, }) => ChannelHeaderThemeData( - title: title ?? this.title, - subtitle: subtitle ?? this.subtitle, + titleStyle: titleStyle ?? this.titleStyle, + subtitleStyle: subtitleStyle ?? this.subtitleStyle, avatarTheme: avatarTheme ?? this.avatarTheme, color: color ?? this.color, ); + /// Linearly interpolate between two [ChannelHeaderThemeData]. + /// + /// All the properties must be non-null. + ChannelHeaderThemeData lerp( + ChannelHeaderThemeData a, + ChannelHeaderThemeData b, + double t, + ) => + ChannelHeaderThemeData( + titleStyle: TextStyle.lerp(a.titleStyle, b.titleStyle, t), + subtitleStyle: TextStyle.lerp(a.subtitleStyle, b.subtitleStyle, t), + avatarTheme: + const AvatarThemeData().lerp(a.avatarTheme!, b.avatarTheme!, t), + color: Color.lerp(a.color, b.color, t), + ); + /// Merge with other [ChannelHeaderThemeData] ChannelHeaderThemeData merge(ChannelHeaderThemeData? other) { if (other == null) return this; return copyWith( - title: title?.merge(other.title) ?? other.title, - subtitle: subtitle?.merge(other.subtitle) ?? other.subtitle, + titleStyle: titleStyle?.merge(other.titleStyle) ?? other.titleStyle, + subtitleStyle: + subtitleStyle?.merge(other.subtitleStyle) ?? other.subtitleStyle, avatarTheme: avatarTheme?.merge(other.avatarTheme) ?? other.avatarTheme, color: other.color, ); } + + @override + bool operator ==(Object other) => + identical(this, other) || + other is ChannelHeaderThemeData && + runtimeType == other.runtimeType && + titleStyle == other.titleStyle && + subtitleStyle == other.subtitleStyle && + avatarTheme == other.avatarTheme && + color == other.color; + + @override + int get hashCode => + titleStyle.hashCode ^ + subtitleStyle.hashCode ^ + avatarTheme.hashCode ^ + color.hashCode; + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('title', titleStyle)) + ..add(DiagnosticsProperty('subtitle', subtitleStyle)) + ..add(DiagnosticsProperty('avatarTheme', avatarTheme)) + ..add(ColorProperty('color', color)); + } } diff --git a/packages/stream_chat_flutter/lib/src/theme/gallery_header_theme.dart b/packages/stream_chat_flutter/lib/src/theme/gallery_header_theme.dart index 611a77bc..862a9a9e 100644 --- a/packages/stream_chat_flutter/lib/src/theme/gallery_header_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/gallery_header_theme.dart @@ -86,7 +86,7 @@ class GalleryHeaderThemeData with Diagnosticable { /// The [TextStyle] to use for the [GalleryHeader] subtitle text. /// - /// Defaults to [ChannelPreviewTheme.subtitle]. + /// Defaults to [ChannelPreviewTheme.subtitleStyle]. final TextStyle? subtitleTextStyle; /// diff --git a/packages/stream_chat_flutter/lib/src/thread_header.dart b/packages/stream_chat_flutter/lib/src/thread_header.dart index bfde9a4c..0473ca48 100644 --- a/packages/stream_chat_flutter/lib/src/thread_header.dart +++ b/packages/stream_chat_flutter/lib/src/thread_header.dart @@ -112,12 +112,12 @@ class ThreadHeader extends StatelessWidget implements PreferredSizeWidget { children: [ Text( 'with ', - style: chatThemeData.channelTheme.channelHeaderTheme.subtitle, + style: chatThemeData.channelTheme.channelHeaderTheme.subtitleStyle, ), Flexible( child: ChannelName( textStyle: - chatThemeData.channelTheme.channelHeaderTheme.subtitle, + chatThemeData.channelTheme.channelHeaderTheme.subtitleStyle, ), ), ], @@ -150,14 +150,14 @@ class ThreadHeader extends StatelessWidget implements PreferredSizeWidget { title ?? Text( 'Thread Reply', - style: chatThemeData.channelTheme.channelHeaderTheme.title, + style: chatThemeData.channelTheme.channelHeaderTheme.titleStyle, ), const SizedBox(height: 2), if (showTypingIndicator) TypingIndicator( alignment: Alignment.center, channel: StreamChannel.of(context).channel, - style: chatThemeData.channelTheme.channelHeaderTheme.subtitle, + style: chatThemeData.channelTheme.channelHeaderTheme.subtitleStyle, parentId: parent.id, alternativeWidget: defaultSubtitle, )