TF-1033: apply auto scroll to identity , composer , vacation screen

This commit is contained in:
ManhNTX
2022-10-06 09:15:27 +07:00
committed by Dat H. Pham
parent 5ba76f802b
commit a7c1d002d3
7 changed files with 58 additions and 5 deletions
@@ -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,
);
}
}
@@ -680,7 +680,7 @@ class ComposerView extends GetWidget<ComposerController>
if(responsiveUtils.isMobile(context)){
controller.keyboardRichTextController.onCreateHTMLEditor(
editorApi,
scrollController: controller.scrollController,
onEnterKeyDown: controller.onEnterKeyDown,
);
} else {
richTextMobileTabletController.listenHtmlEditorApi();
@@ -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,
);
}
}
@@ -510,12 +510,13 @@ class IdentityCreatorView extends GetWidget<IdentityCreatorController> {
);
} 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;
},
@@ -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();
@@ -61,6 +61,7 @@ class VacationView extends GetWidget<VacationController> 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<VacationController> 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,
);
}
);
}
}
+1 -1
View File
@@ -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