!35813 List输入法避让_多行文本要用光标行位置

Merge pull request !35813 from wind/br617
This commit is contained in:
openharmony_ci 2024-06-17 11:58:18 +00:00 committed by Gitee
commit 05a3ed157b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -34,6 +34,7 @@
#include "core/components_ng/pattern/list/list_layout_property.h"
#include "core/components_ng/pattern/list/list_pattern.h"
#include "core/components_ng/pattern/scrollable/scrollable_utils.h"
#include "core/components_ng/pattern/text/text_base.h"
#include "core/components_ng/pattern/text_field/text_field_manager.h"
#include "core/components_ng/property/layout_constraint.h"
#include "core/components_ng/property/measure_property.h"
@ -45,6 +46,10 @@
namespace OHOS::Ace::NG {
namespace {
constexpr Dimension RESERVE_BOTTOM_HEIGHT = 24.0_vp;
} // namespace
void ListLayoutAlgorithm::UpdateListItemConstraint(
Axis axis, const OptionalSizeF& selfIdealSize, LayoutConstraintF& contentConstraint)
{
@ -1416,9 +1421,11 @@ void ListLayoutAlgorithm::OnSurfaceChanged(LayoutWrapper* layoutWrapper)
CHECK_NULL_VOID(textField);
auto textFieldHost = textField->GetHost();
CHECK_NULL_VOID(textFieldHost);
auto position = textFieldHost->GetTransformRelativeOffset().GetY() + textField->GetHostFrameSize()->Height();
auto textBase = DynamicCast<TextBase>(textField);
CHECK_NULL_VOID(textBase);
auto caretPos = textFieldHost->GetTransformRelativeOffset().GetY() + textBase->GetCaretRect().Bottom();
auto globalOffset = host->GetTransformRelativeOffset();
auto offset = contentMainSize_ + globalOffset.GetY() - position;
auto offset = contentMainSize_ + globalOffset.GetY() - caretPos - RESERVE_BOTTOM_HEIGHT.ConvertToPx();
if (LessOrEqual(offset, 0.0)) {
// negative offset to scroll down
currentDelta_ -= static_cast<float>(offset);