From 949e83c6a99488e4a36f44e322d08d785bdf9059 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Thu, 25 Feb 2021 14:05:08 +0530 Subject: [PATCH] feat: Added message input theme and send button animation duration --- .../lib/src/message_input.dart | 3 +- .../lib/src/stream_chat_theme.dart | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/message_input.dart b/packages/stream_chat_flutter/lib/src/message_input.dart index 26feba69..c6da99fc 100644 --- a/packages/stream_chat_flutter/lib/src/message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input.dart @@ -392,7 +392,8 @@ class MessageInputState extends State { : CrossFadeState.showSecond, firstChild: _buildSendButton(context), secondChild: _buildIdleSendButton(context), - duration: Duration(milliseconds: 300), + duration: + StreamChatTheme.of(context).messageInputTheme.sendAnimationDuration, alignment: Alignment.center, ), ); 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 c2f3ee7e..9b246ace 100644 --- a/packages/stream_chat_flutter/lib/src/stream_chat_theme.dart +++ b/packages/stream_chat_flutter/lib/src/stream_chat_theme.dart @@ -60,6 +60,9 @@ class StreamChatThemeData { /// Theme of other users messages final MessageTheme otherMessageTheme; + /// Theme of other users messages + final MessageInputTheme messageInputTheme; + /// The widget that will be built when the channel image is unavailable final Widget Function(BuildContext, Channel) defaultChannelImage; @@ -80,6 +83,7 @@ class StreamChatThemeData { this.channelTheme, this.otherMessageTheme, this.ownMessageTheme, + this.messageInputTheme, this.defaultChannelImage, this.defaultUserImage, this.primaryIconTheme, @@ -108,6 +112,7 @@ class StreamChatThemeData { ChannelTheme channelTheme, MessageTheme ownMessageTheme, MessageTheme otherMessageTheme, + MessageInputTheme messageInputTheme, Widget Function(BuildContext, Channel) defaultChannelImage, Widget Function(BuildContext, User) defaultUserImage, IconThemeData primaryIconTheme, @@ -123,6 +128,7 @@ class StreamChatThemeData { channelTheme: channelTheme ?? this.channelTheme, ownMessageTheme: ownMessageTheme ?? this.ownMessageTheme, otherMessageTheme: otherMessageTheme ?? this.otherMessageTheme, + messageInputTheme: messageInputTheme ?? this.messageInputTheme, reactionIcons: reactionIcons ?? this.reactionIcons, ); @@ -143,6 +149,8 @@ class StreamChatThemeData { other.ownMessageTheme, otherMessageTheme: otherMessageTheme?.merge(other.otherMessageTheme) ?? other.otherMessageTheme, + messageInputTheme: messageInputTheme?.merge(other.messageInputTheme) ?? + other.messageInputTheme, reactionIcons: other.reactionIcons, ); } @@ -248,6 +256,9 @@ class StreamChatThemeData { ), ), ), + messageInputTheme: MessageInputTheme( + sendAnimationDuration: Duration(milliseconds: 7000), + ), reactionIcons: [ ReactionIcon( type: 'love', @@ -873,6 +884,27 @@ class ChannelHeaderTheme { } } +class MessageInputTheme { + final Duration sendAnimationDuration; + + const MessageInputTheme({ + this.sendAnimationDuration, + }); + + MessageInputTheme copyWith({Duration sendAnimationDuration}) => + MessageInputTheme( + sendAnimationDuration: + sendAnimationDuration ?? this.sendAnimationDuration, + ); + + MessageInputTheme merge(MessageInputTheme other) { + if (other == null) return this; + return copyWith( + sendAnimationDuration: other.sendAnimationDuration, + ); + } +} + class Effect { final double sigmaX; final double sigmaY;