chore: add lerp, hashcode, ==, and diagnosticable to message_input_theme.dart
This commit is contained in:
@@ -562,7 +562,8 @@ class _MessageActionsModalState extends State<MessageActionsModal> {
|
|||||||
elevation: 2,
|
elevation: 2,
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
backgroundColor: streamChatThemeData.messageInputTheme.inputBackground,
|
backgroundColor:
|
||||||
|
streamChatThemeData.messageInputTheme.inputBackgroundColor,
|
||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius: BorderRadius.only(
|
||||||
topLeft: Radius.circular(16),
|
topLeft: Radius.circular(16),
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Widget child = DecoratedBox(
|
Widget child = DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: _streamChatTheme.messageInputTheme.inputBackground,
|
color: _streamChatTheme.messageInputTheme.inputBackgroundColor,
|
||||||
),
|
),
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
@@ -565,7 +565,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: _streamChatTheme.messageInputTheme.borderRadius,
|
borderRadius: _streamChatTheme.messageInputTheme.borderRadius,
|
||||||
color: _streamChatTheme.messageInputTheme.inputBackground,
|
color: _streamChatTheme.messageInputTheme.inputBackgroundColor,
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ class StreamChatThemeData {
|
|||||||
expandButtonColor: colorTheme.accentPrimary,
|
expandButtonColor: colorTheme.accentPrimary,
|
||||||
sendButtonColor: colorTheme.accentPrimary,
|
sendButtonColor: colorTheme.accentPrimary,
|
||||||
sendButtonIdleColor: colorTheme.disabled,
|
sendButtonIdleColor: colorTheme.disabled,
|
||||||
inputBackground: colorTheme.barsBg,
|
inputBackgroundColor: colorTheme.barsBg,
|
||||||
inputTextStyle: textTheme.body,
|
inputTextStyle: textTheme.body,
|
||||||
idleBorderGradient: LinearGradient(
|
idleBorderGradient: LinearGradient(
|
||||||
colors: [
|
colors: [
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:stream_chat_flutter/src/extension.dart';
|
import 'package:stream_chat_flutter/src/extension.dart';
|
||||||
|
|
||||||
/// Defines the theme dedicated to the [MessageInput] widget
|
/// Defines the theme dedicated to the [MessageInput] widget
|
||||||
class MessageInputTheme {
|
class MessageInputTheme with Diagnosticable {
|
||||||
/// Returns a new [MessageInputTheme]
|
/// Returns a new [MessageInputTheme]
|
||||||
const MessageInputTheme({
|
const MessageInputTheme({
|
||||||
this.sendAnimationDuration,
|
this.sendAnimationDuration,
|
||||||
@@ -10,7 +11,7 @@ class MessageInputTheme {
|
|||||||
this.sendButtonColor,
|
this.sendButtonColor,
|
||||||
this.actionButtonIdleColor,
|
this.actionButtonIdleColor,
|
||||||
this.sendButtonIdleColor,
|
this.sendButtonIdleColor,
|
||||||
this.inputBackground,
|
this.inputBackgroundColor,
|
||||||
this.inputTextStyle,
|
this.inputTextStyle,
|
||||||
this.inputDecoration,
|
this.inputDecoration,
|
||||||
this.activeBorderGradient,
|
this.activeBorderGradient,
|
||||||
@@ -38,7 +39,7 @@ class MessageInputTheme {
|
|||||||
final Color? expandButtonColor;
|
final Color? expandButtonColor;
|
||||||
|
|
||||||
/// Background color of [MessageInput]
|
/// Background color of [MessageInput]
|
||||||
final Color? inputBackground;
|
final Color? inputBackgroundColor;
|
||||||
|
|
||||||
/// TextStyle of [MessageInput]
|
/// TextStyle of [MessageInput]
|
||||||
final TextStyle? inputTextStyle;
|
final TextStyle? inputTextStyle;
|
||||||
@@ -58,7 +59,7 @@ class MessageInputTheme {
|
|||||||
/// Returns a new [MessageInputTheme] replacing some of its properties
|
/// Returns a new [MessageInputTheme] replacing some of its properties
|
||||||
MessageInputTheme copyWith({
|
MessageInputTheme copyWith({
|
||||||
Duration? sendAnimationDuration,
|
Duration? sendAnimationDuration,
|
||||||
Color? inputBackground,
|
Color? inputBackgroundColor,
|
||||||
Color? actionButtonColor,
|
Color? actionButtonColor,
|
||||||
Color? sendButtonColor,
|
Color? sendButtonColor,
|
||||||
Color? actionButtonIdleColor,
|
Color? actionButtonIdleColor,
|
||||||
@@ -73,7 +74,7 @@ class MessageInputTheme {
|
|||||||
MessageInputTheme(
|
MessageInputTheme(
|
||||||
sendAnimationDuration:
|
sendAnimationDuration:
|
||||||
sendAnimationDuration ?? this.sendAnimationDuration,
|
sendAnimationDuration ?? this.sendAnimationDuration,
|
||||||
inputBackground: inputBackground ?? this.inputBackground,
|
inputBackgroundColor: inputBackgroundColor ?? this.inputBackgroundColor,
|
||||||
actionButtonColor: actionButtonColor ?? this.actionButtonColor,
|
actionButtonColor: actionButtonColor ?? this.actionButtonColor,
|
||||||
sendButtonColor: sendButtonColor ?? this.sendButtonColor,
|
sendButtonColor: sendButtonColor ?? this.sendButtonColor,
|
||||||
actionButtonIdleColor:
|
actionButtonIdleColor:
|
||||||
@@ -87,12 +88,40 @@ class MessageInputTheme {
|
|||||||
borderRadius: borderRadius ?? this.borderRadius,
|
borderRadius: borderRadius ?? this.borderRadius,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// Linearly interpolate from one [MessageInputTheme] to another.
|
||||||
|
MessageInputTheme lerp(
|
||||||
|
MessageInputTheme a,
|
||||||
|
MessageInputTheme b,
|
||||||
|
double t,
|
||||||
|
) =>
|
||||||
|
MessageInputTheme(
|
||||||
|
actionButtonColor:
|
||||||
|
Color.lerp(a.actionButtonColor, b.actionButtonColor, t),
|
||||||
|
actionButtonIdleColor:
|
||||||
|
Color.lerp(a.actionButtonIdleColor, b.actionButtonIdleColor, t),
|
||||||
|
activeBorderGradient:
|
||||||
|
Gradient.lerp(a.activeBorderGradient, b.activeBorderGradient, t),
|
||||||
|
borderRadius: BorderRadius.lerp(a.borderRadius, b.borderRadius, t),
|
||||||
|
expandButtonColor:
|
||||||
|
Color.lerp(a.expandButtonColor, b.expandButtonColor, t),
|
||||||
|
idleBorderGradient:
|
||||||
|
Gradient.lerp(a.idleBorderGradient, b.idleBorderGradient, t),
|
||||||
|
inputBackgroundColor:
|
||||||
|
Color.lerp(a.inputBackgroundColor, b.inputBackgroundColor, t),
|
||||||
|
inputTextStyle: TextStyle.lerp(a.inputTextStyle, b.inputTextStyle, t),
|
||||||
|
sendButtonColor: Color.lerp(a.sendButtonColor, b.sendButtonColor, t),
|
||||||
|
sendButtonIdleColor:
|
||||||
|
Color.lerp(a.sendButtonIdleColor, b.sendButtonIdleColor, t),
|
||||||
|
sendAnimationDuration: a.sendAnimationDuration,
|
||||||
|
inputDecoration: a.inputDecoration,
|
||||||
|
);
|
||||||
|
|
||||||
/// Merges [this] [MessageInputTheme] with the [other]
|
/// Merges [this] [MessageInputTheme] with the [other]
|
||||||
MessageInputTheme merge(MessageInputTheme? other) {
|
MessageInputTheme merge(MessageInputTheme? other) {
|
||||||
if (other == null) return this;
|
if (other == null) return this;
|
||||||
return copyWith(
|
return copyWith(
|
||||||
sendAnimationDuration: other.sendAnimationDuration,
|
sendAnimationDuration: other.sendAnimationDuration,
|
||||||
inputBackground: other.inputBackground,
|
inputBackgroundColor: other.inputBackgroundColor,
|
||||||
actionButtonColor: other.actionButtonColor,
|
actionButtonColor: other.actionButtonColor,
|
||||||
actionButtonIdleColor: other.actionButtonIdleColor,
|
actionButtonIdleColor: other.actionButtonIdleColor,
|
||||||
sendButtonColor: other.sendButtonColor,
|
sendButtonColor: other.sendButtonColor,
|
||||||
@@ -107,4 +136,55 @@ class MessageInputTheme {
|
|||||||
expandButtonColor: other.expandButtonColor,
|
expandButtonColor: other.expandButtonColor,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
identical(this, other) ||
|
||||||
|
other is MessageInputTheme &&
|
||||||
|
runtimeType == other.runtimeType &&
|
||||||
|
sendAnimationDuration == other.sendAnimationDuration &&
|
||||||
|
sendButtonColor == other.sendButtonColor &&
|
||||||
|
actionButtonColor == other.actionButtonColor &&
|
||||||
|
sendButtonIdleColor == other.sendButtonIdleColor &&
|
||||||
|
actionButtonIdleColor == other.actionButtonIdleColor &&
|
||||||
|
expandButtonColor == other.expandButtonColor &&
|
||||||
|
inputBackgroundColor == other.inputBackgroundColor &&
|
||||||
|
inputTextStyle == other.inputTextStyle &&
|
||||||
|
inputDecoration == other.inputDecoration &&
|
||||||
|
idleBorderGradient == other.idleBorderGradient &&
|
||||||
|
activeBorderGradient == other.activeBorderGradient &&
|
||||||
|
borderRadius == other.borderRadius;
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode =>
|
||||||
|
sendAnimationDuration.hashCode ^
|
||||||
|
sendButtonColor.hashCode ^
|
||||||
|
actionButtonColor.hashCode ^
|
||||||
|
sendButtonIdleColor.hashCode ^
|
||||||
|
actionButtonIdleColor.hashCode ^
|
||||||
|
expandButtonColor.hashCode ^
|
||||||
|
inputBackgroundColor.hashCode ^
|
||||||
|
inputTextStyle.hashCode ^
|
||||||
|
inputDecoration.hashCode ^
|
||||||
|
idleBorderGradient.hashCode ^
|
||||||
|
activeBorderGradient.hashCode ^
|
||||||
|
borderRadius.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||||
|
super.debugFillProperties(properties);
|
||||||
|
properties
|
||||||
|
..add(DiagnosticsProperty('sendAnimationDuration', sendAnimationDuration))
|
||||||
|
..add(ColorProperty('inputBackgroundColor', inputBackgroundColor))
|
||||||
|
..add(ColorProperty('actionButtonColor', actionButtonColor))
|
||||||
|
..add(ColorProperty('actionButtonIdleColor', actionButtonIdleColor))
|
||||||
|
..add(ColorProperty('sendButtonColor', sendButtonColor))
|
||||||
|
..add(ColorProperty('sendButtonIdleColor', sendButtonIdleColor))
|
||||||
|
..add(DiagnosticsProperty('inputTextStyle', inputTextStyle))
|
||||||
|
..add(DiagnosticsProperty('inputDecoration', inputDecoration))
|
||||||
|
..add(DiagnosticsProperty('activeBorderGradient', activeBorderGradient))
|
||||||
|
..add(DiagnosticsProperty('idleBorderGradient', idleBorderGradient))
|
||||||
|
..add(DiagnosticsProperty('borderRadius', borderRadius))
|
||||||
|
..add(ColorProperty('expandButtonColor', expandButtonColor));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user