1 /* 2 * Copyright (c) 2022-2024 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_OVERLAY_MANAGER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OVERLAY_OVERLAY_MANAGER_H 18 19 #include <cstdint> 20 #include <functional> 21 #include <stack> 22 #include <unordered_map> 23 #include <utility> 24 25 #include "base/memory/ace_type.h" 26 #include "base/memory/referenced.h" 27 #include "base/utils/noncopyable.h" 28 #include "base/want/want_wrap.h" 29 #include "base/utils/utils.h" 30 #include "core/components/common/properties/placement.h" 31 #include "core/components/dialog/dialog_properties.h" 32 #include "core/components/picker/picker_data.h" 33 #include "core/components_ng/animation/geometry_transition.h" 34 #include "core/components_ng/base/frame_node.h" 35 #include "core/components_ng/base/ui_node.h" 36 #include "core/components_ng/pattern/calendar_picker/calendar_type_define.h" 37 #include "core/components_ng/pattern/overlay/content_cover_param.h" 38 #include "core/components_ng/pattern/overlay/modal_presentation_pattern.h" 39 #include "core/components_ng/pattern/overlay/modal_style.h" 40 #include "core/components_ng/pattern/overlay/sheet_style.h" 41 #include "core/components_ng/pattern/overlay/group_manager.h" 42 #include "core/components_ng/pattern/picker/datepicker_event_hub.h" 43 #include "core/components_ng/pattern/picker/picker_type_define.h" 44 #include "core/components_ng/pattern/text_picker/textpicker_event_hub.h" 45 #include "core/components_ng/pattern/toast/toast_layout_property.h" 46 #include "core/components_ng/pattern/toast/toast_view.h" 47 #include "core/components_ng/property/safe_area_insets.h" 48 #include "core/pipeline_ng/ui_task_scheduler.h" 49 #include "interfaces/inner_api/ace/modal_ui_extension_config.h" 50 51 namespace OHOS::Ace::NG { 52 53 struct PopupInfo { 54 int32_t popupId = -1; 55 WeakPtr<FrameNode> target; 56 RefPtr<FrameNode> popupNode; 57 bool markNeedUpdate = false; 58 bool isCurrentOnShow = false; 59 bool isBlockEvent = true; 60 SizeF targetSize; 61 OffsetF targetOffset; 62 bool focusable = false; 63 bool isAvoidKeyboard = false; 64 int32_t disappearingTimeWithContinuousOperation = 700; 65 }; 66 67 struct GatherNodeChildInfo { 68 WeakPtr<FrameNode> imageNode; 69 OffsetF offset; 70 float width = 0.0f; 71 float height = 0.0f; 72 float halfWidth = 0.0f; 73 float halfHeight = 0.0f; 74 WeakPtr<FrameNode> preImageNode; 75 }; 76 77 struct DismissTarget { DismissTargetDismissTarget78 DismissTarget() {} DismissTargetDismissTarget79 explicit DismissTarget(int32_t inputTargetId) : targetIdOfModal(inputTargetId) {} DismissTargetDismissTarget80 explicit DismissTarget(const SheetKey& index) : sheetKey(index) 81 { 82 targetIsSheet = true; 83 } 84 GetTargetIdDismissTarget85 int32_t GetTargetId() 86 { 87 return targetIsSheet ? sheetKey.targetId : targetIdOfModal; 88 } 89 90 int32_t targetIdOfModal = -1; 91 SheetKey sheetKey; 92 bool targetIsSheet = false; 93 }; 94 95 struct CustomKeyboardOffsetInfo { 96 float finalOffset = 0.0f; 97 float inAniStartOffset = 0.0f; 98 float outAniEndOffset = 0.0f; 99 }; 100 101 struct OverlayManagerInfo { 102 bool renderRootOverlay = true; 103 bool enableBackPressedEvent = false; 104 }; 105 106 // StageManager is the base class for root render node to perform page switch. 107 class ACE_FORCE_EXPORT OverlayManager : public virtual AceType { 108 DECLARE_ACE_TYPE(OverlayManager, AceType); 109 110 public: OverlayManager(const RefPtr<FrameNode> & rootNode)111 explicit OverlayManager(const RefPtr<FrameNode>& rootNode) : rootNodeWeak_(rootNode) {} 112 ~OverlayManager() override; 113 void ShowIndexerPopup(int32_t targetId, RefPtr<FrameNode>& customNode); 114 void RemoveIndexerPopupById(int32_t targetId); 115 void RemoveIndexerPopup(); 116 void HidePopup(int32_t targetId, const PopupInfo& popupInfo, bool isEraseFromMap = false); 117 RefPtr<FrameNode> HidePopupWithoutAnimation(int32_t targetId, const PopupInfo& popupInfo, 118 bool isForceClear = false); 119 void ShowPopup(int32_t targetId, const PopupInfo& popupInfo, 120 const std::function<void(int32_t)>&& onWillDismiss = nullptr, bool interactiveDismiss = true); 121 void HideTips(int32_t targetId, const PopupInfo& tipsInfo, int32_t disappearingTime); 122 void ShowTips(int32_t targetId, const PopupInfo& tipsInfo, int32_t appearingTime, 123 int32_t appearingTimeWithContinuousOperation); 124 void ErasePopup(int32_t targetId); 125 void EraseTipsInfo(int32_t targetId); 126 PopupInfo GetTipsInfo(int32_t targetId); 127 void HideAllPopups(); 128 void HideCustomPopups(); 129 void SetPopupHotAreas(RefPtr<FrameNode> popupNode); 130 void ShowPopupAnimation(const RefPtr<FrameNode>& popupNode); 131 void ShowPopupAnimationNG(const RefPtr<FrameNode>& popupNode); 132 void HidePopupAnimation(const RefPtr<FrameNode>& popupNode, const std::function<void()>& finish); 133 PopupInfo GetPopupInfoWithExistContent(const RefPtr<UINode>& node); 134 GetPopupInfo(int32_t targetId)135 PopupInfo GetPopupInfo(int32_t targetId) const 136 { 137 auto it = popupMap_.find(targetId); 138 if (it == popupMap_.end()) { 139 return {}; 140 } 141 return it->second; 142 } 143 HasPopupInfo(int32_t targetId)144 bool HasPopupInfo(int32_t targetId) const 145 { 146 return popupMap_.find(targetId) != popupMap_.end(); 147 } 148 ErasePopupInfo(int32_t targetId)149 void ErasePopupInfo(int32_t targetId) 150 { 151 if (popupMap_.find(targetId) != popupMap_.end()) { 152 popupMap_.erase(targetId); 153 } 154 } 155 SetDismissDialogId(int32_t id)156 void SetDismissDialogId(int32_t id) 157 { 158 dismissDialogId_ = id; 159 } 160 GetDismissDialogId()161 int32_t GetDismissDialogId() const 162 { 163 return dismissDialogId_; 164 } 165 166 void ShowMenu(int32_t targetId, const NG::OffsetF& offset, RefPtr<FrameNode> menu = nullptr); 167 void HideMenu(const RefPtr<FrameNode>& menu, int32_t targetId, bool isMenuOnTouch = false); 168 void DeleteMenu(int32_t targetId); 169 void ShowMenuInSubWindow(int32_t targetId, const NG::OffsetF& offset, RefPtr<FrameNode> menu = nullptr); 170 void HideMenuInSubWindow(const RefPtr<FrameNode>& menu, int32_t targetId); 171 RefPtr<FrameNode> GetMenuNodeWithExistContent(const RefPtr<UINode>& node); 172 RefPtr<FrameNode> GetMenuNode(int32_t targetId); 173 void HideMenuInSubWindow(bool showPreviewAnimation = true, bool startDrag = false); 174 void CleanMenuInSubWindow(int32_t targetId); 175 void CleanPreviewInSubWindow(); 176 void CleanHoverImagePreviewInSubWindow(const RefPtr<FrameNode>& flexNode); 177 void CleanPopupInSubWindow(bool isForceClear = false); 178 void CleanMenuInSubWindowWithAnimation(); 179 void HideAllMenus(); 180 void UpdatePreviousDisappearingTime(int32_t targetId); 181 void UpdateTipsEnterAndLeaveInfo(int32_t targetId); 182 void UpdateTipsEnterAndLeaveInfoBool(int32_t targetId); 183 bool GetBoolFromTipsEnterAndLeaveInfo(int32_t targetId, int32_t times); 184 int32_t GetTipsEnterAndLeaveInfo(int32_t targetId); 185 void EraseTipsEnterAndLeaveInfo(int32_t targetId, int32_t times); 186 187 void ClearToastInSubwindow(); 188 void ClearToast(); 189 void ShowToast(const NG::ToastInfo& toastInfo, const std::function<void(int32_t)>& callback); 190 void CloseToast(int32_t toastId, const std::function<void(int32_t)>& callback); 191 192 void FireAutoSave(const RefPtr<FrameNode>& ContainerNode); 193 GetDialogMap()194 std::unordered_map<int32_t, RefPtr<FrameNode>> GetDialogMap() 195 { 196 return dialogMap_; 197 }; 198 RefPtr<FrameNode> GetDialog(int32_t dialogId); 199 RefPtr<FrameNode> SetDialogMask(const DialogProperties& dialogProps); 200 // customNode only used by customDialog, pass in nullptr if not customDialog 201 RefPtr<FrameNode> ShowDialog( 202 const DialogProperties& dialogProps, std::function<void()>&& buildFunc, bool isRightToLeft = false); 203 RefPtr<FrameNode> ShowDialogWithNode( 204 const DialogProperties& dialogProps, const RefPtr<NG::UINode>& customNode, bool isRightToLeft = false); 205 void ShowCustomDialog(const RefPtr<FrameNode>& customNode); 206 void ShowDateDialog(const DialogProperties& dialogProps, const DatePickerSettingData& settingData, 207 std::map<std::string, NG::DialogEvent> dialogEvent, 208 std::map<std::string, NG::DialogGestureEvent> dialogCancelEvent, 209 std::map<std::string, NG::DialogCancelEvent> dialogLifeCycleEvent = {}, 210 const std::vector<ButtonInfo>& buttonInfos = std::vector<ButtonInfo>({})); 211 void ShowTimeDialog(const DialogProperties& dialogProps, const TimePickerSettingData& settingData, 212 std::map<std::string, PickerTime> timePickerProperty, std::map<std::string, NG::DialogEvent> dialogEvent, 213 std::map<std::string, NG::DialogGestureEvent> dialogCancelEvent, 214 std::map<std::string, NG::DialogCancelEvent> dialogLifeCycleEvent = {}, 215 const std::vector<ButtonInfo>& buttonInfos = std::vector<ButtonInfo>({})); 216 void ShowTextDialog(const DialogProperties& dialogProps, const TextPickerSettingData& settingData, 217 std::map<std::string, NG::DialogTextEvent> dialogEvent, 218 std::map<std::string, NG::DialogGestureEvent> dialogCancelEvent, 219 std::map<std::string, NG::DialogCancelEvent> dialogLifeCycleEvent = {}, 220 const std::vector<ButtonInfo>& buttonInfos = std::vector<ButtonInfo>({})); 221 void ShowCalendarDialog(const DialogProperties& dialogProps, const CalendarSettingData& settingData, 222 std::map<std::string, NG::DialogEvent> dialogEvent, 223 std::map<std::string, NG::DialogGestureEvent> dialogCancelEvent, 224 std::map<std::string, NG::DialogCancelEvent> dialogLifeCycleEvent = {}, 225 const std::vector<ButtonInfo>& buttonInfos = std::vector<ButtonInfo>({})); 226 void PopModalDialog(int32_t maskId); 227 228 void CloseDialog(const RefPtr<FrameNode>& dialogNode); 229 void DeleteDialogHotAreas(const RefPtr<FrameNode>& dialogNode); 230 231 void OpenCustomDialog(const DialogProperties& dialogProps, std::function<void(int32_t)> &&callback); 232 void CloseCustomDialog(const int32_t dialogId); 233 void CloseCustomDialog(const WeakPtr<NG::UINode>& node, std::function<void(int32_t)> &&callback); 234 void UpdateCustomDialog(const WeakPtr<NG::UINode>& node, const DialogProperties& dialogProps, 235 std::function<void(int32_t)> &&callback); 236 std::optional<double> GetTopOrder(); 237 std::optional<double> GetBottomOrder(); 238 SetSubWindowId(int32_t subWindowId)239 void SetSubWindowId(int32_t subWindowId) 240 { 241 subWindowId_ = subWindowId; 242 } GetSubwindowId()243 int32_t GetSubwindowId() 244 { 245 return subWindowId_; 246 } SetMaskNodeId(int32_t dialogId,int32_t maskId)247 void SetMaskNodeId(int32_t dialogId, int32_t maskId) 248 { 249 maskNodeIdMap_[dialogId] = maskId; 250 } 251 bool isMaskNode(int32_t maskId); 252 int32_t GetMaskNodeIdWithDialogId(int32_t dialogId); 253 254 /** pop overlays (if any) on back press 255 * 256 * @return true if popup was removed, false if no overlay exists 257 */ 258 bool RemoveOverlay(bool isBackPressed, bool isPageRouter = false); 259 bool RemoveDialog(const RefPtr<FrameNode>& overlay, bool isBackPressed, bool isPageRouter = false); 260 bool RemoveBubble(const RefPtr<FrameNode>& overlay); 261 bool RemoveMenu(const RefPtr<FrameNode>& overlay); 262 bool RemoveDragPreview(const RefPtr<FrameNode>& overlay); 263 bool RemoveModalInOverlay(); 264 bool RemoveAllModalInOverlay(bool isRouterTransition = true); 265 bool RemoveAllModalInOverlayByStack(); 266 bool RemoveAllModalInOverlayByList(); 267 bool OnRemoveAllModalInOverlayByList(); 268 void AfterRemoveAllModalInOverlayByList(); 269 bool IsModalUiextensionNode(const RefPtr<FrameNode>& topModalNode); 270 bool IsProhibitedRemoveByRouter(const RefPtr<FrameNode>& topModalNode); 271 bool IsProhibitedRemoveByNavigation(const RefPtr<FrameNode>& topModalNode); 272 bool RemoveOverlayInSubwindow(); 273 bool RemoveNonKeyboardOverlay(const RefPtr<FrameNode>& overlay); 274 bool RemoveMenuInSubWindow(const RefPtr<FrameNode>& menuWrapper); 275 RegisterOnHideDialog(std::function<void ()> callback)276 void RegisterOnHideDialog(std::function<void()> callback) 277 { 278 onHideDialogCallback_ = callback; 279 } 280 CallOnHideDialogCallback()281 void CallOnHideDialogCallback() 282 { 283 if (onHideDialogCallback_) { 284 onHideDialogCallback_(); 285 } 286 } 287 SetBackPressEvent(std::function<bool ()> event)288 void SetBackPressEvent(std::function<bool()> event) 289 { 290 backPressEvent_ = event; 291 } 292 FireBackPressEvent()293 bool FireBackPressEvent() const 294 { 295 if (backPressEvent_) { 296 return backPressEvent_(); 297 } 298 return false; 299 } 300 GetHasPixelMap()301 bool GetHasPixelMap() 302 { 303 return hasPixelMap_; 304 } 305 SetHasPixelMap(bool hasPixelMap)306 void SetHasPixelMap(bool hasPixelMap) 307 { 308 hasPixelMap_ = hasPixelMap; 309 } 310 GetHasDragPixelMap()311 bool GetHasDragPixelMap() const 312 { 313 return hasDragPixelMap_; 314 } 315 SetHasDragPixelMap(bool hasDragPixelMap)316 void SetHasDragPixelMap(bool hasDragPixelMap) 317 { 318 hasDragPixelMap_ = hasDragPixelMap; 319 } 320 GetHasGatherNode()321 bool GetHasGatherNode() 322 { 323 return hasGatherNode_; 324 } 325 GetPixelMapNode()326 RefPtr<FrameNode> GetPixelMapNode() 327 { 328 return pixmapColumnNodeWeak_.Upgrade(); 329 } 330 331 RefPtr<FrameNode> GetPixelMapContentNode(bool isSubwindowOverlay = false) const; 332 333 RefPtr<FrameNode> GetPixelMapContentNodeForSubwindow() const; 334 335 RefPtr<FrameNode> GetDragPixelMapContentNode() const; 336 337 RefPtr<FrameNode> GetRelativeContainerNode() const; 338 339 RefPtr<FrameNode> GetPixelMapBadgeNode() const; 340 341 RefPtr<FrameNode> GetDragPixelMapBadgeNode() const; 342 GetHasFilter()343 bool GetHasFilter() 344 { 345 return hasFilter_; 346 } 347 SetHasFilter(bool hasFilter)348 void SetHasFilter(bool hasFilter) 349 { 350 hasFilter_ = hasFilter; 351 } 352 GetHasEvent()353 bool GetHasEvent() 354 { 355 return hasEvent_; 356 } 357 SetHasEvent(bool hasEvent)358 void SetHasEvent(bool hasEvent) 359 { 360 hasEvent_ = hasEvent; 361 } 362 GetIsOnAnimation()363 bool GetIsOnAnimation() 364 { 365 return isOnAnimation_; 366 } 367 SetIsOnAnimation(bool isOnAnimation)368 void SetIsOnAnimation(bool isOnAnimation) 369 { 370 isOnAnimation_ = isOnAnimation; 371 } 372 SetFilterColumnNode(const RefPtr<FrameNode> & columnNode)373 void SetFilterColumnNode(const RefPtr<FrameNode>& columnNode) 374 { 375 filterColumnNodeWeak_ = columnNode; 376 } 377 void MountFilterToWindowScene(const RefPtr<FrameNode>& columnNode, const RefPtr<UINode>& windowScene); 378 void MountPixelMapToWindowScene( 379 const RefPtr<FrameNode>& columnNode, const RefPtr<UINode>& windowScene, bool isDragPixelMap = false); 380 void MountEventToWindowScene(const RefPtr<FrameNode>& columnNode, const RefPtr<UINode>& windowScene); 381 void MountPixelMapToRootNode(const RefPtr<FrameNode>& columnNode, bool isDragPixelMap = false); 382 void MountEventToRootNode(const RefPtr<FrameNode>& columnNode); 383 void RemovePixelMap(); 384 void RemovePixelMapAnimation(bool startDrag, double x, double y, bool isSubwindowOverlay = false); 385 void RemoveDragPixelMap(); 386 void UpdatePixelMapScale(float& scale); 387 void RemoveFilter(); 388 void RemoveFilterAnimation(); 389 void RemoveEventColumn(); 390 void UpdatePixelMapPosition(bool isSubwindowOverlay = false); 391 void UpdateContextMenuDisappearPosition(const NG::OffsetF& offset, float menuScale = 1.0f, 392 bool isRedragStart = false, int32_t menuWrapperId = -1); 393 void ContextMenuSwitchDragPreviewAnimation(const RefPtr<NG::FrameNode>& dragPreviewNode, 394 const NG::OffsetF& offset); 395 bool GetMenuPreviewCenter(NG::OffsetF& offset); 396 ResetContextMenuDragHideFinished()397 void ResetContextMenuDragHideFinished() 398 { 399 isContextMenuDragHideFinished_ = false; 400 dragMoveVector_ = OffsetF(0.0f, 0.0f); 401 lastDragMoveVector_ = OffsetF(0.0f, 0.0f); 402 } 403 ResetContextMenuRestartDragVector()404 void ResetContextMenuRestartDragVector() 405 { 406 dragMoveVector_ = OffsetF(0.0f, 0.0f); 407 lastDragMoveVector_ = OffsetF(0.0f, 0.0f); 408 } 409 SetContextMenuDragHideFinished(bool isContextMenuDragHideFinished)410 void SetContextMenuDragHideFinished(bool isContextMenuDragHideFinished) 411 { 412 isContextMenuDragHideFinished_ = isContextMenuDragHideFinished; 413 } 414 IsContextMenuDragHideFinished()415 bool IsContextMenuDragHideFinished() const 416 { 417 return isContextMenuDragHideFinished_ == true; 418 } 419 IsOriginDragMoveVector()420 bool IsOriginDragMoveVector() const 421 { 422 return dragMoveVector_.NonOffset() && lastDragMoveVector_.NonOffset(); 423 } 424 IsUpdateDragMoveVector()425 bool IsUpdateDragMoveVector() const 426 { 427 return !GetUpdateDragMoveVector().NonOffset() && !lastDragMoveVector_.NonOffset(); 428 } 429 UpdateDragMoveVector(const NG::OffsetF & offset)430 void UpdateDragMoveVector(const NG::OffsetF& offset) 431 { 432 lastDragMoveVector_ = dragMoveVector_; 433 dragMoveVector_ = offset; 434 } 435 GetUpdateDragMoveVector()436 OffsetF GetUpdateDragMoveVector() const 437 { 438 return dragMoveVector_ - lastDragMoveVector_; 439 } 440 441 void BindContentCover(bool isShow, std::function<void(const std::string&)>&& callback, 442 std::function<RefPtr<UINode>()>&& buildNodeFunc, NG::ModalStyle& modalStyle, std::function<void()>&& onAppear, 443 std::function<void()>&& onDisappear, std::function<void()>&& onWillAppear, 444 std::function<void()>&& onWillDisappear, const NG::ContentCoverParam& contentCoverParam, 445 const RefPtr<FrameNode>& targetNode, int32_t sessionId = 0); 446 void OnBindContentCover(bool isShow, std::function<void(const std::string&)>&& callback, 447 std::function<RefPtr<UINode>()>&& buildNodeFunc, NG::ModalStyle& modalStyle, std::function<void()>&& onAppear, 448 std::function<void()>&& onDisappear, std::function<void()>&& onWillAppear, 449 std::function<void()>&& onWillDisappear, const NG::ContentCoverParam& contentCoverParam, 450 const RefPtr<FrameNode>& targetNode, int32_t sessionId = 0); 451 void BindSheet(bool isShow, std::function<void(const std::string&)>&& callback, 452 std::function<RefPtr<UINode>()>&& buildNodeFunc, std::function<RefPtr<UINode>()>&& buildTitleNodeFunc, 453 NG::SheetStyle& sheetStyle, std::function<void()>&& onAppear, std::function<void()>&& onDisappear, 454 std::function<void()>&& shouldDismiss, std::function<void(const int32_t info)>&& onWillDismiss, 455 std::function<void()>&& onWillAppear, std::function<void()>&& onWillDisappear, 456 std::function<void(const float)>&& onHeightDidChange, 457 std::function<void(const float)>&& onDetentsDidChange, std::function<void(const float)>&& onWidthDidChange, 458 std::function<void(const float)>&& onTypeDidChange, std::function<void()>&& sheetSpringBack, 459 const RefPtr<FrameNode>& targetNode); 460 void OnBindSheet(bool isShow, std::function<void(const std::string&)>&& callback, 461 std::function<RefPtr<UINode>()>&& buildNodeFunc, std::function<RefPtr<UINode>()>&& buildtitleNodeFunc, 462 NG::SheetStyle& sheetStyle, std::function<void()>&& onAppear, std::function<void()>&& onDisappear, 463 std::function<void()>&& shouldDismiss, std::function<void(const int32_t info)>&& onWillDismiss, 464 std::function<void()>&& onWillAppear, std::function<void()>&& onWillDisappear, 465 std::function<void(const float)>&& onHeightDidChange, 466 std::function<void(const float)>&& onDetentsDidChange, std::function<void(const float)>&& onWidthDidChange, 467 std::function<void(const float)>&& onTypeDidChange, std::function<void()>&& sheetSpringBack, 468 const RefPtr<FrameNode>& targetNode); 469 void CloseSheet(const SheetKey& sheetKey); 470 void InitSheetMask( 471 const RefPtr<FrameNode>& maskNode, const RefPtr<FrameNode>& sheetNode, const SheetStyle& sheetStyle); IsModalEmpty()472 bool IsModalEmpty() const 473 { 474 return modalStack_.empty(); 475 } 476 bool HasModalPage(); 477 void DismissSheet(); 478 void DismissContentCover(); 479 void SheetSpringBack(); 480 481 void OpenBindSheetByUIContext( 482 const RefPtr<FrameNode>& sheetContentNode, std::function<RefPtr<UINode>()>&& buildtitleNodeFunc, 483 NG::SheetStyle& sheetStyle, std::function<void()>&& onAppear, std::function<void()>&& onDisappear, 484 std::function<void()>&& shouldDismiss, std::function<void(const int32_t)>&& onWillDismiss, 485 std::function<void()>&& onWillAppear, std::function<void()>&& onWillDisappear, 486 std::function<void(const float)>&& onHeightDidChange, 487 std::function<void(const float)>&& onDetentsDidChange, 488 std::function<void(const float)>&& onWidthDidChange, 489 std::function<void(const float)>&& onTypeDidChange, 490 std::function<void()>&& sheetSpringBack, 491 std::function<void(const int32_t, const int32_t)> cleanViewContextMapCallback, 492 const RefPtr<FrameNode>& targetNode); 493 void UpdateBindSheetByUIContext(const RefPtr<NG::FrameNode>& sheetContentNode, 494 NG::SheetStyle& sheetStyle, int32_t targetId, bool isPartialUpdate); 495 void CloseBindSheetByUIContext(const RefPtr<NG::FrameNode>& sheetContentNode, int32_t targetId); SetDismissTarget(const DismissTarget & dismissTarget)496 void SetDismissTarget(const DismissTarget& dismissTarget) 497 { 498 dismissTarget_ = dismissTarget; 499 } SetDismissSheet(int32_t sheetId)500 void SetDismissSheet(int32_t sheetId) 501 { 502 dismissSheetId_ = sheetId; 503 } GetDismissSheet()504 int32_t GetDismissSheet() const 505 { 506 return dismissSheetId_; 507 } 508 RefPtr<FrameNode> GetModalStackTop(); 509 void RemoveSheetNode(const RefPtr<FrameNode>& sheetNode); 510 void CreateSheetWapperNode(const RefPtr<FrameNode>& sheetPageNode, 511 const RefPtr<FrameNode>& targetNode, NG::SheetStyle& sheetStyle); 512 void CreateMaskNode(const RefPtr<FrameNode>& sheetPageNode, 513 const RefPtr<FrameNode>& targetNode, NG::SheetStyle& sheetStyle); 514 void RemoveSheet(RefPtr<FrameNode> sheetNode); 515 void InitSheetWrapperAction(const RefPtr<FrameNode>& sheetNode, 516 const RefPtr<FrameNode>& targetNode, NG::SheetStyle& sheetStyle); 517 RefPtr<FrameNode> MountSheetWrapperAndChildren(const RefPtr<FrameNode>& sheetNode, 518 const RefPtr<FrameNode>& targetNode, NG::SheetStyle& sheetStyle); GetSheetMap()519 std::unordered_map<SheetKey, WeakPtr<FrameNode>, SheetKeyHash> GetSheetMap() 520 { 521 return sheetMap_; 522 } 523 void MountToParentWithService(const RefPtr<UINode>& rootNode, const RefPtr<FrameNode>& node, 524 std::optional<double> levelOrder = std::nullopt); 525 void OnMainWindowSizeChange(int32_t instanceId); 526 527 void CleanSheet(const RefPtr<FrameNode>& sheetNode, const SheetKey& sheetKey); 528 529 RefPtr<FrameNode> GetSheetMask(const RefPtr<FrameNode>& sheetNode); 530 531 RefPtr<FrameNode> GetModal(int32_t targetId); 532 void RemoveModal(int32_t targetId); 533 void DeleteModal(int32_t targetId, bool needOnWillDisappear = true); 534 void PopTopModalNode(); 535 536 void DeleteModalNode(int32_t targetId, RefPtr<FrameNode>& modalNode, bool isModal, bool needOnWillDisappear); 537 538 void BindKeyboard(const std::function<void()>& keyboardBuilder, int32_t targetId); 539 void BindKeyboardWithNode(const RefPtr<UINode>& keyboard, int32_t targetId); 540 void CloseKeyboard(int32_t targetId); 541 void UpdateCustomKeyboardPosition(); 542 543 RefPtr<UINode> FindWindowScene(RefPtr<FrameNode> targetNode); 544 545 // ui extension 546 bool HandleUIExtNodeSize(const AAFwk::Want& want, RefPtr<FrameNode> uiExtNode); 547 bool HandleUIExtNodeAngle(int32_t uiExtNodeAngle, RefPtr<FrameNode> uiExtNode); 548 bool HandleUIExtNodeTransform(const AAFwk::Want& want, RefPtr<FrameNode> uiExtNode); 549 bool UIExtNodeAngleValid(int32_t uiExtNodeAngle); 550 int32_t CreateModalUIExtension(const RefPtr<WantWrap>& want, const ModalUIExtensionCallbacks& callbacks, 551 const ModalUIExtensionConfig& config); 552 int32_t CreateModalUIExtension(const AAFwk::Want& want, const ModalUIExtensionCallbacks& callbacks, 553 const ModalUIExtensionConfig& config); 554 void CloseModalUIExtension(int32_t sessionId); 555 void UpdateModalUIExtensionConfig( 556 int32_t sessionId, const ModalUIExtensionAllowedUpdateConfig& config); 557 static ModalStyle SetUIExtensionModalStyleAndGet(bool prohibitedRemoveByRouter, 558 bool isAllowAddChildBelowModalUec, bool prohibitedRemoveByNavigation); 559 560 RefPtr<FrameNode> BuildAIEntityMenu(const std::vector<std::pair<std::string, std::function<void()>>>& menuOptions); 561 RefPtr<FrameNode> CreateAIEntityMenu(const std::vector<std::pair<std::string, std::function<void()>>>& menuOptions, 562 const RefPtr<FrameNode>& targetNode); 563 bool ShowAIEntityMenu(const std::vector<std::pair<std::string, std::function<void()>>>& menuOptions, 564 const RectF& aiRect, const RefPtr<FrameNode>& targetNode); 565 void CloseAIEntityMenu(int32_t targetId); 566 567 void MarkDirty(PropertyChangeFlag flag); 568 void MarkDirtyOverlay(); 569 float GetRootHeight() const; 570 float GetRootWidth() const; 571 572 void PlaySheetMaskTransition(RefPtr<FrameNode> maskNode, RefPtr<FrameNode> sheetNode, bool isTransitionIn); 573 574 void PlaySheetTransition(RefPtr<FrameNode> sheetNode, bool isTransitionIn, bool isFirstTransition = true); 575 576 void ComputeSheetOffset(NG::SheetStyle& sheetStyle, RefPtr<FrameNode> sheetNode); 577 578 void ComputeSingleGearSheetOffset(NG::SheetStyle& sheetStyle, RefPtr<FrameNode> sheetNode); 579 580 void ComputeDetentsSheetOffset(NG::SheetStyle& sheetStyle, RefPtr<FrameNode> sheetNode); 581 582 void CheckDeviceInLandscape(NG::SheetStyle& sheetStyle, RefPtr<FrameNode> sheetNode, float& sheetTopSafeArea); 583 SetSheetHeight(float height)584 void SetSheetHeight(float height) 585 { 586 sheetHeight_ = height; 587 } 588 589 const WeakPtr<UINode>& GetRootNode() const; 590 const RefPtr<GroupManager>& GetGroupManager() const; 591 592 void ModalPageLostFocus(const RefPtr<FrameNode>& node); 593 594 void SetCustomKeyboardOption(bool supportAvoidance); 595 SetFilterActive(bool actived)596 void SetFilterActive(bool actived) 597 { 598 hasFilterActived = actived; 599 } 600 SetDismissPopupId(int32_t targetId)601 void SetDismissPopupId(int32_t targetId) 602 { 603 dismissPopupId_ = targetId; 604 } 605 606 void DismissPopup(); 607 608 void MountGatherNodeToRootNode(const RefPtr<FrameNode>& frameNode, 609 const std::vector<GatherNodeChildInfo>& gatherNodeChildrenInfo); 610 void MountGatherNodeToWindowScene(const RefPtr<FrameNode>& frameNode, 611 const std::vector<GatherNodeChildInfo>& gatherNodeChildrenInfo, 612 const RefPtr<UINode>& windowScene); 613 void RemoveGatherNode(); 614 void RemoveGatherNodeWithAnimation(); 615 void UpdateGatherNodeToTop(); GetGatherNode()616 RefPtr<FrameNode> GetGatherNode() const 617 { 618 return gatherNodeWeak_.Upgrade(); 619 } SetDragNodeCopy(const RefPtr<FrameNode> & dragNodeCopy)620 void SetDragNodeCopy(const RefPtr<FrameNode>& dragNodeCopy) 621 { 622 dragNodeCopyWeak_ = dragNodeCopy; 623 } GetDragNodeCopy()624 RefPtr<FrameNode> GetDragNodeCopy() 625 { 626 return dragNodeCopyWeak_.Upgrade(); 627 } GetGatherNodeChildrenInfo()628 const std::vector<GatherNodeChildInfo>& GetGatherNodeChildrenInfo() 629 { 630 return gatherNodeChildrenInfo_; 631 } IsGatherWithMenu()632 bool IsGatherWithMenu() const 633 { 634 return isGatherWithMenu_; 635 } SetIsGatherWithMenu(bool isGatherWithMenu)636 void SetIsGatherWithMenu(bool isGatherWithMenu) 637 { 638 isGatherWithMenu_ = isGatherWithMenu; 639 } 640 void RemoveMenuBadgeNode(const RefPtr<FrameNode>& menuWrapperNode); 641 void RemovePreviewBadgeNode(); 642 void CreateOverlayNode(); 643 void AddFrameNodeToOverlay(const RefPtr<NG::FrameNode>& node, std::optional<int32_t> index = std::nullopt); 644 RefPtr<FrameNode> CreateOverlayNodeWithOrder(std::optional<double> levelOrder); 645 void AddFrameNodeWithOrder(const RefPtr<FrameNode>& node, std::optional<double> levelOrder); 646 void RemoveFrameNodeOnOverlay(const RefPtr<NG::FrameNode>& node); 647 void RemoveFrameNodeWithOrder(const RefPtr<NG::FrameNode>& node); 648 void ShowNodeOnOverlay(const RefPtr<NG::FrameNode>& node); 649 void HideNodeOnOverlay(const RefPtr<NG::FrameNode>& node); 650 void ShowAllNodesOnOverlay(); 651 void HideAllNodesOnOverlay(); GetOverlayNode()652 RefPtr<FrameNode> GetOverlayNode() 653 { 654 return overlayNode_; 655 } 656 bool CheckPageNeedAvoidKeyboard() const; 657 void AvoidCustomKeyboard(int32_t targetId, float safeHeight); 658 void ShowFilterAnimation(const RefPtr<FrameNode>& columnNode); EraseMenuInfo(int32_t targetId)659 void EraseMenuInfo(int32_t targetId) 660 { 661 if (menuMap_.find(targetId) != menuMap_.end()) { 662 menuMap_.erase(targetId); 663 } 664 } 665 bool IsRootExpansive() const; 666 void DumpOverlayInfo() const; 667 void ReloadBuilderNodeConfig(); 668 IsMenuShow()669 bool IsMenuShow() const 670 { 671 return isMenuShow_; 672 } 673 674 void SetIsMenuShow(bool isMenuShow, const RefPtr<FrameNode>& menuNode = nullptr); 675 SetIsAttachToCustomNode(bool isAttachToCustomNode)676 void SetIsAttachToCustomNode(bool isAttachToCustomNode) 677 { 678 isAttachToCustomNode_ = isAttachToCustomNode; 679 } 680 681 void SetIsAllowedBeCovered(bool isAllowedBeCovered = true); 682 void ClearUIExtensionNode(); 683 void DeleteUIExtensionNode(int32_t sessionId); 684 bool AddCurSessionId(int32_t curSessionId); 685 void ResetRootNode(int32_t sessionId); 686 void OnUIExtensionWindowSizeChange(); SetOverlayManagerOptions(const OverlayManagerInfo & overlayInfo)687 bool SetOverlayManagerOptions(const OverlayManagerInfo& overlayInfo) 688 { 689 if (overlayInfo_.has_value()) { 690 return false; 691 } 692 overlayInfo_ = overlayInfo; 693 return true; 694 } GetOverlayManagerOptions()695 std::optional<OverlayManagerInfo> GetOverlayManagerOptions() 696 { 697 return overlayInfo_; 698 } 699 700 RefPtr<FrameNode> GetDialogNodeWithExistContent(const RefPtr<UINode>& node); 701 OffsetF CalculateMenuPosition(const RefPtr<FrameNode>& menuWrapperNode, const OffsetF& offset); 702 BorderRadiusProperty GetPrepareDragFrameNodeBorderRadius() const; 703 static SafeAreaInsets GetSafeAreaInsets(const RefPtr<FrameNode>& frameNode, bool useCurrentWindow = false); 704 RefPtr<FrameNode> GetLastChildNotRemoving(const RefPtr<UINode>& rootNode); 705 bool IsCurrentNodeProcessRemoveOverlay(const RefPtr<FrameNode>& currentNode, bool skipModal); 706 static Rect GetDisplayAvailableRect(const RefPtr<FrameNode>& frameNode); 707 void SkipMenuShow(int32_t targetId); 708 void ResumeMenuShow(int32_t targetId); 709 bool CheckSkipMenuShow(int32_t targetId); 710 711 private: 712 void OnBindSheetInner(std::function<void(const std::string&)>&& callback, 713 const RefPtr<UINode>& sheetContentNode, std::function<RefPtr<UINode>()>&& buildtitleNodeFunc, 714 NG::SheetStyle& sheetStyle, std::function<void()>&& onAppear, std::function<void()>&& onDisappear, 715 std::function<void()>&& shouldDismiss, std::function<void(const int32_t)>&& onWillDismiss, 716 std::function<void()>&& onWillAppear, std::function<void()>&& onWillDisappear, 717 std::function<void(const float)>&& onHeightDidChange, std::function<void(const float)>&& onDetentsDidChange, 718 std::function<void(const float)>&& onWidthDidChange, 719 std::function<void(const float)>&& onTypeDidChange, 720 std::function<void()>&& sheetSpringBack, const RefPtr<FrameNode>& targetNode, bool isStartByUIContext = false); 721 void SetSheetProperty( 722 const RefPtr<FrameNode>& sheetPageNode, 723 NG::SheetStyle& sheetStyle, std::function<void()>&& onAppear, std::function<void()>&& onDisappear, 724 std::function<void()>&& shouldDismiss, std::function<void(const int32_t)>&& onWillDismiss, 725 std::function<void()>&& onWillAppear, std::function<void()>&& onWillDisappear, 726 std::function<void(const float)>&& onHeightDidChange, std::function<void(const float)>&& onDetentsDidChange, 727 std::function<void(const float)>&& onWidthDidChange, 728 std::function<void(const float)>&& onTypeDidChange, 729 std::function<void()>&& sheetSpringBack); 730 void SaveSheetPageNode( 731 const RefPtr<FrameNode>& sheetPageNode, const RefPtr<UINode>& sheetContentNode, 732 const RefPtr<FrameNode>& targetNode, bool isStartByUIContext); 733 bool CheckTargetIdIsValid(int32_t targetId); 734 void UpdateSheetRender(const RefPtr<FrameNode>& sheetPageNode, NG::SheetStyle& sheetStyle, bool isPartialUpdate); 735 void UpdateSheetPage(const RefPtr<FrameNode>& sheetNode, NG::SheetStyle& sheetStyle, 736 int32_t targetId, bool isStartByUIContext = false, bool isPartialUpdate = false, 737 std::function<void()>&& onAppear = nullptr, std::function<void()>&& onDisappear = nullptr, 738 std::function<void()>&& shouldDismiss = nullptr, std::function<void(const int32_t)>&& onWillDismiss = nullptr, 739 std::function<void()>&& onWillDisappear = nullptr, 740 std::function<void(const float)>&& onHeightDidChange = nullptr, 741 std::function<void(const float)>&& onDetentsDidChange = nullptr, 742 std::function<void(const float)>&& onWidthDidChange = nullptr, 743 std::function<void(const float)>&& onTypeDidChange = nullptr, 744 std::function<void()>&& sheetSpringBack = nullptr); 745 SheetStyle UpdateSheetStyle( 746 const RefPtr<FrameNode>& sheetNode, const SheetStyle& sheetStyle, bool isPartialUpdate); 747 void UpdateSheetProperty(const RefPtr<FrameNode>& sheetNode, NG::SheetStyle& currentStyle, bool isPartialUpdate); 748 void UpdateSheetMaskBackgroundColor(const RefPtr<FrameNode>& maskNode, 749 const RefPtr<RenderContext>& maskRenderContext, const SheetStyle& sheetStyle); 750 void UpdateSheetMask(const RefPtr<FrameNode>& maskNode, 751 const RefPtr<FrameNode>& sheetNode, const SheetStyle& sheetStyle, bool isPartialUpdate = false); CleanViewContextMap(int32_t instanceId,int32_t sheetContentId)752 void CleanViewContextMap(int32_t instanceId, int32_t sheetContentId) 753 { 754 if (cleanViewContextMapCallback_) { 755 cleanViewContextMapCallback_(instanceId, sheetContentId); 756 } 757 } 758 void CleanInvalidModalNode(const WeakPtr<FrameNode>& invalidNode); 759 void PopToast(int32_t targetId); 760 761 // toast should contain id to avoid multiple delete. 762 std::unordered_map<int32_t, WeakPtr<FrameNode>> toastMap_; 763 764 /** find/register menu node and update menu's display position 765 * 766 * @return true if process is successful 767 */ 768 bool ShowMenuHelper(RefPtr<FrameNode>& menu, int32_t targetId, const NG::OffsetF& offset); 769 void ResetMenuWrapperVisibility(const RefPtr<FrameNode>& menuWrapper); 770 // The focus logic of overlay node (menu and dialog): 771 // 1. before start show animation: lower level node set unfocusabel and lost focus; 772 // 2. end show animation: overlay node get focus; 773 // 3. before start hide animation: lower level node set focusable; 774 // 4. end hide animation: overlay node lost focus, lower level node get focus. 775 void FocusOverlayNode(const RefPtr<FrameNode>& overlayNode, bool isInSubWindow = false); 776 void BlurOverlayNode(const RefPtr<FrameNode>& currentOverlay, bool isInSubWindow = false); 777 void BlurLowerNode(const RefPtr<FrameNode>& currentOverlay); 778 void ResetLowerNodeFocusable(const RefPtr<FrameNode>& currentOverlay); 779 void PostDialogFinishEvent(const WeakPtr<FrameNode>& nodeWk); 780 void OnDialogCloseEvent(const RefPtr<FrameNode>& node); 781 782 void CloseDialogInner(const RefPtr<FrameNode>& dialogNode); 783 784 void SetPreviewFirstShow(const RefPtr<FrameNode>& menu); 785 void ShowMenuAnimation(const RefPtr<FrameNode>& menu); 786 void SetPatternFirstShow(const RefPtr<FrameNode>& menu); 787 void PopMenuAnimation(const RefPtr<FrameNode>& menu, bool showPreviewAnimation = true, bool startDrag = false); 788 void ShowMenuDisappearTransition(const RefPtr<FrameNode>& menu); 789 void ShowMenuClearAnimation(const RefPtr<FrameNode>& menuWrapper, AnimationOption& option, 790 bool showPreviewAnimation, bool startDrag); 791 bool IsContextMenuBindedOnOrigNode(); 792 void OpenDialogAnimationInner(const RefPtr<FrameNode>& node, const DialogProperties& dialogProps); 793 void OpenDialogAnimation(const RefPtr<FrameNode>& node, const DialogProperties& dialogProps); 794 void CloseDialogAnimation(const RefPtr<FrameNode>& node); 795 void SetDialogTransitionEffect(const RefPtr<FrameNode>& node, const DialogProperties& dialogProps); 796 void CloseDialogMatchTransition(const RefPtr<FrameNode>& node); 797 void SetContainerButtonEnable(bool isEnabled); 798 799 void SaveLastModalNode(); 800 void PlayTransitionEffectIn(const RefPtr<FrameNode>& topModalNode); 801 void PlayTransitionEffectOut(const RefPtr<FrameNode>& topModalNode); 802 void PlayDefaultModalTransition(const RefPtr<FrameNode>& modalNode, bool isTransitionIn); 803 void DefaultModalTransition(bool isTransitionIn); 804 void PlayAlphaModalTransition(const RefPtr<FrameNode>& modalNode, bool isTransitionIn); 805 void FireModalPageShow(); 806 void FireModalPageHide(); 807 808 void SetSheetBackgroundBlurStyle(const RefPtr<FrameNode>& sheetNode, const BlurStyleOption& bgBlurStyle); 809 void SetSheetBackgroundColor(const RefPtr<FrameNode>& sheetNode, const RefPtr<SheetTheme>& sheetTheme, 810 const NG::SheetStyle& sheetStyle, bool isPartialUpdate = false); 811 812 bool ModalExitProcess(const RefPtr<FrameNode>& topModalNode); 813 bool ModalPageExitProcess(const RefPtr<FrameNode>& topModalNode); 814 bool SheetPageExitProcess(const RefPtr<FrameNode>& topModalNode); 815 816 void BeforeShowDialog(const RefPtr<FrameNode>& dialogNode); 817 void PutLevelOrder(const RefPtr<FrameNode>& node, std::optional<double> levelOrder); 818 void PopLevelOrder(const RefPtr<FrameNode>& node); 819 RefPtr<FrameNode> GetPrevNodeWithOrder(std::optional<double> levelOrder); 820 RefPtr<FrameNode> GetPrevOverlayNodeWithOrder(std::optional<double> levelOrder); 821 RefPtr<FrameNode> GetBottomOrderFirstNode(std::optional<double> levelOrder); 822 RefPtr<FrameNode> GetBottomOrderFirstOverlayNode(std::optional<double> levelOrder); 823 bool IsNeedChangeFocus(std::optional<double> levelOrder, bool focusable = true); 824 void RemoveDialogFromMap(const RefPtr<FrameNode>& node); 825 void RemoveMaskFromMap(const RefPtr<FrameNode>& dialogNode); 826 bool DialogInMapHoldingFocus(); 827 void PlayKeyboardTransition(const RefPtr<FrameNode>& customKeyboard, bool isTransitionIn); 828 void FireNavigationStateChange(bool show, const RefPtr<UINode>& node = nullptr); 829 RefPtr<FrameNode> GetModalNodeInStack(std::stack<WeakPtr<FrameNode>>& stack); 830 void PlayBubbleStyleSheetTransition(RefPtr<FrameNode> sheetNode, bool isTransitionIn); 831 void CheckReturnFocus(RefPtr<FrameNode> node); 832 void MountPopup(int32_t targetId, const PopupInfo& popupInfo, 833 const std::function<void(int32_t)>&& onWillDismiss = nullptr, bool interactiveDismiss = true); 834 bool IsContentUpdatePopup(const RefPtr<Pattern>& pattern); 835 836 int32_t GetPopupIdByNode(const RefPtr<FrameNode>& overlay); 837 bool PopupInteractiveDismiss(const RefPtr<FrameNode>& overlay); 838 bool PopupCallBackOnWillDismiss(const RefPtr<FrameNode>& overlay); 839 bool RemovePopupInSubwindow(const RefPtr<Pattern>& pattern, const RefPtr<FrameNode>& overlay, 840 const RefPtr<UINode>& rootNode); 841 bool UpdatePopupMap(int32_t targetId, const PopupInfo& popupInfo); 842 void UpdateTipsInfo(int32_t targetId, const PopupInfo& popupInfo); 843 void PlayDefaultModalIn(const RefPtr<FrameNode>& modalNode, const RefPtr<RenderContext>& context, 844 AnimationOption option, float showHeight); 845 void PlayDefaultModalOut(const RefPtr<FrameNode>& modalNode, const RefPtr<RenderContext>& context, 846 AnimationOption option, float showHeight); 847 void OpenToastAnimation(const RefPtr<FrameNode>& toastNode, int32_t duration); 848 void OnShowMenuAnimationFinished(const WeakPtr<FrameNode> menuWK, const WeakPtr<OverlayManager> weak, 849 int32_t instanceId); 850 void OnPopMenuAnimationFinished(const WeakPtr<FrameNode> menuWK, const WeakPtr<UINode> rootWeak, 851 const WeakPtr<OverlayManager> weak, int32_t instanceId); 852 void UpdateMenuVisibility(const RefPtr<FrameNode>& menu); 853 void RemoveMenuNotInSubWindow( 854 const WeakPtr<FrameNode>& menuWK, const WeakPtr<UINode>& rootWeak, const WeakPtr<OverlayManager>& overlayWeak); 855 bool CreateSheetKey(const RefPtr<NG::FrameNode>& sheetContentNode, int32_t targetId, 856 SheetKey& sheetKey); 857 858 bool CheckTopModalNode(const RefPtr<FrameNode>& topModalNode, int32_t targetId); 859 void HandleModalShow(std::function<void(const std::string&)>&& callback, 860 std::function<RefPtr<UINode>()>&& buildNodeFunc, NG::ModalStyle& modalStyle, std::function<void()>&& onAppear, 861 std::function<void()>&& onDisappear, std::function<void()>&& onWillDisappear, const RefPtr<UINode> rootNode, 862 const NG::ContentCoverParam& contentCoverParam, int32_t targetId, 863 std::optional<ModalTransition> modalTransition); 864 void HandleModalPop(std::function<void()>&& onWillDisappear, const RefPtr<UINode> rootNode, int32_t targetId); 865 866 int32_t ExceptComponent(const RefPtr<NG::UINode>& rootNode, RefPtr<NG::FrameNode>& overlay, 867 bool isBackPressed, bool isPageRouter); 868 void OverlayDoDismiss(RefPtr<NG::FrameNode>& overlay, RefPtr<Pattern>& pattern); 869 int32_t RemoveOverlayCommon(const RefPtr<NG::UINode>& rootNode, RefPtr<NG::FrameNode>& overlay, 870 RefPtr<Pattern>& pattern, bool isBackPressed, bool isPageRouter); 871 int32_t WebBackward(RefPtr<NG::FrameNode>& overlay); 872 void FindWebNode(const RefPtr<NG::UINode>& node, RefPtr<NG::FrameNode>& webNode, bool& isNavDestination); 873 874 void RegisterDialogLifeCycleCallback(const RefPtr<FrameNode>& dialog, const DialogProperties& dialogProps); 875 void CustomDialogRecordEvent(const DialogProperties& dialogProps); 876 RefPtr<UINode> RebuildCustomBuilder(RefPtr<UINode>& contentNode); 877 void OpenCustomDialogInner(const DialogProperties& dialogProps, std::function<void(int32_t)> &&callback, 878 const RefPtr<FrameNode> dialog, bool showComponentContent); 879 880 void DumpPopupMapInfo() const; 881 void DumpMapInfo( 882 std::unordered_map<int32_t, RefPtr<FrameNode>> map, const std::string mapName, bool hasTarget = true) const; 883 void DumpMapInfo( 884 std::unordered_map<int32_t, WeakPtr<FrameNode>> map, const std::string mapName, bool hasTarget = true) const; 885 void DumpSheetMapInfo(const std::unordered_map<SheetKey, WeakPtr<FrameNode>, SheetKeyHash>& map, 886 const std::string mapName) const; 887 void DumpMaskNodeIdMapInfo() const; 888 void DumpModalListInfo() const; 889 void DumpEntry(const RefPtr<FrameNode>& targetNode, int32_t targetId, const RefPtr<FrameNode>& node) const; 890 std::string GetMapNodeLog(const RefPtr<FrameNode>& node, bool hasTarget = true) const; 891 RefPtr<UINode> FindChildNodeByKey(const RefPtr<NG::UINode>& parentNode, const std::string& key); 892 bool SetNodeBeforeAppbar(const RefPtr<NG::UINode>& rootNode, const RefPtr<FrameNode>& node, 893 std::optional<double> levelOrder = std::nullopt); 894 RefPtr<FrameNode> GetOverlayFrameNode(); 895 void RemoveChildWithService(const RefPtr<UINode>& rootNode, const RefPtr<FrameNode>& node); 896 CustomKeyboardOffsetInfo CalcCustomKeyboardOffset(const RefPtr<FrameNode>& customKeyboard); 897 void SendToAccessibility(const WeakPtr<FrameNode> node, bool isShow); 898 void RemoveMenuWrapperNode(const RefPtr<UINode>& rootNode); 899 void SetDragNodeNeedClean(); 900 void MountCustomKeyboard(const RefPtr<FrameNode>& customKeyboard, int32_t targetId); 901 void FireNavigationLifecycle(const RefPtr<UINode>& uiNode, int32_t lifecycleId, bool isLowerOnly, int32_t reason); 902 int32_t RemoveOverlayManagerNode(); 903 RefPtr<FrameNode> overlayNode_; 904 // Key: frameNode Id, Value: index 905 std::unordered_map<int32_t, int32_t> frameNodeMapOnOverlay_; 906 // Key: target Id, Value: PopupInfo 907 std::unordered_map<int32_t, NG::PopupInfo> popupMap_; 908 std::unordered_map<int32_t, std::list<std::pair<int32_t, bool>>> tipsEnterAndLeaveInfoMap_; 909 std::list<std::pair<int32_t, NG::PopupInfo>> tipsInfoList_; 910 // K: target frameNode ID, V: menuNode 911 std::unordered_map<int32_t, RefPtr<FrameNode>> menuMap_; 912 std::unordered_map<int32_t, RefPtr<FrameNode>> dialogMap_; 913 std::unordered_map<int32_t, double> dialogOrderMap_; 914 std::map<double, std::vector<RefPtr<FrameNode>>> dialogLevelOrderMap_; 915 std::unordered_map<int32_t, RefPtr<FrameNode>> customPopupMap_; 916 std::unordered_map<int32_t, RefPtr<FrameNode>> customKeyboardMap_; 917 std::stack<WeakPtr<FrameNode>> modalStack_; 918 std::list<WeakPtr<FrameNode>> modalList_; 919 std::unordered_map<SheetKey, WeakPtr<FrameNode>, SheetKeyHash> sheetMap_; 920 std::function<void(const int32_t, const int32_t)> cleanViewContextMapCallback_ = nullptr; 921 std::unordered_map<int32_t, RefPtr<NG::ClickEvent>> sheetMaskClickEventMap_; // Key: maskNodeId 922 WeakPtr<FrameNode> lastModalNode_; // Previous Modal Node 923 float sheetHeight_ { 0.0 }; 924 WeakPtr<UINode> rootNodeWeak_; 925 int32_t dialogCount_ = 0; 926 DismissTarget dismissTarget_; 927 int32_t dismissSheetId_ = 0; 928 int32_t dismissDialogId_ = 0; 929 std::unordered_map<int32_t, int32_t> maskNodeIdMap_; 930 int32_t subWindowId_ = -1; 931 bool hasPixelMap_ { false }; 932 bool hasDragPixelMap_ { false }; 933 bool hasFilter_ { false }; 934 bool hasEvent_ { false }; 935 bool isOnAnimation_ { false }; 936 WeakPtr<FrameNode> pixmapColumnNodeWeak_; 937 WeakPtr<FrameNode> dragPixmapColumnNodeWeak_; 938 WeakPtr<FrameNode> filterColumnNodeWeak_; 939 WeakPtr<FrameNode> eventColumnNodeWeak_; 940 bool isContextMenuDragHideFinished_ = false; 941 OffsetF dragMoveVector_ = OffsetF(0.0f, 0.0f); 942 OffsetF lastDragMoveVector_ = OffsetF(0.0f, 0.0f); 943 944 std::function<void()> onHideDialogCallback_ = nullptr; 945 CancelableCallback<void()> continuousTask_; 946 std::function<bool()> backPressEvent_ = nullptr; 947 948 std::set<WeakPtr<UINode>> windowSceneSet_; 949 950 RefPtr<NG::ClickEvent> sheetMaskClickEvent_; 951 RefPtr<GroupManager> groupManager_ = MakeRefPtr<GroupManager>(); 952 953 // native modal ui extension 954 bool isProhibitBack_ = false; 955 956 std::unordered_map<int32_t, WeakPtr<FrameNode>> uiExtNodes_; 957 bool keyboardAvoidance_ = false; 958 ACE_DISALLOW_COPY_AND_MOVE(OverlayManager); 959 960 bool hasFilterActived {false}; 961 962 int32_t dismissPopupId_ = 0; 963 964 bool hasGatherNode_ { false }; 965 bool isGatherWithMenu_ { false }; 966 WeakPtr<FrameNode> gatherNodeWeak_; 967 WeakPtr<FrameNode> dragNodeCopyWeak_; 968 std::vector<GatherNodeChildInfo> gatherNodeChildrenInfo_; 969 bool isMenuShow_ = false; 970 bool isAttachToCustomNode_ = false; 971 972 // Only used when CreateModalUIExtension 973 // No thread safety issue due to they are all run in UI thread 974 bool isAllowedBeCovered_ = true; 975 // Only hasValue when isAllowedBeCovered is false 976 std::set<int32_t> curSessionIds_; 977 std::set<int32_t> skipTargetIds_; 978 std::optional<OverlayManagerInfo> overlayInfo_; 979 }; 980 } // namespace OHOS::Ace::NG 981 982 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OVERLAY_OVERLAY_MANAGER_H 983