TF-2671 Fix scroll jumping when typing on composer

(cherry picked from commit 2ab217d8b6193f61dfde0451ed49486cf51d664b)
This commit is contained in:
DatDang
2024-03-26 15:42:30 +07:00
committed by Dat H. Pham
parent 3fefd1929e
commit b636422d37
4 changed files with 9 additions and 7 deletions
@@ -1651,7 +1651,7 @@ class ComposerController extends BaseController with DragDropFileMixin {
if (coordinates?[1] != null && coordinates?[1] != 0) {
final coordinateY = max((coordinates?[1] ?? 0) - defaultPaddingCoordinateYCursorEditor, 0);
final realCoordinateY = coordinateY + (headerEditorMobileSize?.height ?? 0);
final outsideHeight = Get.height - ComposerStyle.keyboardMaxHeight - ComposerStyle.keyboardToolBarHeight;
final outsideHeight = Get.height - MediaQuery.viewInsetsOf(context).bottom - ComposerStyle.keyboardToolBarHeight;
final webViewEditorClientY = max(outsideHeight, 0) + scrollController.position.pixels;
if (scrollController.position.pixels >= realCoordinateY) {
_scrollToCursorEditor(
@@ -1675,9 +1675,12 @@ class ComposerController extends BaseController with DragDropFileMixin {
double headerEditorMobileHeight,
BuildContext context,
) {
scrollController.jumpTo(
realCoordinateY - (responsiveUtils.isLandscapeMobile(context) ? 0 : headerEditorMobileHeight / 2),
);
final scrollTarget = realCoordinateY -
(responsiveUtils.isLandscapeMobile(context)
? 0
: headerEditorMobileHeight / 2);
final maxScrollExtend = scrollController.position.maxScrollExtent;
scrollController.jumpTo(min(scrollTarget, maxScrollExtend));
}
void _onEnterKeyDown() {
@@ -217,7 +217,7 @@ class ComposerView extends GetWidget<ComposerController> {
onLoadCompletedEditorAction: controller.onLoadCompletedMobileEditorAction,
),
)),
const SizedBox(height: ComposerStyle.keyboardMaxHeight),
SizedBox(height: MediaQuery.viewInsetsOf(context).bottom),
],
),
),
@@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
class ComposerStyle {
static const double radius = 28;
static const double keyboardMaxHeight = 500;
static const double keyboardToolBarHeight = 200;
static const double popupMenuRadius = 8;
+1 -1
View File
@@ -429,7 +429,7 @@ packages:
description:
path: "."
ref: cnb_supported
resolved-ref: "669cfd989498cf398c88a6618eebb089967b9e28"
resolved-ref: "69996e32a708a62b8a613f2524c5635f5c556617"
url: "https://github.com/linagora/enough_html_editor.git"
source: git
version: "0.0.5"