diff --git a/CHANGELOG.md b/CHANGELOG.md index 431f48f9..bd93ed96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.15 + +- Fix MessageInput overflow + ## 0.1.14 - Add automatic keep alive to streamchat diff --git a/README.md b/README.md index 5bfb6907..eff6966c 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ The example is available under the [example](https://github.com/GetStream/stream ```yaml dependencies: - stream_chat_flutter: ^0.1.13 + stream_chat_flutter: ^0.1.15 ``` You should then run `flutter packages get` diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index b00c9f2d..f1025385 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -56,12 +56,13 @@ import 'stream_channel.dart'; /// The widget renders the ui based on the first ancestor of type [StreamChatTheme]. /// Modify it to change the widget appearance. class MessageInput extends StatefulWidget { - MessageInput({ - Key key, - this.onMessageSent, - this.parentMessage, - this.editMessage, - }) : super(key: key); + MessageInput( + {Key key, + this.onMessageSent, + this.parentMessage, + this.editMessage, + this.maxHeight = 150}) + : super(key: key); /// Message to edit final Message editMessage; @@ -72,6 +73,9 @@ class MessageInput extends StatefulWidget { /// Parent message in case of a thread final Message parentMessage; + /// Maximum Height for the TextField to grow before it starts scrolling + final double maxHeight; + @override _MessageInputState createState() => _MessageInputState(); } @@ -111,6 +115,7 @@ class _MessageInputState extends State { Flex _buildTextField(BuildContext context) { return Flex( direction: Axis.horizontal, + crossAxisAlignment: CrossAxisAlignment.end, children: [ _buildAttachmentButton(), _buildTextInput(context), @@ -133,54 +138,57 @@ class _MessageInputState extends State { Expanded _buildTextInput(BuildContext context) { return Expanded( - child: TextField( - key: Key('messageInputText'), - minLines: null, - maxLines: null, - onSubmitted: (_) { - _sendMessage(context); - }, - controller: _textController, - focusNode: _focusNode, - onChanged: (s) { - StreamChannel.of(context).channel.keyStroke(); + child: LimitedBox( + maxHeight: widget.maxHeight, + child: TextField( + key: Key('messageInputText'), + minLines: null, + maxLines: null, + onSubmitted: (_) { + _sendMessage(context); + }, + controller: _textController, + focusNode: _focusNode, + onChanged: (s) { + StreamChannel.of(context).channel.keyStroke(); - setState(() { - _messageIsPresent = s.trim().isNotEmpty; - }); + setState(() { + _messageIsPresent = s.trim().isNotEmpty; + }); - _commandsOverlay?.remove(); - _commandsOverlay = null; - _mentionsOverlay?.remove(); - _mentionsOverlay = null; + _commandsOverlay?.remove(); + _commandsOverlay = null; + _mentionsOverlay?.remove(); + _mentionsOverlay = null; - if (s.startsWith('/')) { - _commandsOverlay = _buildCommandsOverlayEntry(); - Overlay.of(context).insert(_commandsOverlay); - } + if (s.startsWith('/')) { + _commandsOverlay = _buildCommandsOverlayEntry(); + Overlay.of(context).insert(_commandsOverlay); + } - if (_textController.selection.isCollapsed && - (s[_textController.selection.start - 1] == '@' || - _textController.text - .substring(0, _textController.selection.start) - .split(' ') - .last - .contains('@'))) { - _mentionsOverlay = _buildMentionsOverlayEntry(); - Overlay.of(context).insert(_mentionsOverlay); - } - }, - onTap: () { - setState(() { - _typingStarted = true; - }); - }, - style: Theme.of(context).textTheme.body1, - autofocus: false, - decoration: InputDecoration( - hintText: 'Write a message', - prefixText: ' ', - border: InputBorder.none, + if (_textController.selection.isCollapsed && + (s[_textController.selection.start - 1] == '@' || + _textController.text + .substring(0, _textController.selection.start) + .split(' ') + .last + .contains('@'))) { + _mentionsOverlay = _buildMentionsOverlayEntry(); + Overlay.of(context).insert(_mentionsOverlay); + } + }, + onTap: () { + setState(() { + _typingStarted = true; + }); + }, + style: Theme.of(context).textTheme.body1, + autofocus: false, + decoration: InputDecoration( + hintText: 'Write a message', + prefixText: ' ', + border: InputBorder.none, + ), ), ), ); diff --git a/pubspec.yaml b/pubspec.yaml index 8055fa72..155134ed 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.1.14 +version: 0.1.15 environment: sdk: ">=2.3.0 <3.0.0"