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