chore: use MessageInputTheme in message_input.dart

This commit is contained in:
groovinchip
2021-07-29 11:07:17 -04:00
parent 700ce9a775
commit 1aa6298799
@@ -288,6 +288,7 @@ class MessageInputState extends State<MessageInput> {
late final TextEditingController textEditingController; late final TextEditingController textEditingController;
late StreamChatThemeData _streamChatTheme; late StreamChatThemeData _streamChatTheme;
late MessageInputThemeData _messageInputTheme;
bool get _hasQuotedMessage => widget.quotedMessage != null; bool get _hasQuotedMessage => widget.quotedMessage != null;
@@ -328,7 +329,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.inputBackgroundColor, color: _messageInputTheme.inputBackgroundColor,
), ),
child: SafeArea( child: SafeArea(
child: GestureDetector( child: GestureDetector(
@@ -484,7 +485,7 @@ class MessageInputState extends State<MessageInput> {
: CrossFadeState.showSecond, : CrossFadeState.showSecond,
firstChild: sendButton, firstChild: sendButton,
secondChild: widget.idleSendButton ?? _buildIdleSendButton(context), secondChild: widget.idleSendButton ?? _buildIdleSendButton(context),
duration: _streamChatTheme.messageInputTheme.sendAnimationDuration!, duration: _messageInputTheme.sendAnimationDuration!,
alignment: Alignment.center, alignment: Alignment.center,
); );
} }
@@ -509,7 +510,7 @@ class MessageInputState extends State<MessageInput> {
? pi ? pi
: 0, : 0,
child: StreamSvgIcon.emptyCircleLeft( child: StreamSvgIcon.emptyCircleLeft(
color: _streamChatTheme.messageInputTheme.expandButtonColor, color: _messageInputTheme.expandButtonColor,
), ),
), ),
padding: const EdgeInsets.all(0), padding: const EdgeInsets.all(0),
@@ -555,17 +556,17 @@ class MessageInputState extends State<MessageInput> {
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
margin: margin, margin: margin,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: _streamChatTheme.messageInputTheme.borderRadius, borderRadius: _messageInputTheme.borderRadius,
gradient: _focusNode.hasFocus gradient: _focusNode.hasFocus
? _streamChatTheme.messageInputTheme.activeBorderGradient ? _messageInputTheme.activeBorderGradient
: _streamChatTheme.messageInputTheme.idleBorderGradient, : _messageInputTheme.idleBorderGradient,
), ),
child: Padding( child: Padding(
padding: const EdgeInsets.all(1.5), padding: const EdgeInsets.all(1.5),
child: DecoratedBox( child: DecoratedBox(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: _streamChatTheme.messageInputTheme.borderRadius, borderRadius: _messageInputTheme.borderRadius,
color: _streamChatTheme.messageInputTheme.inputBackgroundColor, color: _messageInputTheme.inputBackgroundColor,
), ),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@@ -583,7 +584,7 @@ class MessageInputState extends State<MessageInput> {
keyboardType: widget.keyboardType, keyboardType: widget.keyboardType,
controller: textEditingController, controller: textEditingController,
focusNode: _focusNode, focusNode: _focusNode,
style: _streamChatTheme.messageInputTheme.inputTextStyle, style: _messageInputTheme.inputTextStyle,
autofocus: widget.autofocus, autofocus: widget.autofocus,
textAlignVertical: TextAlignVertical.center, textAlignVertical: TextAlignVertical.center,
decoration: _getInputDecoration(), decoration: _getInputDecoration(),
@@ -599,11 +600,11 @@ class MessageInputState extends State<MessageInput> {
} }
InputDecoration _getInputDecoration() { InputDecoration _getInputDecoration() {
final passedDecoration = _streamChatTheme.messageInputTheme.inputDecoration; final passedDecoration = _messageInputTheme.inputDecoration;
return InputDecoration( return InputDecoration(
isDense: true, isDense: true,
hintText: _getHint(), hintText: _getHint(),
hintStyle: _streamChatTheme.messageInputTheme.inputTextStyle!.copyWith( hintStyle: _messageInputTheme.inputTextStyle!.copyWith(
color: _streamChatTheme.colorTheme.textLowEmphasis, color: _streamChatTheme.colorTheme.textLowEmphasis,
), ),
border: const OutlineInputBorder( border: const OutlineInputBorder(
@@ -1685,8 +1686,8 @@ class MessageInputState extends State<MessageInput> {
color: s.isNotEmpty color: s.isNotEmpty
? _streamChatTheme.colorTheme.disabled ? _streamChatTheme.colorTheme.disabled
: (_commandsOverlay != null : (_commandsOverlay != null
? _streamChatTheme.messageInputTheme.actionButtonColor ? _messageInputTheme.actionButtonColor
: _streamChatTheme.messageInputTheme.actionButtonIdleColor), : _messageInputTheme.actionButtonIdleColor),
), ),
padding: const EdgeInsets.all(0), padding: const EdgeInsets.all(0),
constraints: const BoxConstraints.tightFor( constraints: const BoxConstraints.tightFor(
@@ -1723,8 +1724,8 @@ class MessageInputState extends State<MessageInput> {
Widget _buildAttachmentButton() => IconButton( Widget _buildAttachmentButton() => IconButton(
icon: StreamSvgIcon.attach( icon: StreamSvgIcon.attach(
color: _openFilePickerSection color: _openFilePickerSection
? _streamChatTheme.messageInputTheme.actionButtonColor ? _messageInputTheme.actionButtonColor
: _streamChatTheme.messageInputTheme.actionButtonIdleColor, : _messageInputTheme.actionButtonIdleColor,
), ),
padding: const EdgeInsets.all(0), padding: const EdgeInsets.all(0),
constraints: const BoxConstraints.tightFor( constraints: const BoxConstraints.tightFor(
@@ -1959,7 +1960,7 @@ class MessageInputState extends State<MessageInput> {
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: StreamSvgIcon( child: StreamSvgIcon(
assetName: _getIdleSendIcon(), assetName: _getIdleSendIcon(),
color: _streamChatTheme.messageInputTheme.sendButtonIdleColor, color: _messageInputTheme.sendButtonIdleColor,
), ),
); );
@@ -1975,7 +1976,7 @@ class MessageInputState extends State<MessageInput> {
), ),
icon: StreamSvgIcon( icon: StreamSvgIcon(
assetName: _getSendIcon(), assetName: _getSendIcon(),
color: _streamChatTheme.messageInputTheme.sendButtonColor, color: _messageInputTheme.sendButtonColor,
), ),
), ),
); );
@@ -2182,6 +2183,7 @@ class MessageInputState extends State<MessageInput> {
@override @override
void didChangeDependencies() { void didChangeDependencies() {
_streamChatTheme = StreamChatTheme.of(context); _streamChatTheme = StreamChatTheme.of(context);
_messageInputTheme = MessageInputTheme.of(context);
if (widget.editMessage != null && !_initialized) { if (widget.editMessage != null && !_initialized) {
FocusScope.of(context).requestFocus(_focusNode); FocusScope.of(context).requestFocus(_focusNode);
_initialized = true; _initialized = true;