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 ContainerModalComponent(const WeakPtr<PipelineContext>& context) 32 { 33 context_ = context; 34 } 35 36 ~ContainerModalComponent() override = default; 37 static RefPtr<Component> Create(const WeakPtr<PipelineContext>& context, const RefPtr<Component>& child); 38 RefPtr<Element> CreateElement() override; 39 RefPtr<RenderNode> CreateRenderNode() override; 40 void BuildInnerChild(); 41 GetTitleIcon()42 RefPtr<ImageComponent> GetTitleIcon() const 43 { 44 return titleIcon_; 45 } 46 GetTitleLabel()47 RefPtr<TextComponent> GetTitleLabel() const 48 { 49 return titleLabel_; 50 } 51 GetTitleChildrenRow()52 RefPtr<RowComponent> GetTitleChildrenRow() const 53 { 54 return titleChildrenRow_; 55 } 56 GetFloatingTitleChildrenRow()57 RefPtr<RowComponent> GetFloatingTitleChildrenRow() const 58 { 59 return floatingTitleChildrenRow_; 60 } 61 62 private: 63 RefPtr<Component> BuildTitle(); 64 RefPtr<Component> BuildFloatingTitle(); 65 RefPtr<Component> BuildContent(); 66 RefPtr<ButtonComponent> BuildControlButton( 67 InternalResource::ResourceId icon, std::function<void()>&& clickCallback); 68 std::list<RefPtr<Component>> BuildTitleChildren(bool isFloating); 69 static RefPtr<Component> SetPadding( 70 const RefPtr<Component>& component, const Dimension& leftPadding, const Dimension& rightPadding); 71 72 WeakPtr<PipelineContext> context_; 73 RefPtr<ImageComponent> titleIcon_; 74 RefPtr<TextComponent> titleLabel_; 75 RefPtr<RowComponent> titleChildrenRow_; 76 RefPtr<RowComponent> floatingTitleChildrenRow_; 77 }; 78 79 } // namespace OHOS::Ace 80 81 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CONTAINER_MODAL_CONTAINER_MODAL_COMPONENT_H 82