• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 COMPONENT_EXT_ARC_SWIPER_ARC_SWIPER_INDICATOR_H
17 #define COMPONENT_EXT_ARC_SWIPER_ARC_SWIPER_INDICATOR_H
18 
19 #include <optional>
20 
21 #include "base/memory/ace_type.h"
22 #include "core/components_ng/pattern/swiper/swiper_model.h"
23 #include "core/components_ng/property/gradient_property.h"
24 
25 namespace OHOS::Ace::NG {
26 
27 class JsArcSwiperIndicator : public virtual AceType {
28     DECLARE_ACE_TYPE(JsArcSwiperIndicator, AceType);
29 
30 public:
31     JsArcSwiperIndicator() = default;
32     ~JsArcSwiperIndicator() override = default;
33 
SetArcDirection(SwiperArcDirection direction)34     void SetArcDirection(SwiperArcDirection direction)
35     {
36         arcDirection_ = direction;
37     }
38 
GetArcDirection()39     SwiperArcDirection GetArcDirection() const
40     {
41         return arcDirection_.value();
42     }
43 
HasArcDirection()44     bool HasArcDirection() const
45     {
46         return arcDirection_.has_value();
47     }
48 
SetItemColor(const Color & color)49     void SetItemColor(const Color& color)
50     {
51         itemColor_ = color;
52     }
53 
ResetItemColor()54     void ResetItemColor()
55     {
56         itemColor_.reset();
57     }
58 
GetItemColor()59     const Color& GetItemColor() const
60     {
61         return itemColor_.value();
62     }
63 
HasItemColor()64     bool HasItemColor() const
65     {
66         return itemColor_.has_value();
67     }
68 
SetSelectedItemColor(const Color & color)69     void SetSelectedItemColor(const Color& color)
70     {
71         selectedItemColor_ = color;
72     }
73 
ResetSelectedItemColor()74     void ResetSelectedItemColor()
75     {
76         selectedItemColor_.reset();
77     }
78 
GetSelectedItemColor()79     const Color& GetSelectedItemColor() const
80     {
81         return selectedItemColor_.value();
82     }
83 
HasSelectedItemColor()84     bool HasSelectedItemColor() const
85     {
86         return selectedItemColor_.has_value();
87     }
88 
SetContainerColor(const Color & color)89     void SetContainerColor(const Color& color)
90     {
91         containerColor_ = color;
92     }
93 
ResetContainerColor()94     void ResetContainerColor()
95     {
96         containerColor_.reset();
97     }
98 
GetContainerColor()99     const Color& GetContainerColor() const
100     {
101         return containerColor_.value();
102     }
103 
HasContainerColor()104     bool HasContainerColor() const
105     {
106         return containerColor_.has_value();
107     }
108 
SetMaskColor(const NG::Gradient & GradientColor)109     void SetMaskColor(const NG::Gradient& GradientColor)
110     {
111         maskLinearGradientColor_ = GradientColor;
112     }
113 
ResetMaskColor()114     void ResetMaskColor()
115     {
116         maskLinearGradientColor_.reset();
117     }
118 
GetMaskColor()119     const NG::Gradient& GetMaskColor() const
120     {
121         return maskLinearGradientColor_.value();
122     }
123 
HasMaskColor()124     bool HasMaskColor() const
125     {
126         return maskLinearGradientColor_.has_value();
127     }
128 
129 private:
130     std::optional<SwiperArcDirection> arcDirection_;
131     std::optional<Color> itemColor_;
132     std::optional<Color> selectedItemColor_;
133     std::optional<Color> containerColor_;
134     std::optional<NG::Gradient> maskLinearGradientColor_;
135 
136     ACE_DISALLOW_COPY_AND_MOVE(JsArcSwiperIndicator);
137 };
138 
139 } // namespace OHOS::Ace::NG
140 
141 #endif // COMPONENT_EXT_ARC_SWIPER_ARC_SWIPER_INDICATOR_H