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_PATTERN_OVERLAY_POPUP_PATTERN_BASE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_OVERLAY_POPUP_PATTERN_BASE_H 18 19 #include "base/utils/noncopyable.h" 20 #include "core/components_ng/pattern/stage/content_root_pattern.h" 21 namespace OHOS::Ace::NG { 22 // base class of all Popup patterns (Dialog, Toast, Menu, Bubble, etc.) 23 class PopupBasePattern : virtual public ContentRootPattern { 24 DECLARE_ACE_TYPE(PopupBasePattern, ContentRootPattern); 25 26 public: 27 PopupBasePattern() = default; 28 ~PopupBasePattern() override = default; 29 SetContainerId(int32_t containerId)30 void SetContainerId(int32_t containerId) 31 { 32 containerId_ = containerId; 33 } 34 GetContainerId()35 int32_t GetContainerId() const 36 { 37 return containerId_; 38 } 39 GetTargetId()40 virtual int32_t GetTargetId() const 41 { 42 return -1; 43 } 44 45 protected: AvoidKeyboard()46 bool AvoidKeyboard() const override 47 { 48 return true; 49 } 50 AvoidTop()51 bool AvoidTop() const override 52 { 53 // popups don't need to avoid status bar 54 return false; 55 } 56 AvoidBottom()57 bool AvoidBottom() const override 58 { 59 return true; 60 } 61 AvoidCutout()62 bool AvoidCutout() const override 63 { 64 return false; 65 } 66 67 private: 68 // record node in which container. 69 int32_t containerId_ = -1; 70 71 ACE_DISALLOW_COPY_AND_MOVE(PopupBasePattern); 72 }; 73 } // namespace OHOS::Ace::NG 74 75 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_OVERLAY_POPUP_PATTERN_BASE_H 76