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_STEPPER_STEPPER_ITEM_COMPONENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_STEPPER_STEPPER_ITEM_COMPONENT_H
18 
19 #include "core/pipeline/base/constants.h"
20 #include "core/pipeline/base/element.h"
21 #include "core/pipeline/base/render_node.h"
22 #include "core/pipeline/base/sole_child_component.h"
23 
24 namespace OHOS::Ace {
25 
26 struct StepperLabels {
27     std::string leftLabel;
28     std::string rightLabel;
29     std::string initialStatus;
30 };
31 
32 class ACE_EXPORT StepperItemComponent : public SoleChildComponent {
33     DECLARE_ACE_TYPE(StepperItemComponent, SoleChildComponent);
34 
35 public:
StepperItemComponent(const RefPtr<Component> & child)36     explicit StepperItemComponent(const RefPtr<Component>& child) : SoleChildComponent(child) {}
37     ~StepperItemComponent() override = default;
38     static RefPtr<StepperItemComponent> GetStepperItem(const RefPtr<Component>& component);
39 
40     RefPtr<Element> CreateElement() override;
41     RefPtr<RenderNode> CreateRenderNode() override;
42 
SetIndex(int32_t index)43     void SetIndex(int32_t index)
44     {
45         index_ = index;
46     }
47 
GetIndex()48     int32_t GetIndex() const
49     {
50         return index_;
51     }
52 
SetFocusAnimationColor(const Color & color)53     void SetFocusAnimationColor(const Color& color)
54     {
55         focusAnimationColor_ = color;
56     }
57 
GetFocusAnimationColor()58     const Color& GetFocusAnimationColor() const
59     {
60         return focusAnimationColor_;
61     }
62 
SetAppearEventId(const EventMarker & appearEventId)63     void SetAppearEventId(const EventMarker& appearEventId)
64     {
65         appearEventId_ = appearEventId;
66     }
67 
GetAppearEventId()68     const EventMarker& GetAppearEventId() const
69     {
70         return appearEventId_;
71     }
72 
SetDisappearEventId(const EventMarker & disappearEventId)73     void SetDisappearEventId(const EventMarker& disappearEventId)
74     {
75         disappearEventId_ = disappearEventId;
76     }
77 
GetDisappearEventId()78     const EventMarker& GetDisappearEventId() const
79     {
80         return disappearEventId_;
81     }
82 
SetTextStyle(const TextStyle & textStyle)83     void SetTextStyle(const TextStyle& textStyle)
84     {
85         textStyle_ = textStyle;
86     }
87 
GetTextStyle()88     const TextStyle& GetTextStyle() const
89     {
90         return textStyle_;
91     }
92 
SetLabel(const StepperLabels & label)93     void SetLabel(const StepperLabels& label)
94     {
95         label_ = label;
96     }
97 
GetLabel()98     const StepperLabels& GetLabel() const
99     {
100         return label_;
101     }
102 
103 private:
104     int32_t index_ = -1;
105     TextStyle textStyle_;
106     StepperLabels label_;
107     Color focusAnimationColor_ = Color::WHITE;
108     EventMarker appearEventId_;
109     EventMarker disappearEventId_;
110 };
111 
112 } // namespace OHOS::Ace
113 
114 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_STEPPER_STEPPER_ITEM_COMPONENT_H
115