chore: upgrade ChannelHeaderTheme
This commit is contained in:
@@ -188,10 +188,10 @@ class StreamChatThemeData {
|
|||||||
/// Theme configuration for the [UserListView] widget.
|
/// Theme configuration for the [UserListView] widget.
|
||||||
final UserListViewThemeData userListViewTheme;
|
final UserListViewThemeData userListViewTheme;
|
||||||
|
|
||||||
/// Theme configuration for the [] widget.
|
/// Theme configuration for the [MessageSearchListView] widget.
|
||||||
final MessageSearchListViewThemeData messageSearchListViewTheme;
|
final MessageSearchListViewThemeData messageSearchListViewTheme;
|
||||||
|
|
||||||
/// Theme configuration for the [] widget.
|
/// Theme configuration for the [UserAvatar] widget.
|
||||||
final AvatarThemeData avatarTheme;
|
final AvatarThemeData avatarTheme;
|
||||||
|
|
||||||
/// Creates a copy of [StreamChatThemeData] with specified attributes
|
/// Creates a copy of [StreamChatThemeData] with specified attributes
|
||||||
@@ -279,7 +279,7 @@ class StreamChatThemeData {
|
|||||||
final iconTheme =
|
final iconTheme =
|
||||||
IconThemeData(color: colorTheme.textHighEmphasis.withOpacity(.5));
|
IconThemeData(color: colorTheme.textHighEmphasis.withOpacity(.5));
|
||||||
final channelTheme = ChannelTheme(
|
final channelTheme = ChannelTheme(
|
||||||
channelHeaderTheme: ChannelHeaderTheme(
|
channelHeaderTheme: ChannelHeaderThemeData(
|
||||||
avatarTheme: AvatarThemeData(
|
avatarTheme: AvatarThemeData(
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
constraints: const BoxConstraints.tightFor(
|
constraints: const BoxConstraints.tightFor(
|
||||||
@@ -497,7 +497,7 @@ class StreamChatThemeData {
|
|||||||
backgroundColor: colorTheme.appBg,
|
backgroundColor: colorTheme.appBg,
|
||||||
),
|
),
|
||||||
avatarTheme: AvatarThemeData(
|
avatarTheme: AvatarThemeData(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(20),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,64 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.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/avatar_theme.dart';
|
||||||
|
|
||||||
/// Theme for [ChannelHeader]
|
/// Overrides the default style of [ChannelHeader] descendants.
|
||||||
class ChannelHeaderTheme {
|
///
|
||||||
/// Constructor for creating a [ChannelHeaderTheme]
|
/// See also:
|
||||||
|
///
|
||||||
|
/// * [ChannelHeaderThemeData], which is used to configure this theme.
|
||||||
|
class ChannelHeaderTheme extends InheritedTheme {
|
||||||
|
/// Creates a [ChannelHeaderTheme].
|
||||||
|
///
|
||||||
|
/// The [data] parameter must not be null.
|
||||||
const ChannelHeaderTheme({
|
const ChannelHeaderTheme({
|
||||||
|
Key? key,
|
||||||
|
required this.data,
|
||||||
|
required Widget child,
|
||||||
|
}) : super(key: key, child: child);
|
||||||
|
|
||||||
|
/// The configuration of this theme.
|
||||||
|
final ChannelHeaderThemeData data;
|
||||||
|
|
||||||
|
/// The closest instance of this class that encloses the given context.
|
||||||
|
///
|
||||||
|
/// If there is no enclosing [ChannelHeaderTheme] widget, then
|
||||||
|
/// [StreamChatThemeData.channelTheme.channelHeaderTheme] is used.
|
||||||
|
///
|
||||||
|
/// Typical usage is as follows:
|
||||||
|
///
|
||||||
|
/// ```dart
|
||||||
|
/// final theme = ChannelHeaderTheme.of(context);
|
||||||
|
/// ```
|
||||||
|
static ChannelHeaderThemeData of(BuildContext context) {
|
||||||
|
final channelHeaderTheme =
|
||||||
|
context.dependOnInheritedWidgetOfExactType<ChannelHeaderTheme>();
|
||||||
|
return channelHeaderTheme?.data ??
|
||||||
|
StreamChatTheme.of(context).channelTheme.channelHeaderTheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget wrap(BuildContext context, Widget child) =>
|
||||||
|
ChannelHeaderTheme(data: data, child: child);
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool updateShouldNotify(ChannelHeaderTheme oldWidget) =>
|
||||||
|
data != oldWidget.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A style that overrides the default appearance of [ChannelHeader]s when used
|
||||||
|
/// with [ChannelHeaderTheme] or with the overall [StreamChatTheme]'s
|
||||||
|
/// [StreamChatThemeData.channelHeaderTheme].
|
||||||
|
///
|
||||||
|
/// See also:
|
||||||
|
///
|
||||||
|
/// * [ChannelHeaderTheme], the theme which is configured with this class.
|
||||||
|
/// * [StreamChatThemeData.channelHeaderTheme], which can be used to override
|
||||||
|
/// the default style for [ChannelHeader]s below the overall [StreamChatTheme].
|
||||||
|
class ChannelHeaderThemeData with Diagnosticable {
|
||||||
|
/// Creates a [ChannelHeaderThemeData]
|
||||||
|
const ChannelHeaderThemeData({
|
||||||
this.title,
|
this.title,
|
||||||
this.subtitle,
|
this.subtitle,
|
||||||
this.avatarTheme,
|
this.avatarTheme,
|
||||||
@@ -20,25 +74,25 @@ class ChannelHeaderTheme {
|
|||||||
/// Theme for avatar
|
/// Theme for avatar
|
||||||
final AvatarThemeData? avatarTheme;
|
final AvatarThemeData? avatarTheme;
|
||||||
|
|
||||||
/// Color for [ChannelHeaderTheme]
|
/// Color for [ChannelHeaderThemeData]
|
||||||
final Color? color;
|
final Color? color;
|
||||||
|
|
||||||
/// Copy with theme
|
/// Copy with theme
|
||||||
ChannelHeaderTheme copyWith({
|
ChannelHeaderThemeData copyWith({
|
||||||
TextStyle? title,
|
TextStyle? title,
|
||||||
TextStyle? subtitle,
|
TextStyle? subtitle,
|
||||||
AvatarThemeData? avatarTheme,
|
AvatarThemeData? avatarTheme,
|
||||||
Color? color,
|
Color? color,
|
||||||
}) =>
|
}) =>
|
||||||
ChannelHeaderTheme(
|
ChannelHeaderThemeData(
|
||||||
title: title ?? this.title,
|
title: title ?? this.title,
|
||||||
subtitle: subtitle ?? this.subtitle,
|
subtitle: subtitle ?? this.subtitle,
|
||||||
avatarTheme: avatarTheme ?? this.avatarTheme,
|
avatarTheme: avatarTheme ?? this.avatarTheme,
|
||||||
color: color ?? this.color,
|
color: color ?? this.color,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Merge with other [ChannelHeaderTheme]
|
/// Merge with other [ChannelHeaderThemeData]
|
||||||
ChannelHeaderTheme merge(ChannelHeaderTheme? other) {
|
ChannelHeaderThemeData merge(ChannelHeaderThemeData? other) {
|
||||||
if (other == null) return this;
|
if (other == null) return this;
|
||||||
return copyWith(
|
return copyWith(
|
||||||
title: title?.merge(other.title) ?? other.title,
|
title: title?.merge(other.title) ?? other.title,
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ class ChannelTheme {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/// Theme of the [ChannelHeader] widget
|
/// Theme of the [ChannelHeader] widget
|
||||||
final ChannelHeaderTheme channelHeaderTheme;
|
final ChannelHeaderThemeData channelHeaderTheme;
|
||||||
|
|
||||||
/// Creates a copy of [ChannelTheme] with specified attributes overridden.
|
/// Creates a copy of [ChannelTheme] with specified attributes overridden.
|
||||||
ChannelTheme copyWith({
|
ChannelTheme copyWith({
|
||||||
ChannelHeaderTheme? channelHeaderTheme,
|
ChannelHeaderThemeData? channelHeaderTheme,
|
||||||
}) =>
|
}) =>
|
||||||
ChannelTheme(
|
ChannelTheme(
|
||||||
channelHeaderTheme: channelHeaderTheme ?? this.channelHeaderTheme,
|
channelHeaderTheme: channelHeaderTheme ?? this.channelHeaderTheme,
|
||||||
|
|||||||
Reference in New Issue
Block a user