1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OVERLAY_SHEET_PRESENTATION_PATTERN_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OVERLAY_SHEET_PRESENTATION_PATTERN_H
18 
19 #include <functional>
20 #include <utility>
21 
22 #include "base/memory/ace_type.h"
23 #include "base/memory/referenced.h"
24 #include "core/common/autofill/auto_fill_trigger_state_holder.h"
25 #include "core/components/common/properties/alignment.h"
26 #include "core/components_ng/manager/focus/focus_view.h"
27 #include "core/components_ng/pattern/linear_layout/linear_layout_algorithm.h"
28 #include "core/components_ng/pattern/linear_layout/linear_layout_pattern.h"
29 #include "core/components_ng/pattern/linear_layout/linear_layout_property.h"
30 #include "core/components_ng/pattern/overlay/popup_base_pattern.h"
31 #include "core/components_ng/pattern/overlay/sheet_presentation_layout_algorithm.h"
32 #include "core/components_ng/pattern/overlay/sheet_presentation_property.h"
33 #include "core/components_ng/pattern/overlay/sheet_style.h"
34 #include "core/components_ng/pattern/scrollable/nestable_scroll_container.h"
35 #include "core/pipeline_ng/pipeline_context.h"
36 
37 namespace OHOS::Ace::NG {
38 
39 enum class BindSheetDismissReason {
40     BACK_PRESSED = 0,
41     TOUCH_OUTSIDE,
42     CLOSE_BUTTON,
43     SLIDE_DOWN,
44 };
45 class ACE_EXPORT SheetPresentationPattern :
46     public LinearLayoutPattern, public PopupBasePattern, public FocusView,
47         public NestableScrollContainer, public AutoFillTriggerStateHolder{
48     DECLARE_ACE_TYPE(SheetPresentationPattern,
49         LinearLayoutPattern, PopupBasePattern, FocusView, NestableScrollContainer, AutoFillTriggerStateHolder);
50 
51 public:
SheetPresentationPattern(int32_t targetId,const std::string & targetTag,std::function<void (const std::string &)> && callback)52     SheetPresentationPattern(
53         int32_t targetId, const std::string& targetTag, std::function<void(const std::string&)>&& callback)
54         : LinearLayoutPattern(true)
55     {
56         targetId_ = targetId;
57         targetTag_ = targetTag;
58         callback_ = std::move(callback);
59     }
60 
61     ~SheetPresentationPattern() override = default;
62 
IsMeasureBoundary()63     bool IsMeasureBoundary() const override
64     {
65         return true;
66     }
67 
SetOverlay(const WeakPtr<OverlayManager> & overlayManager)68     void SetOverlay(const WeakPtr<OverlayManager>& overlayManager)
69     {
70         overlayManager_ = overlayManager;
71     }
72 
IsAtomicNode()73     bool IsAtomicNode() const override
74     {
75         return false;
76     }
77 
CreateLayoutAlgorithm()78     RefPtr<LayoutAlgorithm> CreateLayoutAlgorithm() override
79     {
80         return MakeRefPtr<SheetPresentationLayoutAlgorithm>(targetId_, targetTag_, GetSheetType());
81     }
82 
CreateLayoutProperty()83     RefPtr<LayoutProperty> CreateLayoutProperty() override
84     {
85         return MakeRefPtr<SheetPresentationProperty>();
86     }
87 
GetTargetId()88     int32_t GetTargetId() const override
89     {
90         return targetId_;
91     }
92 
GetTargetTag()93     const std::string& GetTargetTag() const
94     {
95         return targetTag_;
96     }
97 
FireCallback(const std::string & value)98     void FireCallback(const std::string& value)
99     {
100         if (callback_) {
101             callback_(value);
102         }
103     }
104 
UpdateShouldDismiss(std::function<void ()> && shouldDismiss)105     void UpdateShouldDismiss(std::function<void()>&& shouldDismiss)
106     {
107         shouldDismiss_ = std::move(shouldDismiss);
108     }
109 
HasShouldDismiss()110     bool HasShouldDismiss()
111     {
112         if (shouldDismiss_) {
113             return true;
114         }
115         return false;
116     }
117 
CallShouldDismiss()118     void CallShouldDismiss()
119     {
120         if (shouldDismiss_) {
121             shouldDismiss_();
122         }
123     }
124 
UpdateOnDisappear(std::function<void ()> && onDisappear)125     void UpdateOnDisappear(std::function<void()>&& onDisappear)
126     {
127         onDisappear_ = std::move(onDisappear);
128         isExecuteOnDisappear_ = false;
129     }
130 
OnDisappear()131     void OnDisappear()
132     {
133         if (onDisappear_) {
134             TAG_LOGI(AceLogTag::ACE_SHEET, "bindsheet lifecycle change to onDisappear state.");
135             isExecuteOnDisappear_ = true;
136             onDisappear_();
137         }
138         isDismissProcess_ = false;
139     }
140 
UpdateOnWillDisappear(std::function<void ()> && onWillDisappear)141     void UpdateOnWillDisappear(std::function<void()>&& onWillDisappear)
142     {
143         onWillDisappear_ = std::move(onWillDisappear);
144     }
145 
OnWillDisappear()146     void OnWillDisappear()
147     {
148         if (onWillDisappear_) {
149             TAG_LOGI(AceLogTag::ACE_SHEET, "bindsheet lifecycle change to onWillDisappear state.");
150             onWillDisappear_();
151         }
152     }
153 
UpdateOnAppear(std::function<void ()> && onAppear)154     void UpdateOnAppear(std::function<void()>&& onAppear)
155     {
156         onAppear_ = std::move(onAppear);
157     }
158 
OnAppear()159     void OnAppear()
160     {
161         if (onAppear_) {
162             TAG_LOGI(AceLogTag::ACE_SHEET, "bindsheet lifecycle change to onAppear state.");
163             onAppear_();
164         }
165     }
166 
UpdateOnHeightDidChange(std::function<void (const float)> && onHeightDidChange)167     void UpdateOnHeightDidChange(std::function<void(const float)>&& onHeightDidChange)
168     {
169         onHeightDidChange_ = std::move(onHeightDidChange);
170     }
171 
OnHeightDidChange(float currentHeight)172     void OnHeightDidChange(float currentHeight) const
173     {
174         if (onHeightDidChange_) {
175             onHeightDidChange_(currentHeight);
176         }
177     }
178 
179     void FireOnHeightDidChange(float height);
180 
HasOnHeightDidChange()181     bool HasOnHeightDidChange()
182     {
183         if (onHeightDidChange_) {
184             return true;
185         }
186         return false;
187     }
188 
UpdateOnDetentsDidChange(std::function<void (const float)> && onDetentsDidChange)189     void UpdateOnDetentsDidChange(std::function<void(const float)>&& onDetentsDidChange)
190     {
191         onDetentsDidChange_ = std::move(onDetentsDidChange);
192     }
193 
OnDetentsDidChange(float currentHeight)194     void OnDetentsDidChange(float currentHeight) const
195     {
196         if (onDetentsDidChange_) {
197             onDetentsDidChange_(currentHeight);
198         }
199     }
200 
201     void FireOnDetentsDidChange(float height);
202 
UpdateOnWidthDidChange(std::function<void (const float)> && onWidthDidChange)203     void UpdateOnWidthDidChange(std::function<void(const float)>&& onWidthDidChange)
204     {
205         onWidthDidChange_ = std::move(onWidthDidChange);
206     }
207 
onWidthDidChange(float currentWidth)208     void onWidthDidChange(float currentWidth) const
209     {
210         if (onWidthDidChange_) {
211             onWidthDidChange_(currentWidth);
212         }
213     }
214 
215     void FireOnWidthDidChange(RefPtr<FrameNode> sheetNode);
216 
UpdateOnTypeDidChange(std::function<void (const float)> && onTypeDidChange)217     void UpdateOnTypeDidChange(std::function<void(const float)>&& onTypeDidChange)
218     {
219         onTypeDidChange_ = std::move(onTypeDidChange);
220     }
221 
onTypeDidChange(float currentType)222     void onTypeDidChange(float currentType) const
223     {
224         if (onTypeDidChange_) {
225             onTypeDidChange_(currentType);
226         }
227     }
228 
229     void FireOnTypeDidChange();
230 
UpdateOnWillDismiss(std::function<void (const int32_t)> && onWillDismiss)231     void UpdateOnWillDismiss(std::function<void(const int32_t)>&& onWillDismiss)
232     {
233         onWillDismiss_ = std::move(onWillDismiss);
234     }
235 
HasOnWillDismiss()236     bool HasOnWillDismiss() const
237     {
238         if (onWillDismiss_) {
239             return true;
240         }
241         return false;
242     }
243 
CallOnWillDismiss(const int32_t reason)244     void CallOnWillDismiss(const int32_t reason)
245     {
246         if (onWillDismiss_) {
247             onWillDismiss_(reason);
248         }
249     }
250 
UpdateSheetSpringBack(std::function<void ()> && sheetSpringBack)251     void UpdateSheetSpringBack(std::function<void()>&& sheetSpringBack)
252     {
253         sheetSpringBack_ = std::move(sheetSpringBack);
254     }
255 
HasSheetSpringBack()256     bool HasSheetSpringBack() const
257     {
258         if (sheetSpringBack_) {
259             return true;
260         }
261         return false;
262     }
263 
CallSheetSpringBack()264     void CallSheetSpringBack()
265     {
266         if (sheetSpringBack_) {
267             sheetSpringBack_();
268         }
269     }
270 
271     void OverlaySheetSpringBack();
272     void OverlayDismissSheet();
DismissSheet()273     void DismissSheet()
274     {
275         DismissTransition(false);
276     }
277 
SheetSpringBack()278     void SheetSpringBack()
279     {
280         isDismissProcess_ = false;
281         SheetTransition(true);
282     }
283 
284     void InitialLayoutProps();
285 
286     bool IsScrollable() const;
287     void AvoidAiBar();
288 
289     void AvoidSafeArea(bool forceAvoid = false);
290     void CheckBuilderChange();
291     float GetSheetHeightChange();
292     void ScrollTo(float height);
293     bool AdditionalScrollTo(const RefPtr<FrameNode>& scroll, float height);
294     float InitialSingleGearHeight(NG::SheetStyle& sheetStyle);
295     float GetSheetTopSafeArea();
296     float UpdateSheetTransitionOffset();
297 
298     // initial drag gesture event
299     void InitPanEvent();
300 
301     void HandleDragStart();
302 
303     void HandleDragUpdate(const GestureEvent& info);
304 
305     void HandleDragEnd(float dragVelocity);
306 
307     void OnCoordScrollStart();
308 
309     bool OnCoordScrollUpdate(float scrollOffset);
310 
311     void OnCoordScrollEnd(float dragVelocity);
312 
313     void SheetTransition(bool isTransitionIn, float dragVelocity = 0.0f);
314 
315     void ModifyFireSheetTransition(float dragVelocity = 0.0f);
316 
317     void SheetInteractiveDismiss(BindSheetDismissReason dismissReason, float dragVelocity = 0.0f);
318 
319     void SetSheetBorderWidth(bool isPartialUpdate = false);
320 
SetCurrentOffset(float currentOffset)321     void SetCurrentOffset(float currentOffset)
322     {
323         currentOffset_ = currentOffset;
324     }
325 
SetCurrentHeight(float currentHeight)326     void SetCurrentHeight(float currentHeight)
327     {
328         if (height_ != currentHeight) {
329             height_ = currentHeight;
330             ChangeScrollHeight(height_);
331         }
332         ProcessColumnRect(height_);
333     }
334 
SetCurrentHeightToOverlay(float height)335     void SetCurrentHeightToOverlay(float height)
336     {
337         auto overlayManager = GetOverlayManager();
338         CHECK_NULL_VOID(overlayManager);
339         overlayManager->SetSheetHeight(height);
340     }
341 
342     void ChangeScrollHeight(float height);
343 
GetFocusPattern()344     FocusPattern GetFocusPattern() const override
345     {
346         return { FocusType::SCOPE, true };
347     }
348 
GetRouteOfFirstScope()349     std::list<int32_t> GetRouteOfFirstScope() override
350     {
351         return { 1, 0 };
352     }
353 
IsExecuteOnDisappear()354     bool IsExecuteOnDisappear() const
355     {
356         return isExecuteOnDisappear_;
357     }
358 
AvoidKeyboard()359     bool AvoidKeyboard() const override
360     {
361         return false;
362     }
363 
364     bool IsWindowSizeChangedWithUndefinedReason(int32_t width, int32_t height, WindowSizeChangeReason type);
365 
366     void OnWindowSizeChanged(int32_t width, int32_t height, WindowSizeChangeReason type) override;
367 
HasTitleNode()368     bool HasTitleNode() const
369     {
370         return titleId_.has_value();
371     }
372 
SetTitleId(const int32_t id)373     bool SetTitleId(const int32_t id)
374     {
375         if (HasTitleNode()) {
376             return false;
377         }
378         titleId_ = id;
379         return true;
380     }
381 
GetTitleId()382     int32_t GetTitleId()
383     {
384         if (!titleId_.has_value()) {
385             titleId_ = ElementRegister::GetInstance()->MakeUniqueId();
386         }
387         return titleId_.value();
388     }
389 
HasSubtitleNode()390     bool HasSubtitleNode() const
391     {
392         return titleId_.has_value();
393     }
394 
SetSubtitleId(const int32_t id)395     bool SetSubtitleId(const int32_t id)
396     {
397         if (HasSubtitleNode()) {
398             return false;
399         }
400         subtitleId_ = id;
401         return true;
402     }
403 
GetSubtitleId()404     int32_t GetSubtitleId()
405     {
406         if (!subtitleId_.has_value()) {
407             subtitleId_ = ElementRegister::GetInstance()->MakeUniqueId();
408         }
409         return subtitleId_.value();
410     }
411 
CalculateFriction(float gamma)412     static float CalculateFriction(float gamma)
413     {
414         constexpr float RATIO = 1.848f;
415         if (GreatOrEqual(gamma, 1.0)) {
416             gamma = 1.0f;
417         }
418         return exp(-RATIO * gamma);
419     }
420 
421     SheetType GetSheetType();
422     bool IsPhoneInLandScape();
423     bool IsShowCloseIcon();
424     ScrollSizeMode GetScrollSizeMode();
425     void InitSheetMode();
426     void GetSheetTypeWithAuto(SheetType& sheetType);
427     void GetSheetTypeWithPopup(SheetType& sheetType);
428 
429     void BubbleStyleSheetTransition(bool isTransitionIn);
430 
431     void StartOffsetEnteringAnimation();
432 
433     void StartAlphaEnteringAnimation(std::function<void()> finish);
434 
435     void StartOffsetExitingAnimation();
436 
437     void StartAlphaExitingAnimation(std::function<void()> finish);
438 
439     void ResetToInvisible();
440 
441     bool IsFold();
442 
SetSheetKey(const SheetKey & sheetKey)443     void SetSheetKey(const SheetKey& sheetKey)
444     {
445         sheetKey_ = sheetKey;
446     }
447 
GetSheetKey()448     SheetKey GetSheetKey() const
449     {
450         return sheetKey_;
451     }
452 
GetAnimationBreak()453     bool GetAnimationBreak() const
454     {
455         return isAnimationBreak_;
456     }
457 
SetAnimationProcess(bool isProcess)458     void SetAnimationProcess(bool isProcess)
459     {
460         isAnimationProcess_ = isProcess;
461     }
462 
GetAnimationProcess()463     bool GetAnimationProcess()
464     {
465         return isAnimationProcess_;
466     }
467 
SetDismissProcess(bool isProcess)468     void SetDismissProcess(bool isProcess)
469     {
470         isDismissProcess_ = isProcess;
471     }
472 
GetDismissProcess()473     bool GetDismissProcess()
474     {
475         return isDismissProcess_;
476     }
477 
GetPageHeightWithoutOffset()478     float GetPageHeightWithoutOffset() const
479     {
480         return pageHeight_;
481     }
482 
GetPageHeight()483     float GetPageHeight()
484     {
485         // OnTransformTranslateUpdate's offset is the relative to the upper left corner of the father
486         // Therefore, if the father is a PageNode, need to obtain the offsetY of the Page relative to the window
487         // On the basis of the normally calculated offset, move parentOffsetY up,
488         // It can be considered as the offset relative to the window
489         auto parentOffsetY = GetRootOffsetYToWindow();
490         return pageHeight_ - parentOffsetY;
491     }
492 
GetSheetMaxHeight()493     float GetSheetMaxHeight()
494     {
495         // pageHeight - sheetTopSafeArea
496         return sheetMaxHeight_;
497     }
498 
GetSheetMaxWidth()499     float GetSheetMaxWidth()
500     {
501         return sheetMaxWidth_;
502     }
503 
GetSheetOffset()504     float GetSheetOffset()
505     {
506         return sheetOffsetY_;
507     }
508 
509     float GetFitContentHeight();
510 
511     void ProcessColumnRect(float height = 0.0f);
512 
WillSpringBack()513     bool WillSpringBack() const
514     {
515         return isSpringBack_;
516     }
517 
SetShowState(bool show)518     void SetShowState(bool show)
519     {
520         show_ = show;
521     }
522 
GetShowState()523     bool GetShowState() const
524     {
525         return show_;
526     }
527 
SetIsDragging(bool isDrag)528     void SetIsDragging(bool isDrag)
529     {
530         isDrag_ = isDrag;
531     }
532 
IsDragging()533     bool IsDragging() const
534     {
535         return isDrag_;
536     }
537 
538     void UpdateMaskBackgroundColor();
539 
540     void UpdateMaskBackgroundColorRender();
541 
GetMaskBackgroundColor()542     Color GetMaskBackgroundColor() const
543     {
544         return sheetMaskColor_;
545     }
546 
InitFoldState()547     void InitFoldState()
548     {
549         auto container = Container::Current();
550         CHECK_NULL_VOID(container);
551         container->InitIsFoldable();
552         if (container->IsFoldable()) {
553             currentFoldStatus_ = container->GetCurrentFoldStatus();
554         }
555     }
556 
IsFoldStatusChanged()557     bool IsFoldStatusChanged()
558     {
559         auto container = Container::Current();
560         CHECK_NULL_RETURN(container, false);
561         if (!container->IsFoldable()) {
562             return false;
563         }
564         auto foldStatus = container->GetCurrentFoldStatus();
565         TAG_LOGI(AceLogTag::ACE_SHEET, "newFoldStatus: %{public}d, currentFoldStatus: %{public}d.",
566             static_cast<int32_t>(foldStatus), static_cast<int32_t>(currentFoldStatus_));
567         if (foldStatus != currentFoldStatus_) {
568             currentFoldStatus_ = foldStatus;
569             return true;
570         }
571         return false;
572     }
573 
UpdateHoverModeChangedCallbackId(const std::optional<int32_t> & id)574     void UpdateHoverModeChangedCallbackId(const std::optional<int32_t>& id)
575     {
576         hoverModeChangedCallbackId_ = id;
577     }
578 
HasHoverModeChangedCallbackId()579     bool HasHoverModeChangedCallbackId() const
580     {
581         return hoverModeChangedCallbackId_.has_value();
582     }
583 
584     // Get ScrollHeight before avoid keyboard
GetScrollHeight()585     float GetScrollHeight() const
586     {
587         auto titleHeight = GetFirstChildHeight();
588         if (sheetType_ == SheetType::SHEET_CENTER) {
589             return centerHeight_ - titleHeight;
590         }
591         return height_ - titleHeight;
592     }
593 
594     float GetFirstChildHeight() const;
595 
596     RefPtr<OverlayManager> GetOverlayManager();
597     RefPtr<FrameNode> GetOverlayRoot();
598     float GetRootOffsetYToWindow();
599 
IsAvoidingKeyboard()600     bool IsAvoidingKeyboard() const
601     {
602         return Positive(keyboardHeight_);
603     }
604 
605     bool IsTypeNeedAvoidAiBar();
606     bool IsCustomHeightOrDetentsChanged(const SheetStyle& sheetStyle) const;
607 
608     RefPtr<FrameNode> GetFirstFrameNodeOfBuilder() const;
609     void GetBuilderInitHeight();
610     void ChangeSheetPage(float height);
611     void DumpAdvanceInfo() override;
612 
GetDetentsIndex()613     uint32_t GetDetentsIndex() const
614     {
615         return detentsFinalIndex_;
616     }
617     bool IsScrollOutOfBoundary();
618     RefPtr<FrameNode> GetScrollNode();
619 
IsSheetBottomStyle()620     bool IsSheetBottomStyle()
621     {
622         if (AceApplicationInfo::GetInstance().GreatOrEqualTargetAPIVersion(PlatformVersion::VERSION_TWELVE)) {
623             return sheetType_ == SheetType::SHEET_BOTTOM || sheetType_ == SheetType::SHEET_BOTTOM_FREE_WINDOW ||
624             sheetType_ == SheetType::SHEET_BOTTOMLANDSPACE;
625         }
626         return sheetType_ == SheetType::SHEET_BOTTOM || sheetType_ == SheetType::SHEET_BOTTOM_FREE_WINDOW;
627     }
628 
629     // Nestable Scroll
GetAxis()630     Axis GetAxis() const override
631     {
632         return Axis::VERTICAL;
633     }
634     ScrollResult HandleScroll(float scrollOffset, int32_t source,
635         NestedState state = NestedState::GESTURE, float velocity = 0.f) override;
636     void OnScrollStartRecursive(
637         WeakPtr<NestableScrollContainer> child, float position, float dragVelocity = 0.0f) override;
638     void OnScrollEndRecursive (const std::optional<float>& velocity) override;
639     bool HandleScrollVelocity(float velocity, const RefPtr<NestableScrollContainer>& child = nullptr) override;
640     ScrollResult HandleScrollWithSheet(float scrollOffset);
641     bool IsCurSheetNeedHalfFoldHover();
642     float GetMaxSheetHeightBeforeDragUpdate();
643     float GetSheetHeightBeforeDragUpdate();
644     void FireHoverModeChangeCallback();
645     void InitFoldCreaseRegion();
646     Rect GetFoldScreenRect() const;
647     void RecoverHalfFoldOrAvoidStatus();
648 
649 protected:
650     void OnDetachFromFrameNode(FrameNode* sheetNode) override;
651 
652 private:
653     void OnModifyDone() override;
654     void OnAttachToFrameNode() override;
655     void OnColorConfigurationUpdate() override;
656     bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override;
657 
658     void RegisterHoverModeChangeCallback();
659     void InitScrollProps();
660     void InitPageHeight();
661     void TranslateTo(float height);
662     void SetColumnMinSize(bool reset = false);
663     void UpdateDragBarStatus();
664     void UpdateCloseIconStatus();
665     void UpdateTitlePadding();
666     RefPtr<FrameNode> GetTitleNode() const;
667     float GetCloseIconPosX(const SizeF& sheetSize, const RefPtr<SheetTheme>& sheetTheme);
668     void UpdateSheetTitle();
669     void UpdateFontScaleStatus();
670     RefPtr<RenderContext> GetRenderContext();
671     bool PostTask(const TaskExecutor::Task& task, const std::string& name);
672     void CheckSheetHeightChange();
673     float GetWrapperHeight();
674     bool SheetHeightNeedChanged();
675     void InitSheetDetents();
676     void HandleFitContontChange(float height);
677     void ChangeSheetHeight(float height);
678     void StartSheetTransitionAnimation(const AnimationOption& option, bool isTransitionIn, float offset);
679     void DismissSheetShadow(const RefPtr<RenderContext>& context);
680     void ClipSheetNode();
681     void CreatePropertyCallback();
682     void ComputeDetentsPos(float currentSheetHeight, float& upHeight, float& downHeight, uint32_t& detentsLowerPos,
683         uint32_t& detentsUpperPos);
684     void IsCustomDetentsChanged(SheetStyle sheetStyle);
685     std::string GetPopupStyleSheetClipPath(SizeF sheetSize, Dimension sheetRadius);
686     std::string GetCenterStyleSheetClipPath(SizeF sheetSize, Dimension sheetRadius);
687     std::string GetBottomStyleSheetClipPath(SizeF sheetSize, Dimension sheetRadius);
688     std::string MoveTo(double x, double y);
689     std::string LineTo(double x, double y);
690     std::string ArcTo(double rx, double ry, double rotation, int32_t arc_flag, double x, double y);
691     void DismissTransition(bool isTransitionIn, float dragVelocity = 0.0f);
692     void AvoidKeyboardBySheetMode(bool forceAvoid = false);
693     bool AvoidKeyboardBeforeTranslate();
694     void AvoidKeyboardAfterTranslate(float height);
695     void DecreaseScrollHeightInSheet(float decreaseHeight);
696     bool IsResizeWhenAvoidKeyboard();
697     void GetCurrentScrollHeight();
698     void RecoverAvoidKeyboardStatus();
699     void RecoverScrollOrResizeAvoidStatus();
700 
701     uint32_t keyboardHeight_ = 0;
702     int32_t targetId_ = -1;
703     SheetKey sheetKey_;
704     std::optional<int32_t> titleId_;
705     std::optional<int32_t> subtitleId_;
706     std::string targetTag_;
707     std::function<void(const std::string&)> callback_;
708     std::function<void()> onDisappear_;
709     std::function<void()> onWillDisappear_;
710     std::function<void()> shouldDismiss_;
711     std::function<void(const int32_t info)> onWillDismiss_;
712     std::function<void()> sheetSpringBack_;
713     std::function<void(const float)> onHeightDidChange_;
714     std::function<void(const float)> onDetentsDidChange_;
715     std::function<void(const float)> onWidthDidChange_;
716     std::function<void(const float)> onTypeDidChange_;
717     std::function<void()> onAppear_;
718     RefPtr<PanEvent> panEvent_;
719     OffsetF arrowOffset_;
720     float currentOffset_ = 0.0f;
721 
722     float preDidHeight_ = 0.0f;
723     float sheetHeightUp_ = 0.0f; // sheet offset to move up when avoiding keyboard
724     float height_ = 0.0f; // sheet height, start from the bottom, before avoiding keyboard
725     float sheetHeight_ = 0.0f; // sheet frameSize Height
726     float wrapperHeight_ = 0.0f; // sheetWrapper frameSize Height
727     float pageHeight_ = 0.0f; // root Height, = maxSize.Height()
728     float scrollHeight_ = 0.0f;
729     float preWidth_ = 0.0f;
730     int32_t preType_ = -1;
731     float sheetTopSafeArea_ = .0f;
732     bool isExecuteOnDisappear_ = false;
733     bool windowRotate_ = false;
734     bool isScrolling_ = false;
735     float builderHeight_ = 0.0f;
736     float sheetMaxHeight_ = 0.0f; // start from the bottom, pageHeight - sheetTopSafeArea
737     float sheetMaxWidth_ = 0.0f;
738     float centerHeight_ = 0.0f; // node height, not translate height
739     float sheetFitContentHeight_ = 0.0f;
740     float sheetOffsetX_ = 0.0f;
741     float sheetOffsetY_ = 0.0f;
742     float bottomOffsetY_ = 0.0f; // offset y with SHEET_BOTTOM_OFFSET, <= 0
743     bool isFirstInit_ = true;
744     bool isAnimationBreak_ = false;
745     bool isAnimationProcess_ = false;
746     bool isDismissProcess_ = false;
747     SheetType sheetType_ = SheetType::SHEET_BOTTOM;
748     bool windowChanged_ = false;
749     bool isDirectionUp_ = true;
750     bool topSafeAreaChanged_ = false;
751     ScrollSizeMode scrollSizeMode_ = ScrollSizeMode::FOLLOW_DETENT;
752 
753     //record sheet sored detent index
754     uint32_t detentsIndex_ = 0;
755 
756     //record sheet unsoreddetent index
757     uint32_t detentsFinalIndex_ = 0;
758     std::string sheetThemeType_ = "auto";
759 
760     WeakPtr<OverlayManager> overlayManager_ = nullptr;
761 
762     std::vector<SheetHeight> preDetents_;
763     std::vector<float> sheetDetentHeight_;
764     std::vector<float> unSortedSheetDentents_;
765     std::vector<Rect> currentFoldCreaseRegion_;
766 
767     std::shared_ptr<AnimationUtils::Animation> animation_;
768     std::optional<int32_t> foldDisplayModeChangedCallbackId_;
769     std::optional<int32_t> hoverModeChangedCallbackId_;
770 
771     bool show_ = true;
772     bool isDrag_ = false;
773     FoldStatus currentFoldStatus_ = FoldStatus::UNKNOWN;
774     bool isNeedProcessHeight_ = false;
775     bool isSheetNeedScroll_ = false; // true if Sheet is ready to receive scroll offset.
776     bool isSheetPosChanged_ = false; // UpdateTransformTranslate end
777     bool isSpringBack_ = false; // sheet rebound
778 
779     double start_ = 0.0; // start position of detents changed
780     RefPtr<NodeAnimatablePropertyFloat> property_;
781 
782     ACE_DISALLOW_COPY_AND_MOVE(SheetPresentationPattern);
783 
784     float preDetentsHeight_ = 0.0f;
785     std::optional<SizeT<int32_t>> windowSize_;
786     float scale_ = 1.0;
787 
788     Color sheetMaskColor_ = Color::TRANSPARENT;
789     SheetKeyboardAvoidMode keyboardAvoidMode_ = SheetKeyboardAvoidMode::TRANSLATE_AND_SCROLL;
790     float resizeDecreasedHeight_ = 0.f;
791 };
792 } // namespace OHOS::Ace::NG
793 
794 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OVERLAY_SHEET_PRESENTATION_PATTERN_H
795