fix: attachments ui

This commit is contained in:
Deven Joshi
2020-10-26 15:46:47 +05:30
parent b93b7fd853
commit 5095b8e3c3
+89 -84
View File
@@ -252,95 +252,100 @@ class MessageInputState extends State<MessageInput> {
child: Center( child: Center(
child: LimitedBox( child: LimitedBox(
maxHeight: widget.maxHeight, maxHeight: widget.maxHeight,
child: Column( child: Container(
mainAxisSize: MainAxisSize.min, decoration: BoxDecoration(
children: [ borderRadius: BorderRadius.circular(8.0),
_buildAttachments(), ),
TextField( child: Column(
key: Key('messageInputText'), mainAxisSize: MainAxisSize.min,
enabled: _inputEnabled, children: [
minLines: null, _buildAttachments(),
maxLines: null, TextField(
onSubmitted: (_) { key: Key('messageInputText'),
sendMessage(); enabled: _inputEnabled,
}, minLines: null,
keyboardType: widget.keyboardType, maxLines: null,
controller: textEditingController, onSubmitted: (_) {
focusNode: _focusNode, sendMessage();
onChanged: (s) { },
StreamChannel.of(context).channel.keyStroke(); keyboardType: widget.keyboardType,
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), contentPadding: EdgeInsets.all(8),
prefixIcon: _commandEnabled prefixIcon: _commandEnabled
? Padding( ? Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0), padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Chip( child: Chip(
backgroundColor: StreamChatTheme.of(context).accentColor, backgroundColor: StreamChatTheme.of(context).accentColor,
label: Text( label: Text(
_chosenCommand?.name ?? "", _chosenCommand?.name ?? "",
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
),
avatar: Icon(
StreamIcons.lightning,
color: Colors.white,
),
), ),
avatar: Icon(
StreamIcons.lightning,
color: Colors.white,
),
),
)
: null,
suffixIcon: _commandEnabled
? IconButton(
icon: Icon(Icons.cancel_outlined),
onPressed: () {
setState(() {
_commandEnabled = false;
});
},
) )
: null, : null,
suffixIcon: _commandEnabled
? IconButton(
icon: Icon(Icons.cancel_outlined),
onPressed: () {
setState(() {
_commandEnabled = false;
});
},
)
: null,
),
textCapitalization: TextCapitalization.sentences,
), ),
textCapitalization: TextCapitalization.sentences, ],
), ),
],
), ),
), ),
), ),
@@ -592,8 +597,8 @@ class MessageInputState extends State<MessageInput> {
} }
Widget _buildAttachments() { Widget _buildAttachments() {
return ListView( return Wrap(
scrollDirection: Axis.horizontal, direction: Axis.horizontal,
children: _attachments children: _attachments
.map( .map(
(attachment) => Padding( (attachment) => Padding(