feat: wip message input
This commit is contained in:
+72
-66
@@ -230,60 +230,62 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
|
|
||||||
Expanded _buildTextInput(BuildContext context) {
|
Expanded _buildTextInput(BuildContext context) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: LimitedBox(
|
child: Center(
|
||||||
maxHeight: widget.maxHeight,
|
child: LimitedBox(
|
||||||
child: TextField(
|
maxHeight: widget.maxHeight,
|
||||||
key: Key('messageInputText'),
|
child: TextField(
|
||||||
enabled: _inputEnabled,
|
key: Key('messageInputText'),
|
||||||
minLines: null,
|
enabled: _inputEnabled,
|
||||||
maxLines: null,
|
minLines: null,
|
||||||
onSubmitted: (_) {
|
maxLines: null,
|
||||||
sendMessage();
|
onSubmitted: (_) {
|
||||||
},
|
sendMessage();
|
||||||
keyboardType: widget.keyboardType,
|
},
|
||||||
controller: textEditingController,
|
keyboardType: widget.keyboardType,
|
||||||
focusNode: _focusNode,
|
controller: textEditingController,
|
||||||
onChanged: (s) {
|
focusNode: _focusNode,
|
||||||
StreamChannel.of(context).channel.keyStroke();
|
onChanged: (s) {
|
||||||
|
StreamChannel.of(context).channel.keyStroke();
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_messageIsPresent = s.trim().isNotEmpty;
|
_messageIsPresent = s.trim().isNotEmpty;
|
||||||
});
|
});
|
||||||
|
|
||||||
_commandsOverlay?.remove();
|
_commandsOverlay?.remove();
|
||||||
_commandsOverlay = null;
|
_commandsOverlay = null;
|
||||||
_mentionsOverlay?.remove();
|
_mentionsOverlay?.remove();
|
||||||
_mentionsOverlay = null;
|
_mentionsOverlay = null;
|
||||||
|
|
||||||
if (s.startsWith('/')) {
|
if (s.startsWith('/')) {
|
||||||
_commandsOverlay = _buildCommandsOverlayEntry();
|
_commandsOverlay = _buildCommandsOverlayEntry();
|
||||||
Overlay.of(context).insert(_commandsOverlay);
|
Overlay.of(context).insert(_commandsOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textEditingController.selection.isCollapsed &&
|
if (textEditingController.selection.isCollapsed &&
|
||||||
(s[textEditingController.selection.start - 1] == '@' ||
|
(s[textEditingController.selection.start - 1] == '@' ||
|
||||||
textEditingController.text
|
textEditingController.text
|
||||||
.substring(0, textEditingController.selection.start)
|
.substring(0, textEditingController.selection.start)
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.last
|
.last
|
||||||
.contains('@'))) {
|
.contains('@'))) {
|
||||||
_mentionsOverlay = _buildMentionsOverlayEntry();
|
_mentionsOverlay = _buildMentionsOverlayEntry();
|
||||||
Overlay.of(context).insert(_mentionsOverlay);
|
Overlay.of(context).insert(_mentionsOverlay);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_typingStarted = true;
|
_typingStarted = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
style: Theme.of(context).textTheme.bodyText2,
|
style: Theme.of(context).textTheme.bodyText2,
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'Write a message',
|
hintText: 'Write a message',
|
||||||
prefixText: ' ',
|
prefixText: ' ',
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
textCapitalization: TextCapitalization.sentences,
|
||||||
),
|
),
|
||||||
textCapitalization: TextCapitalization.sentences,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -602,22 +604,24 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Material _buildAttachmentButton() {
|
Widget _buildAttachmentButton() {
|
||||||
return Material(
|
return Center(
|
||||||
clipBehavior: Clip.hardEdge,
|
child: Material(
|
||||||
shape: RoundedRectangleBorder(
|
clipBehavior: Clip.hardEdge,
|
||||||
borderRadius: BorderRadius.circular(32),
|
shape: RoundedRectangleBorder(
|
||||||
),
|
borderRadius: BorderRadius.circular(32),
|
||||||
color: Colors.transparent,
|
),
|
||||||
child: IconButton(
|
color: Colors.transparent,
|
||||||
onPressed: () {
|
child: IconButton(
|
||||||
showAttachmentModal();
|
onPressed: () {
|
||||||
},
|
showAttachmentModal();
|
||||||
icon: Transform.rotate(
|
},
|
||||||
child: Icon(
|
icon: Transform.rotate(
|
||||||
Icons.attach_file_sharp,
|
child: Icon(
|
||||||
|
Icons.attach_file_sharp,
|
||||||
|
),
|
||||||
|
angle: 0.4,
|
||||||
),
|
),
|
||||||
angle: 0.4,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -845,7 +849,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
child: Material(
|
child: Material(
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(24),
|
borderRadius: BorderRadius.circular(32),
|
||||||
),
|
),
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
@@ -856,6 +860,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.arrow_forward,
|
Icons.arrow_forward,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
size: 18.0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -874,7 +879,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
child: Material(
|
child: Material(
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(24),
|
borderRadius: BorderRadius.circular(32),
|
||||||
),
|
),
|
||||||
color: StreamChatTheme.of(context).accentColor,
|
color: StreamChatTheme.of(context).accentColor,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
@@ -885,6 +890,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.arrow_upward,
|
Icons.arrow_upward,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
size: 18.0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user