• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_SHEET_SHEET_MASK_PATTERN_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SHEET_SHEET_MASK_PATTERN_H
18 
19 #include "core/common/ace_engine.h"
20 #include "core/components_ng/pattern/navrouter/navdestination_pattern.h"
21 #include "core/components_ng/pattern/overlay/popup_base_pattern.h"
22 #include "core/components_ng/pattern/overlay/sheet_presentation_pattern.h"
23 #include "core/components_ng/pattern/overlay/sheet_wrapper_layout_algorithm.h"
24 #include "core/components_ng/pattern/overlay/sheet_wrapper_paint_method.h"
25 
26 namespace OHOS::Ace::NG {
27 class SheetMaskPattern : virtual public PopupBasePattern {
28     DECLARE_ACE_TYPE(SheetMaskPattern, PopupBasePattern);
29 
30 public:
31     SheetMaskPattern() = default;
32 
SheetMaskPattern(int32_t targetId,const std::string & targetTag)33     SheetMaskPattern(int32_t targetId, const std::string& targetTag) : targetId_(targetId), targetTag_(targetTag) {}
34 
35     ~SheetMaskPattern() override = default;
36 
GetFocusPattern()37     FocusPattern GetFocusPattern() const override
38     {
39         return { FocusType::SCOPE, true };
40     }
GetTargetNode()41     RefPtr<FrameNode> GetTargetNode() const
42     {
43         return FrameNode::GetFrameNode(targetTag_, targetId_);
44     }
45 
OnAttachToFrameNode()46     void OnAttachToFrameNode() override
47     {
48         auto host = GetHost();
49         CHECK_NULL_VOID(host);
50         auto maskLayoutProps = host->GetLayoutProperty();
51         CHECK_NULL_VOID(maskLayoutProps);
52         maskLayoutProps->UpdateMeasureType(MeasureType::MATCH_PARENT);
53         maskLayoutProps->UpdateAlignment(Alignment::TOP_LEFT);
54         auto maskRenderContext = host->GetRenderContext();
55         CHECK_NULL_VOID(maskRenderContext);
56         maskRenderContext->UpdateClipEdge(true);
57     }
58 
GetIsMaskInteractive()59     bool GetIsMaskInteractive() const
60     {
61         return isMaskInteractive_;
62     }
63 
SetIsMaskInteractive(bool IsInteractive)64     void SetIsMaskInteractive(bool IsInteractive)
65     {
66         isMaskInteractive_ = IsInteractive;
67     }
68 
69 protected:
AvoidKeyboard()70     bool AvoidKeyboard() const override
71     {
72         return false;
73     }
74 
AvoidBottom()75     bool AvoidBottom() const override
76     {
77         return false;
78     }
79 
80 private:
81     int32_t targetId_ = -1;
82     std::string targetTag_;
83     bool isMaskInteractive_ = true;
84 
85     ACE_DISALLOW_COPY_AND_MOVE(SheetMaskPattern);
86 };
87 } // namespace OHOS::Ace::NG
88 
89 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OVERLAY_SHEET_WRAPPER_PATTERN_H
90