From a7c1d002d35e3e9a28d34b3a5ac789a980cbd2c3 Mon Sep 17 00:00:00 2001 From: ManhNTX Date: Thu, 6 Oct 2022 09:15:27 +0700 Subject: [PATCH] TF-1033: apply auto scroll to identity , composer , vacation screen --- .../presentation/composer_controller.dart | 9 +++++++++ .../composer/presentation/composer_view.dart | 2 +- .../identity_creator_controller.dart | 17 +++++++++++++++++ .../presentation/identity_creator_view.dart | 5 +++-- .../vacation/vacation_controller.dart | 19 +++++++++++++++++++ .../presentation/vacation/vacation_view.dart | 9 ++++++++- pubspec.yaml | 2 +- 7 files changed, 58 insertions(+), 5 deletions(-) diff --git a/lib/features/composer/presentation/composer_controller.dart b/lib/features/composer/presentation/composer_controller.dart index 7a9bcedf5..391c67ba5 100644 --- a/lib/features/composer/presentation/composer_controller.dart +++ b/lib/features/composer/presentation/composer_controller.dart @@ -1365,4 +1365,13 @@ class ComposerController extends BaseController { FocusManager.instance.primaryFocus?.unfocus(); popBack(); } + + + void onEnterKeyDown() { + scrollController.animateTo( + keyboardRichTextController.currentLine * 20, + duration: const Duration(milliseconds: 300), + curve: Curves.linear, + ); + } } \ No newline at end of file diff --git a/lib/features/composer/presentation/composer_view.dart b/lib/features/composer/presentation/composer_view.dart index 1eca8a829..6502a0108 100644 --- a/lib/features/composer/presentation/composer_view.dart +++ b/lib/features/composer/presentation/composer_view.dart @@ -680,7 +680,7 @@ class ComposerView extends GetWidget if(responsiveUtils.isMobile(context)){ controller.keyboardRichTextController.onCreateHTMLEditor( editorApi, - scrollController: controller.scrollController, + onEnterKeyDown: controller.onEnterKeyDown, ); } else { richTextMobileTabletController.listenHtmlEditorApi(); diff --git a/lib/features/identity_creator/presentation/identity_creator_controller.dart b/lib/features/identity_creator/presentation/identity_creator_controller.dart index 608a9eeb8..4c65ed197 100644 --- a/lib/features/identity_creator/presentation/identity_creator_controller.dart +++ b/lib/features/identity_creator/presentation/identity_creator_controller.dart @@ -66,6 +66,7 @@ class IdentityCreatorController extends BaseController { String? _contentHtmlEditor; final ScrollController scrollController = ScrollController(); + double currentPositionYHTMLEditor = 250; void updateNameIdentity(BuildContext context, String? value) { _nameIdentity = value; @@ -403,4 +404,20 @@ class IdentityCreatorController extends BaseController { popBack(); } } + + void onFocusHTMLEditor() { + scrollController.animateTo( + currentPositionYHTMLEditor, + duration: const Duration(milliseconds: 300), + curve: Curves.linear, + ); + } + + void onEnterKeyDown() { + scrollController.animateTo( + currentPositionYHTMLEditor - keyboardRichTextController.currentLine * 20, + duration: const Duration(milliseconds: 300), + curve: Curves.linear, + ); + } } \ No newline at end of file diff --git a/lib/features/identity_creator/presentation/identity_creator_view.dart b/lib/features/identity_creator/presentation/identity_creator_view.dart index 0555d6dd3..177531917 100644 --- a/lib/features/identity_creator/presentation/identity_creator_view.dart +++ b/lib/features/identity_creator/presentation/identity_creator_view.dart @@ -510,12 +510,13 @@ class IdentityCreatorView extends GetWidget { ); } else { return html_editor_mobile.HtmlEditor( - key: const Key('signature_html_editor_mobile'), + key:const Key('html_editor_mobile'), minHeight: 230, onCreated: (htmlEditorController) { controller.keyboardRichTextController.onCreateHTMLEditor( htmlEditorController, - scrollController:controller.scrollController, + onFocus: controller.onFocusHTMLEditor, + onEnterKeyDown: controller.onEnterKeyDown, ); controller.signatureHtmlEditorMobileController = htmlEditorController; }, diff --git a/lib/features/manage_account/presentation/vacation/vacation_controller.dart b/lib/features/manage_account/presentation/vacation/vacation_controller.dart index 4a1e6c3e2..19682f089 100644 --- a/lib/features/manage_account/presentation/vacation/vacation_controller.dart +++ b/lib/features/manage_account/presentation/vacation/vacation_controller.dart @@ -50,6 +50,9 @@ class VacationController extends BaseController { late Worker vacationWorker; + final ScrollController scrollController = ScrollController(); + double currentPositionYHTMLEditor = 660; + VacationController( this._getAllVacationInteractor, this._updateVacationInteractor, @@ -358,6 +361,22 @@ class VacationController extends BaseController { _settingController.backToUniversalSettings(); } + void onFocusHTMLEditor() { + scrollController.animateTo( + currentPositionYHTMLEditor, + duration: const Duration(milliseconds: 300), + curve: Curves.linear, + ); + } + + void onEnterKeyDown() { + scrollController.animateTo( + currentPositionYHTMLEditor + richTextControllerForMobile.currentLine * 20, + duration: const Duration(milliseconds: 300), + curve: Curves.linear, + ); + } + @override void onClose() { messageTextController.dispose(); diff --git a/lib/features/manage_account/presentation/vacation/vacation_view.dart b/lib/features/manage_account/presentation/vacation/vacation_view.dart index c4663e211..c2b2eb22c 100644 --- a/lib/features/manage_account/presentation/vacation/vacation_view.dart +++ b/lib/features/manage_account/presentation/vacation/vacation_view.dart @@ -61,6 +61,7 @@ class VacationView extends GetWidget with RichTextButtonMixi : null, padding: SettingsUtils.getMarginViewForSettingDetails(context, _responsiveUtils), child: SingleChildScrollView( + controller: controller.scrollController, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -472,7 +473,13 @@ class VacationView extends GetWidget with RichTextButtonMixi minHeight: 150, addDefaultSelectionMenuItems: false, initialContent: controller.vacationMessageHtmlText ?? '', - onCreated: controller.richTextControllerForMobile.onCreateHTMLEditor + onCreated: (htmlApi) { + controller.richTextControllerForMobile.onCreateHTMLEditor( + htmlApi, + onFocus: controller.onFocusHTMLEditor, + onEnterKeyDown: controller.onEnterKeyDown, + ); + } ); } } diff --git a/pubspec.yaml b/pubspec.yaml index 7469ac08b..397ef7387 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -45,7 +45,7 @@ dependencies: rich_text_composer: git: url: https://github.com/linagora/rich-text-composer.git - ref: apply_rich_text_bottom_sheet + ref: master # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2