!40600 修复:半模态实时刷新且多档位于最高档位时,内容区与半模态等大,上滑半模态面板,半模态位移不更新

Merge pull request !40600 from chenxiaoxue/cherry-pick-1723794912
This commit is contained in:
openharmony_ci 2024-08-21 02:35:15 +00:00 committed by Gitee
commit 45f02ec562
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 27 additions and 14 deletions

View File

@ -3171,7 +3171,6 @@ bool OverlayManager::RemoveModalInOverlay()
if (topModalNode->GetTag() == V2::SHEET_PAGE_TAG) {
auto sheetPattern = topModalNode->GetPattern<SheetPresentationPattern>();
CHECK_NULL_RETURN(sheetPattern, false);
sheetPattern->SetIsDirectionUp(false);
sheetPattern->SheetInteractiveDismiss(BindSheetDismissReason::BACK_PRESSED);
return true;
} else if (topModalNode->GetTag() == V2::MODAL_PAGE_TAG) {
@ -4069,7 +4068,6 @@ void OverlayManager::InitSheetMask(
if (sheetPattern->IsDragging()) {
return;
}
sheetPattern->SetIsDirectionUp(false);
sheetPattern->SheetInteractiveDismiss(BindSheetDismissReason::TOUCH_OUTSIDE);
});
auto maskNodeId = maskNode->GetId();

View File

@ -472,7 +472,7 @@ void SheetPresentationPattern::HandleDragUpdate(const GestureEvent& info)
auto height = height_ + sheetHeightUp_;
auto maxDetentSize = sheetDetentHeight_[detentSize - 1];
if (GreatNotEqual((height - currentOffset_), maxDetentSize)) {
if (LessNotEqual(mainDelta, 0)) {
if (LessNotEqual(mainDelta, 0) && GreatNotEqual(sheetMaxHeight_, 0.0f)) {
auto friction = CalculateFriction((height - currentOffset_) / sheetMaxHeight_);
mainDelta = mainDelta * friction;
}
@ -553,7 +553,6 @@ void SheetPresentationPattern::HandleDragEnd(float dragVelocity)
if (NearZero(downHeight)) {
SheetInteractiveDismiss(BindSheetDismissReason::SLIDE_DOWN, std::abs(dragVelocity));
} else {
isDirectionUp_ = false;
detentsIndex_ = detentsLowerPos;
ChangeSheetHeight(downHeight);
ChangeSheetPage(height);
@ -568,7 +567,6 @@ void SheetPresentationPattern::HandleDragEnd(float dragVelocity)
} else {
// when drag velocity is over the threshold
if (GreatOrEqual(dragVelocity, 0.0f)) {
isDirectionUp_ = false;
if (NearZero(downHeight)) {
SheetInteractiveDismiss(BindSheetDismissReason::SLIDE_DOWN, std::abs(dragVelocity));
} else {
@ -900,6 +898,7 @@ void SheetPresentationPattern::SheetTransition(bool isTransitionIn, float dragVe
void SheetPresentationPattern::SheetInteractiveDismiss(BindSheetDismissReason dismissReason, float dragVelocity)
{
isDirectionUp_ = false;
if (HasShouldDismiss() || HasOnWillDismiss()) {
const auto& overlayManager = GetOverlayManager();
CHECK_NULL_VOID(overlayManager);
@ -1550,6 +1549,7 @@ bool SheetPresentationPattern::IsFold()
void SheetPresentationPattern::ChangeSheetHeight(float height)
{
if (!NearEqual(height_, height)) {
isDirectionUp_ = GreatNotEqual(height, height_);
height_ = height;
SetCurrentHeightToOverlay(height_);
}
@ -2151,12 +2151,30 @@ ScrollResult SheetPresentationPattern::HandleScrollWithSheet(float scrollOffset)
isSheetNeedScroll_ = false;
return {scrollOffset, true};
}
auto currentHeightPos = height_ + sheetHeightUp_;
if ((NearZero(currentOffset_)) && (LessNotEqual(scrollOffset, 0.0f)) &&
(GreatOrEqual(currentHeightPos, sheetDetentHeight_[sheetDetentsSize - 1]))) {
bool isDraggingUp = LessNotEqual(scrollOffset, 0.0f);
bool isReachMaxSheetHeight = GreatOrEqual(currentHeightPos, sheetDetentHeight_[sheetDetentsSize - 1]);
// When dragging up the sheet, and sheet height is larger than sheet content height,
// the sheet height should be updated.
// When dragging up the sheet, and sheet height is less than or equal to sheet content height,
// the sheet content should scrolling.
if ((NearZero(currentOffset_)) && isDraggingUp && isReachMaxSheetHeight && IsScrollable()) {
isSheetNeedScroll_ = false;
return {scrollOffset, true};
}
// When dragging up the sheet, and sheet height is larger than max height,
// should set the coefficient of friction.
bool isExceedMaxSheetHeight =
GreatNotEqual((currentHeightPos - currentOffset_), sheetDetentHeight_[sheetDetentsSize - 1]);
bool isNeedCalculateFriction = isExceedMaxSheetHeight && isDraggingUp;
if (isNeedCalculateFriction && GreatNotEqual(sheetMaxHeight_, 0.0f)) {
auto friction = CalculateFriction((currentHeightPos - currentOffset_) / sheetMaxHeight_);
scrollOffset = scrollOffset * friction;
}
auto host = GetHost();
CHECK_NULL_RETURN(host, result);
currentOffset_ = currentOffset_ + scrollOffset;
@ -2166,13 +2184,16 @@ ScrollResult SheetPresentationPattern::HandleScrollWithSheet(float scrollOffset)
sheetOffsetInPage = pageHeight - sheetMaxHeight_;
currentOffset_ = currentHeightPos - sheetMaxHeight_;
}
bool isNeedChangeScrollHeight = scrollSizeMode_ == ScrollSizeMode::CONTINUOUS && scrollOffset < 0;
bool isNeedChangeScrollHeight = scrollSizeMode_ == ScrollSizeMode::CONTINUOUS && isDraggingUp;
if (isNeedChangeScrollHeight) {
ChangeScrollHeight(currentHeightPos - currentOffset_);
}
ProcessColumnRect(currentHeightPos - currentOffset_);
auto renderContext = host->GetRenderContext();
renderContext->UpdateTransformTranslate({ 0.0f, sheetOffsetInPage, 0.0f });
if (IsSheetBottomStyle()) {
OnHeightDidChange(height_ - currentOffset_ + sheetHeightUp_);
}
isSheetPosChanged_ = true;
return result;
}

View File

@ -326,11 +326,6 @@ public:
currentOffset_ = currentOffset;
}
void SetIsDirectionUp(bool isDirectionUp)
{
isDirectionUp_ = isDirectionUp;
}
void SetCurrentHeight(float currentHeight)
{
if (height_ != currentHeight) {

View File

@ -178,7 +178,6 @@ void SheetView::CreateCloseIconButtonNode(RefPtr<FrameNode> sheetNode, NG::Sheet
CHECK_NULL_VOID(sheet);
auto sheetPattern = sheet->GetPattern<SheetPresentationPattern>();
CHECK_NULL_VOID(sheetPattern);
sheetPattern->SetIsDirectionUp(false);
sheetPattern->SheetInteractiveDismiss(BindSheetDismissReason::CLOSE_BUTTON);
};
eventConfirmHub->AddClickEvent(AceType::MakeRefPtr<NG::ClickEvent>(clickCallback));