1 /*
2  * Copyright (c) 2021 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_TAB_BAR_TAB_BAR_INDICATOR_COMPONENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TAB_BAR_TAB_BAR_INDICATOR_COMPONENT_H
18 
19 #include "core/components/box/box_component.h"
20 
21 namespace OHOS::Ace {
22 
23 inline const Dimension DEFAULT_INDICATOR_WIDTH = Dimension(2.0, DimensionUnit::VP);
24 inline const Color DEFAULT_INDICATOR_COLOR = Color(0xFF254ff7);
25 inline const Edge DEFAULT_INDICATOR_PADDING = Edge(0.0);
26 
27 enum class TabBarIndicatorStyle {
28     DEFAULT,
29     CUSTOM,
30 };
31 
32 class ACE_EXPORT TabBarIndicatorComponent : public BoxComponent {
33     DECLARE_ACE_TYPE(TabBarIndicatorComponent, BoxComponent);
34 
35 public:
36     explicit TabBarIndicatorComponent(const Edge& padding = DEFAULT_INDICATOR_PADDING,
37         const Color& color = DEFAULT_INDICATOR_COLOR, const Dimension& borderWidth = DEFAULT_INDICATOR_WIDTH);
38     explicit TabBarIndicatorComponent(const RefPtr<Decoration>& indicatorDecoration);
39     ~TabBarIndicatorComponent() override = default;
40 
GetIndicatorStyle()41     TabBarIndicatorStyle GetIndicatorStyle() const
42     {
43         return indicatorStyle_;
44     }
45 
GetIndicatorPadding()46     const Edge& GetIndicatorPadding() const
47     {
48         return indicatorPadding_;
49     }
50 
GetIndicatorColor()51     const Color& GetIndicatorColor() const
52     {
53         return indicatorColor_;
54     }
55 
GetIndicatorWidth()56     Dimension GetIndicatorWidth() const
57     {
58         return indicatorWidth_;
59     }
60 
GetIndicatorDecoration()61     const RefPtr<Decoration>& GetIndicatorDecoration() const
62     {
63         return indicatorDecoration_;
64     }
65 
66 private:
67     void Initialize();
68 
69     TabBarIndicatorStyle indicatorStyle_ { TabBarIndicatorStyle::DEFAULT };
70     Edge indicatorPadding_;
71     Color indicatorColor_ { DEFAULT_INDICATOR_COLOR };
72     Dimension indicatorWidth_ { DEFAULT_INDICATOR_WIDTH };
73     RefPtr<Decoration> indicatorDecoration_;
74 };
75 
76 } // namespace OHOS::Ace
77 
78 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TAB_BAR_TAB_BAR_INDICATOR_COMPONENT_H
79