Merge pull request #488 from GetStream/hotfix/messageInput

fix: message input
This commit is contained in:
Salvatore Giordano
2021-06-21 14:36:05 +02:00
committed by GitHub
2 changed files with 44 additions and 50 deletions
@@ -625,48 +625,51 @@ class _MessageActionsModalState extends State<MessageActionsModal> {
topRight: Radius.circular(16), topRight: Radius.circular(16),
), ),
), ),
builder: (context) => StreamChannel( builder: (context) => Padding(
channel: channel, padding: MediaQuery.of(context).viewInsets,
child: Flex( child: StreamChannel(
direction: Axis.vertical, channel: channel,
mainAxisAlignment: MainAxisAlignment.end, child: Flex(
mainAxisSize: MainAxisSize.min, direction: Axis.vertical,
children: <Widget>[ mainAxisAlignment: MainAxisAlignment.end,
Padding( mainAxisSize: MainAxisSize.min,
padding: const EdgeInsets.fromLTRB(8, 8, 8, 0), children: <Widget>[
child: Row( Padding(
mainAxisAlignment: MainAxisAlignment.spaceBetween, padding: const EdgeInsets.fromLTRB(8, 8, 8, 0),
children: <Widget>[ child: Row(
Padding( mainAxisAlignment: MainAxisAlignment.spaceBetween,
padding: const EdgeInsets.all(8), children: <Widget>[
child: StreamSvgIcon.edit( Padding(
color: streamChatThemeData.colorTheme.greyGainsboro, padding: const EdgeInsets.all(8),
child: StreamSvgIcon.edit(
color: streamChatThemeData.colorTheme.greyGainsboro,
),
), ),
), const Text(
const Text( 'Edit Message',
'Edit Message', style: TextStyle(fontWeight: FontWeight.bold),
style: TextStyle(fontWeight: FontWeight.bold), ),
), IconButton(
IconButton( visualDensity: VisualDensity.compact,
visualDensity: VisualDensity.compact, icon: StreamSvgIcon.closeSmall(),
icon: StreamSvgIcon.closeSmall(), onPressed: Navigator.of(context).pop,
onPressed: Navigator.of(context).pop, ),
), ],
], ),
), ),
), if (widget.editMessageInputBuilder != null)
if (widget.editMessageInputBuilder != null) widget.editMessageInputBuilder!(context, widget.message)
widget.editMessageInputBuilder!(context, widget.message) else
else MessageInput(
MessageInput( editMessage: widget.message,
editMessage: widget.message, preMessageSending: (m) {
preMessageSending: (m) { FocusScope.of(context).unfocus();
FocusScope.of(context).unfocus(); Navigator.pop(context);
Navigator.pop(context); return m;
return m; },
}, ),
), ],
], ),
), ),
), ),
); );
@@ -251,7 +251,6 @@ class MessageInputState extends State<MessageInput> {
late final FocusNode _focusNode; late final FocusNode _focusNode;
bool _inputEnabled = true; bool _inputEnabled = true;
bool _messageIsPresent = false; bool _messageIsPresent = false;
bool _animateContainer = true;
bool _commandEnabled = false; bool _commandEnabled = false;
OverlayEntry? _commandsOverlay, _mentionsOverlay, _emojiOverlay; OverlayEntry? _commandsOverlay, _mentionsOverlay, _emojiOverlay;
late Iterable<String> _emojiNames; late Iterable<String> _emojiNames;
@@ -939,10 +938,6 @@ class MessageInputState extends State<MessageInput> {
} }
Widget _buildFilePickerSection() { Widget _buildFilePickerSection() {
if (!_openFilePickerSection) {
return const Offstage();
}
final _attachmentContainsFile = final _attachmentContainsFile =
_attachments.values.any((it) => it.type == 'file'); _attachments.values.any((it) => it.type == 'file');
@@ -975,8 +970,7 @@ class MessageInputState extends State<MessageInput> {
} }
return AnimatedContainer( return AnimatedContainer(
duration: duration: const Duration(milliseconds: 300),
_animateContainer ? const Duration(milliseconds: 300) : Duration.zero,
height: _openFilePickerSection ? _filePickerSize : 0, height: _openFilePickerSection ? _filePickerSize : 0,
child: Material( child: Material(
color: _streamChatTheme.colorTheme.whiteSmoke, color: _streamChatTheme.colorTheme.whiteSmoke,
@@ -1034,7 +1028,6 @@ class MessageInputState extends State<MessageInput> {
GestureDetector( GestureDetector(
onVerticalDragUpdate: (update) { onVerticalDragUpdate: (update) {
setState(() { setState(() {
_animateContainer = false;
_filePickerSize = (_filePickerSize - update.delta.dy).clamp( _filePickerSize = (_filePickerSize - update.delta.dy).clamp(
_kMinMediaPickerSize, _kMinMediaPickerSize,
MediaQuery.of(context).size.height / 1.7, MediaQuery.of(context).size.height / 1.7,
@@ -1672,7 +1665,6 @@ class MessageInputState extends State<MessageInput> {
onPressed: () async { onPressed: () async {
if (_openFilePickerSection) { if (_openFilePickerSection) {
setState(() { setState(() {
_animateContainer = false;
_openFilePickerSection = false; _openFilePickerSection = false;
_filePickerSize = _kMinMediaPickerSize; _filePickerSize = _kMinMediaPickerSize;
}); });
@@ -1718,7 +1710,6 @@ class MessageInputState extends State<MessageInput> {
if (_openFilePickerSection) { if (_openFilePickerSection) {
setState(() { setState(() {
_animateContainer = true;
_openFilePickerSection = false; _openFilePickerSection = false;
_filePickerSize = _kMinMediaPickerSize; _filePickerSize = _kMinMediaPickerSize;
}); });