From 64dc62dba3482044a85b3bf235af06abf4d8479c Mon Sep 17 00:00:00 2001 From: zmhu Date: Fri, 27 Oct 2023 12:46:20 +0800 Subject: [PATCH 1/3] fix: #33 do submit when scroll to bottom finished --- lib/components/desktop_main_right_component.dart | 12 ++++++------ lib/pages/chat_message_page.dart | 7 ++++--- macos/Podfile.lock | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/components/desktop_main_right_component.dart b/lib/components/desktop_main_right_component.dart index b608fa3..00620d3 100644 --- a/lib/components/desktop_main_right_component.dart +++ b/lib/components/desktop_main_right_component.dart @@ -72,8 +72,8 @@ class DeskTopMainRightComponent extends StatelessWidget { 20); } - void scrollToBottom() { - scrollController.animateTo( + Future scrollToBottom() { + return scrollController.animateTo( scrollController.position.minScrollExtent, duration: const Duration(milliseconds: 500), curve: Curves.linear, @@ -294,7 +294,8 @@ class QuestionInputComponent extends StatelessWidget { focusedBorder: InputBorder.none, filled: false, suffixIcon: IconButton( - onPressed: () { + onPressed: () async { + await scrollToBottom(); controller.submit(sid, onDone: () { chatListController.updateSessionLastEdit( chatListController.currentSession); @@ -304,7 +305,6 @@ class QuestionInputComponent extends StatelessWidget { chatListController.currentSession); chatListController.update(); }); - scrollToBottom(); }, icon: const Icon(Icons.send)), ), @@ -316,7 +316,8 @@ class QuestionInputComponent extends StatelessWidget { controller.inputQuestion = value; // controller.update(['inputQuestion']); }, - onSubmitted: (String value) { + onSubmitted: (String value) async { + await scrollToBottom(); controller.submit(sid, onDone: () { chatListController .updateSessionLastEdit(chatListController.currentSession); @@ -326,7 +327,6 @@ class QuestionInputComponent extends StatelessWidget { .updateSessionLastEdit(chatListController.currentSession); chatListController.update(); }); - scrollToBottom(); }, onTap: () { // diff --git a/lib/pages/chat_message_page.dart b/lib/pages/chat_message_page.dart index f734993..824cb21 100644 --- a/lib/pages/chat_message_page.dart +++ b/lib/pages/chat_message_page.dart @@ -30,8 +30,8 @@ class ChatMessagePage extends StatelessWidget { ChatListController chatListController = Get.find(); TextEditingController textEditingController = TextEditingController(); - void scrollToBottom() { - scrollController.animateTo(scrollController.position.maxScrollExtent, + scrollToBottom() { + return scrollController.animateTo(scrollController.position.maxScrollExtent, duration: const Duration(milliseconds: 500), curve: Curves.easeInOut); } @@ -108,8 +108,9 @@ class ChatMessagePage extends StatelessWidget { onChanged: (value) { controller.inputQuestion = value; }, - onSubmitted: (String value) { + onSubmitted: (String value) async { // onSubmit(); + await scrollToBottom(); controller.submit(sid ?? '', onDone: () { chatListController.updateSessionLastEdit( chatListController.currentSession); diff --git a/macos/Podfile.lock b/macos/Podfile.lock index fff328c..38ea8b6 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -50,4 +50,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 -COCOAPODS: 1.13.0 +COCOAPODS: 1.14.1 From 22de1b1b71449671aee564fabbc06953da7c3800 Mon Sep 17 00:00:00 2001 From: zmhu Date: Fri, 27 Oct 2023 13:07:22 +0800 Subject: [PATCH 2/3] fix: #32 fix keyborad layout on huawei phone with baidu input method --- lib/pages/chat_message_page.dart | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/pages/chat_message_page.dart b/lib/pages/chat_message_page.dart index 824cb21..a49d515 100644 --- a/lib/pages/chat_message_page.dart +++ b/lib/pages/chat_message_page.dart @@ -104,7 +104,27 @@ class ChatMessagePage extends StatelessWidget { minLines: 1, maxLines: 3, textInputAction: TextInputAction.go, - decoration: const InputDecoration(filled: false), + decoration: InputDecoration( + filled: false, + suffixIcon: IconButton( + onPressed: () async { + await scrollToBottom(); + controller.submit(sid ?? '', + onDone: () { + chatListController + .updateSessionLastEdit( + chatListController + .currentSession); + chatListController.update(); + }, onError: () { + chatListController + .updateSessionLastEdit( + chatListController + .currentSession); + chatListController.update(); + }); + }, + icon: const Icon(Icons.send))), onChanged: (value) { controller.inputQuestion = value; }, From 0909a9e5f63feb86231437abacfecb88cd0b85c3 Mon Sep 17 00:00:00 2001 From: zmhu Date: Fri, 27 Oct 2023 13:12:39 +0800 Subject: [PATCH 3/3] fix: mobile: fix scroll to bottom function --- lib/pages/chat_message_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/chat_message_page.dart b/lib/pages/chat_message_page.dart index a49d515..fb76cbb 100644 --- a/lib/pages/chat_message_page.dart +++ b/lib/pages/chat_message_page.dart @@ -31,7 +31,7 @@ class ChatMessagePage extends StatelessWidget { TextEditingController textEditingController = TextEditingController(); scrollToBottom() { - return scrollController.animateTo(scrollController.position.maxScrollExtent, + return scrollController.animateTo(scrollController.position.minScrollExtent, duration: const Duration(milliseconds: 500), curve: Curves.easeInOut); }