From 98d1d0660b79a4dbc9b9fd24c123547222a9ae75 Mon Sep 17 00:00:00 2001 From: chenzhiz Date: Wed, 10 Sep 2025 16:24:54 +0800 Subject: [PATCH] function customdialog truncate test Signed-off-by: chenzhiz Change-Id: Ifbc27dee583e77d8633550397293144089cdcbe4 --- .../dialog/dialog_layout_algorithm.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.cpp index 6b24ea42fe6..34bf17ee910 100644 --- a/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/dialog/dialog_layout_algorithm.cpp @@ -1073,6 +1073,28 @@ OffsetF DialogLayoutAlgorithm::AdjustChildPosition( auto keyboardInsert = manager->GetKeyboardInset(); auto childBottom = childOffset.GetY() + childSize.Height() + embeddedDialogOffsetY_ + stackRootDialogOffsetY_; auto paddingBottom = static_cast(GetPaddingBottom()); + + const bool enabletruncate = true; + + // 如果dialog底部在安全区之下 + if(enabletruncate && childBottom > safeAreaInsets_.bottom_.start){ + auto limitPos = std::min(childOffset.GetY(), + static_cast(safeAreaInsets_.top_.Length() + AVOID_LIMIT_PADDING.ConvertToPx())); + childOffset.SetY(childOffset.GetY() - (childBottom - safeAreaInsets_.bottom_.start)); + + // 缩小逻辑 + if(childOffset.GetY() < limitPos){ + resizeFlag_ = true; + dialogChildSize_ = childSize; + if (limitPos - childOffset.GetY() > dialogChildSize_.Height()) { + dialogChildSize_.MinusHeight(dialogChildSize_.Height()); + } else { + dialogChildSize_.MinusHeight(limitPos - childOffset.GetY()); + } + childOffset.SetY(limitPos); + } + } + if (needAvoidKeyboard && keyboardInsert.Length() > 0 && childBottom > (keyboardInsert.start - paddingBottom)) { auto limitPos = std::min(childOffset.GetY(), static_cast(safeAreaInsets_.top_.Length() + AVOID_LIMIT_PADDING.ConvertToPx())); -- Gitee