fix messageinput
This commit is contained in:
+19
-2
@@ -6,8 +6,8 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
import 'chips_input_text_field.dart';
|
|
||||||
|
|
||||||
|
import 'chips_input_text_field.dart';
|
||||||
import 'notifications_service.dart';
|
import 'notifications_service.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
@@ -422,9 +422,12 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
|||||||
|
|
||||||
bool _isSearchActive = false;
|
bool _isSearchActive = false;
|
||||||
|
|
||||||
|
Channel channel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
channel = StreamChat.of(context).client.channel('messaging');
|
||||||
_controller = TextEditingController()
|
_controller = TextEditingController()
|
||||||
..addListener(() {
|
..addListener(() {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -452,7 +455,10 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
|||||||
style: TextStyle(color: Colors.black),
|
style: TextStyle(color: Colors.black),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: UsersBloc(
|
body: StreamChannel(
|
||||||
|
showLoading: false,
|
||||||
|
channel: channel,
|
||||||
|
child: UsersBloc(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -518,10 +524,21 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
MessageInput(
|
MessageInput(
|
||||||
|
preMessageSending: (message) async {
|
||||||
|
channel.extraData = {
|
||||||
|
'members': [
|
||||||
|
..._selectedUsers.map((e) => e.id),
|
||||||
|
channel.client.state.user.id,
|
||||||
|
],
|
||||||
|
};
|
||||||
|
await channel.watch();
|
||||||
|
return message;
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: example
|
name: example
|
||||||
description: A new Flutter project.
|
description: A new Flutter project.
|
||||||
version: 1.0.59+61
|
version: 1.0.60+62
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.2.2 <3.0.0"
|
sdk: ">=2.2.2 <3.0.0"
|
||||||
|
|||||||
@@ -364,7 +364,10 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
controller: textEditingController,
|
controller: textEditingController,
|
||||||
focusNode: _focusNode,
|
focusNode: _focusNode,
|
||||||
onChanged: (s) {
|
onChanged: (s) {
|
||||||
StreamChannel.of(context).channel.keyStroke();
|
StreamChannel.of(context)
|
||||||
|
.channel
|
||||||
|
.keyStroke()
|
||||||
|
.catchError((e) {});
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_messageIsPresent = s.trim().isNotEmpty;
|
_messageIsPresent = s.trim().isNotEmpty;
|
||||||
@@ -479,7 +482,9 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
|
|
||||||
void _checkMentions(String s, BuildContext context) {
|
void _checkMentions(String s, BuildContext context) {
|
||||||
if (textEditingController.selection.isCollapsed &&
|
if (textEditingController.selection.isCollapsed &&
|
||||||
(s.isNotEmpty && s[textEditingController.selection.start - 1] == '@' ||
|
(s.isNotEmpty &&
|
||||||
|
textEditingController.selection.start > 0 &&
|
||||||
|
s[textEditingController.selection.start - 1] == '@' ||
|
||||||
textEditingController.text
|
textEditingController.text
|
||||||
.substring(0, textEditingController.selection.start)
|
.substring(0, textEditingController.selection.start)
|
||||||
.split(' ')
|
.split(' ')
|
||||||
@@ -1569,14 +1574,9 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: InkWell(
|
|
||||||
onTap: () {
|
|
||||||
sendMessage();
|
|
||||||
},
|
|
||||||
child: Icon(
|
child: Icon(
|
||||||
_getIdleSendIcon(),
|
_getIdleSendIcon(),
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
),
|
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ class StreamChannel extends StatefulWidget {
|
|||||||
Key key,
|
Key key,
|
||||||
@required this.child,
|
@required this.child,
|
||||||
@required this.channel,
|
@required this.channel,
|
||||||
|
this.showLoading = true,
|
||||||
}) : super(
|
}) : super(
|
||||||
key: key,
|
key: key,
|
||||||
);
|
);
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
final Channel channel;
|
final Channel channel;
|
||||||
|
final bool showLoading;
|
||||||
|
|
||||||
/// Use this method to get the current [StreamChannelState] instance
|
/// Use this method to get the current [StreamChannelState] instance
|
||||||
static StreamChannelState of(BuildContext context) {
|
static StreamChannelState of(BuildContext context) {
|
||||||
@@ -155,7 +157,7 @@ class StreamChannelState extends State<StreamChannel> {
|
|||||||
future: widget.channel.initialized,
|
future: widget.channel.initialized,
|
||||||
initialData: widget.channel.state != null,
|
initialData: widget.channel.state != null,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (!snapshot.hasData || !snapshot.data) {
|
if (widget.showLoading && (!snapshot.hasData || !snapshot.data)) {
|
||||||
return Container(
|
return Container(
|
||||||
height: 30,
|
height: 30,
|
||||||
child: Center(
|
child: Center(
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ dependencies:
|
|||||||
file_picker: ^2.0.12
|
file_picker: ^2.0.12
|
||||||
image_picker: ^0.6.7+2
|
image_picker: ^0.6.7+2
|
||||||
flutter_keyboard_visibility: ^3.3.0
|
flutter_keyboard_visibility: ^3.3.0
|
||||||
stream_chat: ^0.2.13
|
stream_chat: ^0.2.13+1
|
||||||
mime: ^0.9.6+3
|
mime: ^0.9.6+3
|
||||||
visibility_detector: ^0.1.5
|
visibility_detector: ^0.1.5
|
||||||
http_parser: ^3.1.4
|
http_parser: ^3.1.4
|
||||||
|
|||||||
Reference in New Issue
Block a user