fix: attachments ui
This commit is contained in:
+83
-79
@@ -189,7 +189,6 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
_buildAttachments(),
|
|
||||||
_buildTextField(context),
|
_buildTextField(context),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -258,89 +257,94 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
child: Center(
|
child: Center(
|
||||||
child: LimitedBox(
|
child: LimitedBox(
|
||||||
maxHeight: widget.maxHeight,
|
maxHeight: widget.maxHeight,
|
||||||
child: TextField(
|
child: Column(
|
||||||
key: Key('messageInputText'),
|
children: [
|
||||||
enabled: _inputEnabled,
|
_buildAttachments(),
|
||||||
minLines: null,
|
TextField(
|
||||||
maxLines: null,
|
key: Key('messageInputText'),
|
||||||
onSubmitted: (_) {
|
enabled: _inputEnabled,
|
||||||
sendMessage();
|
minLines: null,
|
||||||
},
|
maxLines: null,
|
||||||
keyboardType: widget.keyboardType,
|
onSubmitted: (_) {
|
||||||
controller: textEditingController,
|
sendMessage();
|
||||||
focusNode: _focusNode,
|
},
|
||||||
onChanged: (s) {
|
keyboardType: widget.keyboardType,
|
||||||
StreamChannel.of(context).channel.keyStroke();
|
controller: textEditingController,
|
||||||
|
focusNode: _focusNode,
|
||||||
|
onChanged: (s) {
|
||||||
|
StreamChannel.of(context).channel.keyStroke();
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_messageIsPresent = s.trim().isNotEmpty;
|
_messageIsPresent = s.trim().isNotEmpty;
|
||||||
_actionsShrunk = s.trim().isNotEmpty;
|
_actionsShrunk = 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,
|
||||||
textAlignVertical: TextAlignVertical.center,
|
textAlignVertical: TextAlignVertical.center,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'Write a message',
|
hintText: 'Write a message',
|
||||||
prefixText: _commandEnabled ? null : ' ',
|
prefixText: _commandEnabled ? null : ' ',
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(32),
|
borderRadius: BorderRadius.circular(32),
|
||||||
|
),
|
||||||
|
contentPadding: EdgeInsets.all(8),
|
||||||
|
prefixIcon: _commandEnabled
|
||||||
|
? Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||||
|
child: Chip(
|
||||||
|
backgroundColor: StreamChatTheme.of(context).accentColor,
|
||||||
|
label: Text(
|
||||||
|
_chosenCommand?.name ?? "",
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
avatar: Icon(
|
||||||
|
StreamIcons.lightning,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
suffixIcon: _commandEnabled
|
||||||
|
? IconButton(
|
||||||
|
icon: Icon(Icons.cancel_outlined),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_commandEnabled = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
textCapitalization: TextCapitalization.sentences,
|
||||||
),
|
),
|
||||||
contentPadding: EdgeInsets.all(8),
|
],
|
||||||
prefixIcon: _commandEnabled
|
|
||||||
? Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
|
||||||
child: Chip(
|
|
||||||
backgroundColor: StreamChatTheme.of(context).accentColor,
|
|
||||||
label: Text(
|
|
||||||
_chosenCommand?.name ?? "",
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
avatar: Icon(
|
|
||||||
StreamIcons.lightning,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
suffixIcon: _commandEnabled
|
|
||||||
? IconButton(
|
|
||||||
icon: Icon(Icons.cancel_outlined),
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
_commandEnabled = false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
textCapitalization: TextCapitalization.sentences,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user