diff --git a/lib/src/media_list_view.dart b/lib/src/media_list_view.dart index 5a2fc25f..627a480c 100644 --- a/lib/src/media_list_view.dart +++ b/lib/src/media_list_view.dart @@ -99,23 +99,9 @@ class _MediaListViewState extends State { @override void initState() { super.initState(); - - _scrollController.addListener(() { - if (_scrollController.offset > - _scrollController.position.maxScrollExtent - 100) { - _getMedia(); - } - }); - _getMedia(); } - @override - void dispose() { - _scrollController.dispose(); - super.dispose(); - } - void _getMedia() async { final List collections = await MediaGallery.listMediaCollections( @@ -154,8 +140,5 @@ class _MediaListViewState extends State { setState(() { _media.addAll(allItems); }); - - print( - '_media.where((element) => element.mediaType == MediaType.video).length: ${_media.where((element) => element.mediaType == MediaType.video).length}'); } } diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index 8014ed89..e4693244 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -171,7 +171,7 @@ class MessageInputState extends State { final _imagePicker = ImagePicker(); bool _inputEnabled = true; bool _messageIsPresent = false; - bool _typingStarted = false; + bool _animateContainer = true; bool _commandEnabled = false; OverlayEntry _commandsOverlay, _mentionsOverlay, _emojiOverlay; Iterable _emojiNames; @@ -383,11 +383,6 @@ class MessageInputState extends State { _checkEmoji(s, context); }, - onTap: () { - setState(() { - _typingStarted = true; - }); - }, style: Theme.of(context).textTheme.bodyText2, autofocus: false, textAlignVertical: TextAlignVertical.center, @@ -613,7 +608,7 @@ class MessageInputState extends State { Widget _buildFilePickerSection() { return AnimatedContainer( - duration: Duration(milliseconds: 300), + duration: _animateContainer ? Duration(milliseconds: 300) : Duration.zero, height: _openFilePickerSection ? _filePickerSize : 0, child: Material( color: Color(0xFFF2F2F2), @@ -662,13 +657,11 @@ class MessageInputState extends State { GestureDetector( onVerticalDragUpdate: (update) { setState(() { - _filePickerSize -= update.delta.dy; - if (_filePickerSize < 100) { - _filePickerSize = 100.0; - } else if (_filePickerSize > - MediaQuery.of(context).size.height / 1.7) { - _filePickerSize = MediaQuery.of(context).size.height / 1.7; - } + _animateContainer = false; + _filePickerSize = (_filePickerSize - update.delta.dy).clamp( + 100, + MediaQuery.of(context).size.height / 1.7, + ); }); }, child: Container( @@ -1206,6 +1199,7 @@ class MessageInputState extends State { if (_openFilePickerSection) { setState(() { + _animateContainer = true; _openFilePickerSection = false; _filePickerSize = 250.0; }); @@ -1536,7 +1530,6 @@ class MessageInputState extends State { setState(() { _messageIsPresent = false; - _typingStarted = false; _commandEnabled = false; }); @@ -1632,7 +1625,6 @@ class MessageInputState extends State { void _parseExistingMessage(Message message) { textEditingController.text = message.text; - _typingStarted = true; _messageIsPresent = true; message.attachments?.forEach((attachment) {