1 /*
2  * Copyright (c) 2021-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_V2_TABS_TABS_COMPONENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_TABS_TABS_COMPONENT_H
18 
19 #include "core/components/tab_bar/tab_controller.h"
20 #include "core/pipeline/base/component_group.h"
21 #include "core/pipeline/base/element.h"
22 #include "core/pipeline/base/render_node.h"
23 #include "frameworks/core/components/flex/flex_component.h"
24 #include "frameworks/core/components/flex/flex_item_component.h"
25 #include "frameworks/core/components/tab_bar/tab_bar_component.h"
26 #include "frameworks/core/components/tab_bar/tab_content_component.h"
27 
28 namespace OHOS::Ace::V2 {
29 
30 class ACE_EXPORT TabsComponent : public FlexComponent {
31     DECLARE_ACE_TYPE(TabsComponent, FlexComponent);
32 
33 public:
34     explicit TabsComponent(std::list<RefPtr<Component>>& children, BarPosition barPosition = BarPosition::START,
35         const RefPtr<TabController>& controller = nullptr);
36     ~TabsComponent() override = default;
37 
38     RefPtr<Element> CreateElement() override;
39 
SetTabsController(const RefPtr<TabController> & controller)40     void SetTabsController(const RefPtr<TabController>& controller)
41     {
42         controller_ = controller;
43     }
44 
GetTabsController()45     RefPtr<TabController> GetTabsController() const
46     {
47         return controller_;
48     }
49 
GetTabContentChild()50     RefPtr<TabContentComponent> GetTabContentChild() const
51     {
52         return tabContent_;
53     }
54 
GetTabBarChild()55     RefPtr<TabBarComponent> GetTabBarChild() const
56     {
57         return tabBar_;
58     }
59 
60     void AppendChild(const RefPtr<Component>& child) override;
61 
62     void RemoveChild(const RefPtr<Component>& child) override;
63 
64 private:
65     std::list<RefPtr<Component>> tabContentChildren_;
66     std::list<RefPtr<Component>> tabBarChildren_;
67     RefPtr<TabController> controller_;
68     RefPtr<TabBarIndicatorComponent> tabBarIndicator_;
69     RefPtr<TabContentComponent> tabContent_;
70     RefPtr<TabBarComponent> tabBar_;
71     RefPtr<FlexItemComponent> flexItem_;
72 };
73 
74 } // namespace OHOS::Ace::V2
75 
76 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_TABS_TABS_COMPONENT_H
77