1 /* 2 * Copyright (c) 2022 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_CONTAINER_MODAL_CONTAINER_MODAL_COMPONENT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CONTAINER_MODAL_CONTAINER_MODAL_COMPONENT_H 18 19 #include "core/components/button/button_component.h" 20 #include "core/components/flex/flex_component.h" 21 #include "core/components/image/image_component.h" 22 #include "core/components/text/text_component.h" 23 #include "core/pipeline/base/sole_child_component.h" 24 25 namespace OHOS::Ace { 26 27 class ContainerModalComponent : public SoleChildComponent { 28 DECLARE_ACE_TYPE(ContainerModalComponent, SoleChildComponent); 29 30 public: ContainerModalComponent(const WeakPtr<PipelineContext> & context)31 explicit ContainerModalComponent(const WeakPtr<PipelineContext>& context) 32 { 33 context_ = context; 34 auto pipelineContext = context_.Upgrade(); 35 if (pipelineContext) { 36 isDeclarative_ = pipelineContext->GetIsDeclarative(); 37 } 38 } 39 40 ~ContainerModalComponent() override = default; 41 static RefPtr<Component> Create(const WeakPtr<PipelineContext>& context, const RefPtr<Component>& child); 42 RefPtr<Element> CreateElement() override; 43 RefPtr<RenderNode> CreateRenderNode() override; 44 void BuildInnerChild(); 45 std::list<RefPtr<Component>> BuildTitleChildren(bool isFloating, bool isFocus = true, bool isFullWindow = true); 46 GetTitleIcon()47 RefPtr<ImageComponent> GetTitleIcon() const 48 { 49 return titleIcon_; 50 } 51 GetTitleLabel()52 RefPtr<TextComponent> GetTitleLabel() const 53 { 54 return titleLabel_; 55 } 56 SetTitleButtonHide(bool hideSplit,bool hideMaximize,bool hideMinimize)57 void SetTitleButtonHide(bool hideSplit, bool hideMaximize, bool hideMinimize) 58 { 59 hideSplit_ = hideSplit; 60 hideMaximize_ = hideMaximize; 61 hideMinimize_ = hideMinimize; 62 } 63 GetSplitButtonHide()64 bool GetSplitButtonHide() const 65 { 66 return hideSplit_; 67 } 68 69 private: 70 RefPtr<Component> BuildTitle(); 71 RefPtr<Component> BuildFloatingTitle(); 72 RefPtr<Component> BuildContent(); 73 RefPtr<Component> BuildControlButton( 74 InternalResource::ResourceId icon, std::function<void()>&& clickCallback, bool isFocus, bool isFloating); 75 void CreateAccessibilityNode(const std::string& tag, int32_t nodeId, int32_t parentNodeId); 76 static RefPtr<Component> SetPadding( 77 const RefPtr<Component>& component, const Dimension& leftPadding, const Dimension& rightPadding); 78 79 WeakPtr<PipelineContext> context_; 80 RefPtr<ImageComponent> titleIcon_; 81 RefPtr<TextComponent> titleLabel_; 82 bool isDeclarative_ = true; 83 bool hideSplit_ = false; 84 bool hideMaximize_ = false; 85 bool hideMinimize_ = false; 86 }; 87 88 } // namespace OHOS::Ace 89 90 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CONTAINER_MODAL_CONTAINER_MODAL_COMPONENT_H 91