Merge branch 'develop' into message-input-controller
This commit is contained in:
@@ -218,6 +218,7 @@ class MessageInput extends StatefulWidget {
|
||||
this.mentionAllAppUsers = false,
|
||||
this.attachmentsPickerBuilder,
|
||||
this.sendButtonBuilder,
|
||||
this.shouldKeepFocusAfterMessage,
|
||||
}) : assert(
|
||||
initialMessage == null || editMessage == null,
|
||||
"Can't provide both `initialMessage` and `editMessage`",
|
||||
@@ -342,6 +343,10 @@ class MessageInput extends StatefulWidget {
|
||||
/// Builder for creating send button
|
||||
final MessageRelatedBuilder? sendButtonBuilder;
|
||||
|
||||
/// Defines if the [MessageInput] loses focuses after a message is sent.
|
||||
/// The default behaviour keeps focus until a command is enabled.
|
||||
final bool? shouldKeepFocusAfterMessage;
|
||||
|
||||
@override
|
||||
MessageInputState createState() => MessageInputState();
|
||||
|
||||
@@ -988,7 +993,8 @@ class MessageInputState extends State<MessageInput> {
|
||||
}
|
||||
|
||||
Widget _buildMentionsOverlayEntry() {
|
||||
if (messageInputController.selectionStart < 0) {
|
||||
final channel = StreamChannel.of(context).channel;
|
||||
if (messageInputController.selectionStart < 0 || channel.state == null) {
|
||||
return const Offstage();
|
||||
}
|
||||
|
||||
@@ -1020,7 +1026,7 @@ class MessageInputState extends State<MessageInput> {
|
||||
query: query,
|
||||
mentionAllAppUsers: widget.mentionAllAppUsers,
|
||||
client: StreamChat.of(context).client,
|
||||
channel: StreamChannel.of(context).channel,
|
||||
channel: channel,
|
||||
size: Size(renderObject.size.width - 16, 400),
|
||||
mentionsTileBuilder: tileBuilder,
|
||||
onMentionUserTap: (user) {
|
||||
@@ -1476,7 +1482,6 @@ class MessageInputState extends State<MessageInput> {
|
||||
}
|
||||
final res = await FilePicker.platform.pickFiles(
|
||||
type: type,
|
||||
withData: true,
|
||||
);
|
||||
if (res?.files.isNotEmpty == true) {
|
||||
file = res!.files.single.toAttachmentFile;
|
||||
@@ -1554,7 +1559,9 @@ class MessageInputState extends State<MessageInput> {
|
||||
return;
|
||||
}
|
||||
|
||||
final shouldUnfocus = _commandEnabled;
|
||||
var shouldKeepFocus = widget.shouldKeepFocusAfterMessage;
|
||||
|
||||
shouldKeepFocus ??= !_commandEnabled;
|
||||
|
||||
if (_commandEnabled) {
|
||||
text = '${'/${_chosenCommand!.name} '}$text';
|
||||
@@ -1620,8 +1627,10 @@ class MessageInputState extends State<MessageInput> {
|
||||
sendingFuture = channel.updateMessage(message);
|
||||
}
|
||||
|
||||
if (!shouldUnfocus) {
|
||||
if (shouldKeepFocus) {
|
||||
FocusScope.of(context).requestFocus(_focusNode);
|
||||
} else {
|
||||
FocusScope.of(context).unfocus();
|
||||
}
|
||||
|
||||
final resp = await sendingFuture;
|
||||
|
||||
Reference in New Issue
Block a user