@@ -15,7 +15,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Flutter action
|
- name: Flutter action
|
||||||
uses: subosito/flutter-action@v1.3.2
|
uses: subosito/flutter-action@v1.4.0
|
||||||
with:
|
with:
|
||||||
channel: 'stable'
|
channel: 'stable'
|
||||||
- name: Get dependencies
|
- name: Get dependencies
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
## 0.2.13+1
|
||||||
|
|
||||||
|
- Use TextEditingController.addListener instead of TextField.onChanged
|
||||||
|
|
||||||
## 0.2.13
|
## 0.2.13
|
||||||
|
|
||||||
- Update llc dependency
|
- Update llc dependency
|
||||||
|
|||||||
+62
-74
@@ -77,25 +77,25 @@ enum DefaultAttachmentTypes {
|
|||||||
/// Modify it to change the widget appearance.
|
/// Modify it to change the widget appearance.
|
||||||
class MessageInput extends StatefulWidget {
|
class MessageInput extends StatefulWidget {
|
||||||
/// Instantiate a new MessageInput
|
/// Instantiate a new MessageInput
|
||||||
MessageInput(
|
MessageInput({
|
||||||
{Key key,
|
Key key,
|
||||||
this.onMessageSent,
|
this.onMessageSent,
|
||||||
this.preMessageSending,
|
this.preMessageSending,
|
||||||
this.parentMessage,
|
this.parentMessage,
|
||||||
this.editMessage,
|
this.editMessage,
|
||||||
this.maxHeight = 150,
|
this.maxHeight = 150,
|
||||||
this.keyboardType = TextInputType.multiline,
|
this.keyboardType = TextInputType.multiline,
|
||||||
this.disableAttachments = false,
|
this.disableAttachments = false,
|
||||||
this.doImageUploadRequest,
|
this.doImageUploadRequest,
|
||||||
this.doFileUploadRequest,
|
this.doFileUploadRequest,
|
||||||
this.initialMessage,
|
this.initialMessage,
|
||||||
this.textEditingController,
|
this.textEditingController,
|
||||||
this.actions,
|
this.actions,
|
||||||
this.actionsLocation = ActionsLocation.left,
|
this.actionsLocation = ActionsLocation.left,
|
||||||
this.attachmentThumbnailBuilders,
|
this.attachmentThumbnailBuilders,
|
||||||
this.inputTextStyle,
|
this.inputTextStyle,
|
||||||
this.attachmentIconColor})
|
this.attachmentIconColor,
|
||||||
: super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// Message to edit
|
/// Message to edit
|
||||||
final Message editMessage;
|
final Message editMessage;
|
||||||
@@ -252,36 +252,6 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
keyboardType: widget.keyboardType,
|
keyboardType: widget.keyboardType,
|
||||||
controller: textEditingController,
|
controller: textEditingController,
|
||||||
focusNode: _focusNode,
|
focusNode: _focusNode,
|
||||||
onChanged: (s) {
|
|
||||||
StreamChannel.of(context).channel.keyStroke(
|
|
||||||
widget.parentMessage?.id,
|
|
||||||
);
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
_messageIsPresent = s.trim().isNotEmpty;
|
|
||||||
});
|
|
||||||
|
|
||||||
_commandsOverlay?.remove();
|
|
||||||
_commandsOverlay = null;
|
|
||||||
_mentionsOverlay?.remove();
|
|
||||||
_mentionsOverlay = null;
|
|
||||||
|
|
||||||
if (s.startsWith('/')) {
|
|
||||||
_commandsOverlay = _buildCommandsOverlayEntry();
|
|
||||||
Overlay.of(context).insert(_commandsOverlay);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (textEditingController.selection.isCollapsed &&
|
|
||||||
(s[textEditingController.selection.start - 1] == '@' ||
|
|
||||||
textEditingController.text
|
|
||||||
.substring(0, textEditingController.selection.start)
|
|
||||||
.split(' ')
|
|
||||||
.last
|
|
||||||
.contains('@'))) {
|
|
||||||
_mentionsOverlay = _buildMentionsOverlayEntry();
|
|
||||||
Overlay.of(context).insert(_mentionsOverlay);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_typingStarted = true;
|
_typingStarted = true;
|
||||||
@@ -403,7 +373,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
|
|
||||||
OverlayEntry _buildMentionsOverlayEntry() {
|
OverlayEntry _buildMentionsOverlayEntry() {
|
||||||
final splits = textEditingController.text
|
final splits = textEditingController.text
|
||||||
.substring(0, textEditingController.value.selection.start)
|
.substring(0, textEditingController.value.selection.baseOffset)
|
||||||
.split('@');
|
.split('@');
|
||||||
final query = splits.last.toLowerCase();
|
final query = splits.last.toLowerCase();
|
||||||
|
|
||||||
@@ -467,7 +437,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
text: rejoin +
|
text: rejoin +
|
||||||
textEditingController.text.substring(
|
textEditingController.text.substring(
|
||||||
textEditingController
|
textEditingController
|
||||||
.selection.start),
|
.selection.baseOffset),
|
||||||
selection: TextSelection.collapsed(
|
selection: TextSelection.collapsed(
|
||||||
offset: rejoin.length,
|
offset: rejoin.length,
|
||||||
),
|
),
|
||||||
@@ -962,41 +932,59 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
if (!kIsWeb) {
|
if (!kIsWeb) {
|
||||||
_keyboardListener = KeyboardVisibility.onChange.listen((visible) {
|
_keyboardListener = KeyboardVisibility.onChange.listen((visible) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
if (_commandsOverlay != null) {
|
_onChange();
|
||||||
if (textEditingController.text.startsWith('/')) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
_commandsOverlay = _buildCommandsOverlayEntry();
|
|
||||||
Overlay.of(context).insert(_commandsOverlay);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_mentionsOverlay != null) {
|
|
||||||
if (textEditingController.text.contains('@')) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
_mentionsOverlay = _buildCommandsOverlayEntry();
|
|
||||||
Overlay.of(context).insert(_mentionsOverlay);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (_commandsOverlay != null) {
|
_commandsOverlay?.remove();
|
||||||
_commandsOverlay.remove();
|
_commandsOverlay = null;
|
||||||
}
|
_mentionsOverlay?.remove();
|
||||||
if (_mentionsOverlay != null) {
|
_mentionsOverlay = null;
|
||||||
_mentionsOverlay.remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
textEditingController =
|
textEditingController =
|
||||||
widget.textEditingController ?? TextEditingController();
|
widget.textEditingController ?? TextEditingController();
|
||||||
|
|
||||||
|
textEditingController.addListener(_onChange);
|
||||||
|
|
||||||
if (widget.editMessage != null || widget.initialMessage != null) {
|
if (widget.editMessage != null || widget.initialMessage != null) {
|
||||||
_parseExistingMessage(widget.editMessage ?? widget.initialMessage);
|
_parseExistingMessage(widget.editMessage ?? widget.initialMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _onChange() {
|
||||||
|
final s = textEditingController.text;
|
||||||
|
StreamChannel.of(context).channel.keyStroke(
|
||||||
|
widget.parentMessage?.id,
|
||||||
|
);
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_messageIsPresent = s.trim().isNotEmpty;
|
||||||
|
});
|
||||||
|
|
||||||
|
_commandsOverlay?.remove();
|
||||||
|
_commandsOverlay = null;
|
||||||
|
_mentionsOverlay?.remove();
|
||||||
|
_mentionsOverlay = null;
|
||||||
|
|
||||||
|
if (s.trim().startsWith('/')) {
|
||||||
|
_commandsOverlay = _buildCommandsOverlayEntry();
|
||||||
|
Overlay.of(context).insert(_commandsOverlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_messageIsPresent &&
|
||||||
|
textEditingController.selection.isCollapsed &&
|
||||||
|
textEditingController.selection.baseOffset > 0 &&
|
||||||
|
textEditingController.text
|
||||||
|
.substring(0, textEditingController.selection.baseOffset)
|
||||||
|
.split(' ')
|
||||||
|
.last
|
||||||
|
.contains('@')) {
|
||||||
|
_mentionsOverlay = _buildMentionsOverlayEntry();
|
||||||
|
Overlay.of(context).insert(_mentionsOverlay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _parseExistingMessage(Message message) {
|
void _parseExistingMessage(Message message) {
|
||||||
textEditingController.text = message.text;
|
textEditingController.text = message.text;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
name: stream_chat_flutter
|
name: stream_chat_flutter
|
||||||
homepage: https://github.com/GetStream/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.
|
description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter.
|
||||||
version: 0.2.13
|
version: 0.2.13+1
|
||||||
repository: https://github.com/GetStream/stream-chat-flutter
|
repository: https://github.com/GetStream/stream-chat-flutter
|
||||||
issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues
|
issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user