fix messageinput

This commit is contained in:
Salvatore Giordano
2020-11-18 18:06:27 +01:00
parent 6411afdee0
commit 6c4bcd2073
5 changed files with 98 additions and 79 deletions
+10 -10
View File
@@ -364,7 +364,10 @@ class MessageInputState extends State<MessageInput> {
controller: textEditingController,
focusNode: _focusNode,
onChanged: (s) {
StreamChannel.of(context).channel.keyStroke();
StreamChannel.of(context)
.channel
.keyStroke()
.catchError((e) {});
setState(() {
_messageIsPresent = s.trim().isNotEmpty;
@@ -479,7 +482,9 @@ class MessageInputState extends State<MessageInput> {
void _checkMentions(String s, BuildContext context) {
if (textEditingController.selection.isCollapsed &&
(s.isNotEmpty && s[textEditingController.selection.start - 1] == '@' ||
(s.isNotEmpty &&
textEditingController.selection.start > 0 &&
s[textEditingController.selection.start - 1] == '@' ||
textEditingController.text
.substring(0, textEditingController.selection.start)
.split(' ')
@@ -1569,14 +1574,9 @@ class MessageInputState extends State<MessageInput> {
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: InkWell(
onTap: () {
sendMessage();
},
child: Icon(
_getIdleSendIcon(),
color: Colors.grey,
),
child: Icon(
_getIdleSendIcon(),
color: Colors.grey,
)),
),
);
+3 -1
View File
@@ -12,12 +12,14 @@ class StreamChannel extends StatefulWidget {
Key key,
@required this.child,
@required this.channel,
this.showLoading = true,
}) : super(
key: key,
);
final Widget child;
final Channel channel;
final bool showLoading;
/// Use this method to get the current [StreamChannelState] instance
static StreamChannelState of(BuildContext context) {
@@ -155,7 +157,7 @@ class StreamChannelState extends State<StreamChannel> {
future: widget.channel.initialized,
initialData: widget.channel.state != null,
builder: (context, snapshot) {
if (!snapshot.hasData || !snapshot.data) {
if (widget.showLoading && (!snapshot.hasData || !snapshot.data)) {
return Container(
height: 30,
child: Center(