feat(ui): add the ability to add a background image in MessageListView

This commit is contained in:
Efthymios Sarmpanis
2021-10-09 20:06:27 +03:00
parent 0146d2cc85
commit 7d90dc0cfe
8 changed files with 128 additions and 9 deletions
@@ -60,17 +60,23 @@ class MessageListViewThemeData with Diagnosticable {
/// Creates a [MessageListViewThemeData].
const MessageListViewThemeData({
this.backgroundColor,
this.backgroundImage,
});
/// The color of the [MessageListView] background.
final Color? backgroundColor;
/// The image of the [MessageListView] background.
final DecorationImage? backgroundImage;
/// Copies this [MessageListViewThemeData] to another.
MessageListViewThemeData copyWith({
Color? backgroundColor,
DecorationImage? backgroundImage,
}) =>
MessageListViewThemeData(
backgroundColor: backgroundColor ?? this.backgroundColor,
backgroundImage: backgroundImage ?? this.backgroundImage,
);
/// Linearly interpolate between two [MessageListView] themes.
@@ -83,6 +89,7 @@ class MessageListViewThemeData with Diagnosticable {
) =>
MessageListViewThemeData(
backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t),
backgroundImage: t < 0.5 ? a.backgroundImage : b.backgroundImage,
);
/// Merges one [MessageListViewThemeData] with another.
@@ -90,6 +97,7 @@ class MessageListViewThemeData with Diagnosticable {
if (other == null) return this;
return copyWith(
backgroundColor: other.backgroundColor,
backgroundImage: other.backgroundImage,
);
}
@@ -98,14 +106,20 @@ class MessageListViewThemeData with Diagnosticable {
identical(this, other) ||
other is MessageListViewThemeData &&
runtimeType == other.runtimeType &&
backgroundColor == other.backgroundColor;
backgroundColor == other.backgroundColor &&
backgroundImage == other.backgroundImage;
@override
int get hashCode => backgroundColor.hashCode;
int get hashCode => backgroundColor.hashCode + backgroundImage.hashCode;
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(ColorProperty('backgroundColor', backgroundColor));
properties
..add(ColorProperty('backgroundColor', backgroundColor))
..add(
DiagnosticsProperty<DecorationImage>('backgroundImage', backgroundImage,
defaultValue: null),
);
}
}