• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_PROGRESS_PROGRESS_DATE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_PROGRESS_PROGRESS_DATE_H
18 
19 #include "base/geometry/dimension.h"
20 #include "core/components/common/properties/color.h"
21 #include "core/components/common/properties/text_style.h"
22 #include "core/components_ng/property/gradient_property.h"
23 #include "core/components_ng/property/property.h"
24 #include "core/components_ng/base/common_configuration.h"
25 
26 namespace OHOS::Ace::NG {
27 
28 enum class ProgressType {
29     LINEAR = 1,
30     RING = 2,
31     SCALE = 3,
32     CIRCLE = 4,
33     GAUGE = 5,
34     ARC = 6,
35     MOON = 7,
36     BUBBLE = 8,
37     CAPSULE = 9,
38 };
39 
40 enum class ProgressStatus {
41     PROGRESSING = 0,
42     LOADING
43 };
44 
45 class ProgressTypeUtils {
46 public:
ConvertProgressTypeToString(ProgressType progressType)47     static std::string ConvertProgressTypeToString(ProgressType progressType)
48     {
49         std::string progressTypeUtils = "";
50         switch (progressType) {
51             case ProgressType::LINEAR:
52                 progressTypeUtils = "ProgressStyle.Linear";
53                 break;
54             case ProgressType::MOON:
55                 progressTypeUtils = "ProgressStyle.Eclipse";
56                 break;
57             case ProgressType::SCALE:
58                 progressTypeUtils = "ProgressStyle.ScaleRing";
59                 break;
60             case ProgressType::RING:
61                 progressTypeUtils = "ProgressStyle.Ring";
62                 break;
63             case ProgressType::CAPSULE:
64                 progressTypeUtils = "ProgressStyle.Capsule";
65                 break;
66             default:
67                 progressTypeUtils = "ProgressStyle.Linear";
68         }
69         return progressTypeUtils;
70     }
71 };
72 
73 struct ProgressDate {
74     ACE_DEFINE_PROPERTY_GROUP_ITEM(MaxValue, double);
75     ACE_DEFINE_PROPERTY_GROUP_ITEM(Value, double);
76     ACE_DEFINE_PROPERTY_GROUP_ITEM(StrokeWidth, Dimension);
77     ACE_DEFINE_PROPERTY_GROUP_ITEM(ScaleCount, int32_t);
78     ACE_DEFINE_PROPERTY_GROUP_ITEM(ScaleWidth, Dimension);
79     ACE_DEFINE_PROPERTY_GROUP_ITEM(BorderWidth, Dimension);
80     ACE_DEFINE_PROPERTY_GROUP_ITEM(TextSize, Dimension);
81     ACE_DEFINE_PROPERTY_GROUP_ITEM(Text, std::string);
82     ACE_DEFINE_PROPERTY_GROUP_ITEM(EnableScanEffect, bool);
83     ACE_DEFINE_PROPERTY_GROUP_ITEM(FontWeight, FontWeight);
84     ACE_DEFINE_PROPERTY_GROUP_ITEM(FontFamily, std::vector<std::string>);
85     ACE_DEFINE_PROPERTY_GROUP_ITEM(ItalicFontStyle, Ace::FontStyle);
86     ACE_DEFINE_PROPERTY_GROUP_ITEM(TextColor, Color);
87     ACE_DEFINE_PROPERTY_GROUP_ITEM(EnableRingScanEffect, bool);
88     ACE_DEFINE_PROPERTY_GROUP_ITEM(EnableLinearScanEffect, bool);
89     ACE_DEFINE_PROPERTY_GROUP_ITEM(EnableShowText, bool);
90     ACE_DEFINE_PROPERTY_GROUP_ITEM(StrokeRadius, Dimension);
91     ACE_DEFINE_PROPERTY_GROUP_ITEM(BorderRadius, Dimension);
92 };
93 
94 struct ProgressStyle {
95     ACE_DEFINE_PROPERTY_GROUP_ITEM(Color, Color);
96     ACE_DEFINE_PROPERTY_GROUP_ITEM(BackgroundColor, Color);
97     ACE_DEFINE_PROPERTY_GROUP_ITEM(Type, ProgressType);
98 };
99 
100 struct ProgressAnimatableProperty {
101     Color color;
102     Color bgColor;
103     Color borderColor;
104     Gradient ringProgressColor;
105     float strokeWidth = 0.0f;
106     float strokeRadius = 0.0f;
107     float value = 0.0f;
108 };
109 
110 class ProgressConfiguration : public CommonConfiguration {
111     public:
ProgressConfiguration(float value,float total,bool enabled)112         ProgressConfiguration(float value, float total, bool enabled)
113             : CommonConfiguration(enabled), value_(value), total_(total) {}
114         float value_ = 0.0f;
115         float total_ = 0.0f;
116 };
117 
118 } // namespace OHOS::Ace::NG
119 
120 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_PROGRESS_PROGRESS_DATE_H
121