1 /*
2  * Copyright (c) 2022-2023 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_NG_PATTERNS_DATA_PANEL_MODEL_NG_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_DATA_PANEL_MODEL_NG_H
18 
19 #include "core/components_ng/pattern/data_panel/data_panel_model.h"
20 #include "core/components_ng/base/common_configuration.h"
21 
22 namespace OHOS::Ace::NG {
23 class DataPanelConfiguration : public CommonConfiguration {
24     public:
DataPanelConfiguration(std::vector<double> & values,double maxValue,bool enabled)25         DataPanelConfiguration(std::vector<double>& values, double maxValue, bool enabled)
26             : CommonConfiguration(enabled), values_(values), maxValue_(maxValue)
27         {}
28         std::vector<double>& values_;
29         double maxValue_;
30 };
31 using DataPanelMakeCallback =
32     std::function<RefPtr<FrameNode>(const DataPanelConfiguration& dataPanelConfiguration)>;
33 class ACE_EXPORT DataPanelModelNG : public OHOS::Ace::DataPanelModel {
34 public:
35     void Create(const std::vector<double>& values, double max, int32_t dataPanelType) override;
36     void SetEffect(bool isCloseEffect) override;
37     void SetValueColors(const std::vector<Gradient>& valueColors) override;
38     void SetTrackBackground(const Color& trackBackgroundColor) override;
39     void SetStrokeWidth(const Dimension& strokeWidth) override;
40     void SetShadowOption(const DataPanelShadow& shadowOption) override;
41 
42     static void SetCloseEffect(FrameNode* frameNode, bool isClose);
43     static void SetTrackBackground(FrameNode* frameNode, const Color& trackBackgroundColor);
44     static void SetStrokeWidth(FrameNode* frameNode, const Dimension& strokeWidth);
45     static void SetShadowOption(FrameNode* frameNode, const DataPanelShadow& shadowOption);
46     static void SetValueColors(FrameNode* frameNode, const std::vector<Gradient>& valueColors);
47     static void SetBuilderFunc(FrameNode* frameNode, NG::DataPanelMakeCallback&& jsMake);
48 };
49 } // namespace OHOS::Ace::NG
50 
51 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_DATA_PANEL_MODEL_NG_H