From 150a8b00a6b2ce759a72c44b404ee0fcee943a0e Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 18 Nov 2020 09:35:23 +0100 Subject: [PATCH 1/6] Update README.md update readme adding file picker troubleshooting link --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 7ca34145..ba5de4c1 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,11 @@ We also use [video_player](https://pub.dev/packages/video_player) to reproduce v To pick images from the camera, we use the [image_picker](https://pub.dev/packages/image_picker) plugin. Follow [these instructions](https://pub.dev/packages/image_picker#ios) to check the requirements. +### Troubleshooting + +It may happen that you have some problems building the app. +If it seems related to the [flutter file picker plugin](https://github.com/miguelpruivo/flutter_file_picker) make sure to check [this page](https://github.com/miguelpruivo/flutter_file_picker/wiki/Troubleshooting) + ## Docs ### Business logic components From a793c623b299880641756b28d9f74936c28f61ee Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 19 Nov 2020 10:58:10 +0100 Subject: [PATCH 2/6] use texteditingcontroller listener instead of onchanged --- lib/src/message_input.dart | 126 +++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 68 deletions(-) diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index 02fbbd8f..7ba3e4b9 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -77,25 +77,25 @@ enum DefaultAttachmentTypes { /// Modify it to change the widget appearance. class MessageInput extends StatefulWidget { /// Instantiate a new MessageInput - MessageInput( - {Key key, - this.onMessageSent, - this.preMessageSending, - this.parentMessage, - this.editMessage, - this.maxHeight = 150, - this.keyboardType = TextInputType.multiline, - this.disableAttachments = false, - this.doImageUploadRequest, - this.doFileUploadRequest, - this.initialMessage, - this.textEditingController, - this.actions, - this.actionsLocation = ActionsLocation.left, - this.attachmentThumbnailBuilders, - this.inputTextStyle, - this.attachmentIconColor}) - : super(key: key); + MessageInput({ + Key key, + this.onMessageSent, + this.preMessageSending, + this.parentMessage, + this.editMessage, + this.maxHeight = 150, + this.keyboardType = TextInputType.multiline, + this.disableAttachments = false, + this.doImageUploadRequest, + this.doFileUploadRequest, + this.initialMessage, + this.textEditingController, + this.actions, + this.actionsLocation = ActionsLocation.left, + this.attachmentThumbnailBuilders, + this.inputTextStyle, + this.attachmentIconColor, + }) : super(key: key); /// Message to edit final Message editMessage; @@ -252,36 +252,6 @@ class MessageInputState extends State { keyboardType: widget.keyboardType, controller: textEditingController, focusNode: _focusNode, - onChanged: (s) { - StreamChannel.of(context).channel.keyStroke( - widget.parentMessage?.id, - ); - - setState(() { - _messageIsPresent = s.trim().isNotEmpty; - }); - - _commandsOverlay?.remove(); - _commandsOverlay = null; - _mentionsOverlay?.remove(); - _mentionsOverlay = null; - - if (s.startsWith('/')) { - _commandsOverlay = _buildCommandsOverlayEntry(); - Overlay.of(context).insert(_commandsOverlay); - } - - if (textEditingController.selection.isCollapsed && - (s[textEditingController.selection.start - 1] == '@' || - textEditingController.text - .substring(0, textEditingController.selection.start) - .split(' ') - .last - .contains('@'))) { - _mentionsOverlay = _buildMentionsOverlayEntry(); - Overlay.of(context).insert(_mentionsOverlay); - } - }, onTap: () { setState(() { _typingStarted = true; @@ -403,7 +373,7 @@ class MessageInputState extends State { OverlayEntry _buildMentionsOverlayEntry() { final splits = textEditingController.text - .substring(0, textEditingController.value.selection.start) + .substring(0, textEditingController.value.selection.baseOffset) .split('@'); final query = splits.last.toLowerCase(); @@ -467,7 +437,7 @@ class MessageInputState extends State { text: rejoin + textEditingController.text.substring( textEditingController - .selection.start), + .selection.baseOffset), selection: TextSelection.collapsed( offset: rejoin.length, ), @@ -962,23 +932,7 @@ class MessageInputState extends State { if (!kIsWeb) { _keyboardListener = KeyboardVisibility.onChange.listen((visible) { if (visible) { - if (_commandsOverlay != null) { - if (textEditingController.text.startsWith('/')) { - WidgetsBinding.instance.addPostFrameCallback((_) { - _commandsOverlay = _buildCommandsOverlayEntry(); - Overlay.of(context).insert(_commandsOverlay); - }); - } - } - - if (_mentionsOverlay != null) { - if (textEditingController.text.contains('@')) { - WidgetsBinding.instance.addPostFrameCallback((_) { - _mentionsOverlay = _buildCommandsOverlayEntry(); - Overlay.of(context).insert(_mentionsOverlay); - }); - } - } + _onChange(); } else { if (_commandsOverlay != null) { _commandsOverlay.remove(); @@ -992,11 +946,47 @@ class MessageInputState extends State { textEditingController = widget.textEditingController ?? TextEditingController(); + + textEditingController.addListener(_onChange); + if (widget.editMessage != null || widget.initialMessage != null) { _parseExistingMessage(widget.editMessage ?? widget.initialMessage); } } + void _onChange() { + final s = textEditingController.text; + StreamChannel.of(context).channel.keyStroke( + widget.parentMessage?.id, + ); + + setState(() { + _messageIsPresent = s.trim().isNotEmpty; + }); + + _commandsOverlay?.remove(); + _commandsOverlay = null; + _mentionsOverlay?.remove(); + _mentionsOverlay = null; + + if (s.trim().startsWith('/')) { + _commandsOverlay = _buildCommandsOverlayEntry(); + Overlay.of(context).insert(_commandsOverlay); + } + + if (_messageIsPresent && + textEditingController.selection.isCollapsed && + textEditingController.selection.baseOffset > 0 && + textEditingController.text + .substring(0, textEditingController.selection.baseOffset) + .split(' ') + .last + .contains('@')) { + _mentionsOverlay = _buildMentionsOverlayEntry(); + Overlay.of(context).insert(_mentionsOverlay); + } + } + void _parseExistingMessage(Message message) { textEditingController.text = message.text; From 1c1cf66d9394cc32e1ee4b4243dddec30bcca1c7 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 19 Nov 2020 10:59:59 +0100 Subject: [PATCH 3/6] bump version --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 945199b9..675d40d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.13+1 + +- Use TextEditingController.addListener instea of TextField.onChanged + ## 0.2.13 - Update llc dependency diff --git a/pubspec.yaml b/pubspec.yaml index 00be2548..f667acfb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.13 +version: 0.2.13+1 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues From 6a8e76dc189d992a183065e3c1b9bb91f51f73d9 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 19 Nov 2020 11:00:25 +0100 Subject: [PATCH 4/6] fix typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 675d40d0..7d5b93f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.2.13+1 -- Use TextEditingController.addListener instea of TextField.onChanged +- Use TextEditingController.addListener instead of TextField.onChanged ## 0.2.13 From 199831a7ec7fa8fe383b47156e80f2da1e3eed33 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 19 Nov 2020 11:50:41 +0100 Subject: [PATCH 5/6] fix show overlay --- lib/src/message_input.dart | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index 7ba3e4b9..a4bfcd18 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -934,12 +934,10 @@ class MessageInputState extends State { if (visible) { _onChange(); } else { - if (_commandsOverlay != null) { - _commandsOverlay.remove(); - } - if (_mentionsOverlay != null) { - _mentionsOverlay.remove(); - } + _commandsOverlay?.remove(); + _commandsOverlay = null; + _mentionsOverlay?.remove(); + _mentionsOverlay = null; } }); } From 04da9a06b34aee886ebfb4decfe498732df9ed55 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 19 Nov 2020 11:58:30 +0100 Subject: [PATCH 6/6] update github action --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 373aa879..bb72c2f2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Flutter action - uses: subosito/flutter-action@v1.3.2 + uses: subosito/flutter-action@v1.4.0 with: channel: 'stable' - name: Get dependencies