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_BRIDGE_COMMON_DOM_DOM_SLIDER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_BRIDGE_COMMON_DOM_DOM_SLIDER_H
18 
19 #include "core/components/padding/padding_component.h"
20 #include "core/components/slider/slider_component.h"
21 #include "core/components/track/track_component.h"
22 #include "core/components/watch_slider/watch_slider_component.h"
23 #include "frameworks/bridge/common/dom/dom_node.h"
24 
25 namespace OHOS::Ace::Framework {
26 
27 class DOMSlider final : public DOMNode {
28     DECLARE_ACE_TYPE(DOMSlider, DOMNode);
29 
30 public:
31     DOMSlider(NodeId nodeId, const std::string& nodeName);
32     ~DOMSlider() override = default;
33 
34     void InitializeStyle() override;
35 
36     void CallSpecializedMethod(const std::string& method, const std::string& args) override;
37 
GetSpecializedComponent()38     RefPtr<Component> GetSpecializedComponent() override
39     {
40         return paddingChild_;
41     }
42 
43 protected:
44     bool SetSpecializedAttr(const std::pair<std::string, std::string>& attr) override;
45     bool SetSpecializedStyle(const std::pair<std::string, std::string>& style) override;
46     bool AddSpecializedEvent(int32_t pageId, const std::string& event) override;
47     void PrepareSpecializedComponent() override;
48     void ResetInitializedStyle() override;
49 
50 private:
51 
52     RefPtr<TrackComponent> trackChild_;
53     RefPtr<BlockComponent> blockChild_;
54     RefPtr<SliderComponent> sliderChild_;
55     RefPtr<WatchSliderComponent> watchSliderChild_;
56     RefPtr<PaddingComponent> paddingChild_;
57 
58     double min_ = 0.0;
59     double max_ = 100.0;
60     double step_ = 1.0;
61     double val_ = 0.0;
62     Dimension paddingLeft_ = 32.0_vp;
63     Dimension paddingRight_ = 32.0_vp;
64     Color color_;
65     Color selectColor_;
66     Color blockColor_;
67     EventMarker onMoveEndEventId_;
68 
69     std::string minIconUrl_;
70     std::string maxIconUrl_;
71     SliderMode mode_ = SliderMode::OUTSET;
72     bool isContinuous_ = true;
73     bool showSteps_ = false;
74     bool showTips_ = false;
75 };
76 
77 } // namespace OHOS::Ace::Framework
78 
79 #endif // FOUNDATION_ACE_FRAMEWORKS_BRIDGE_COMMON_DOM_DOM_SLIDER_H
80