• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 #include "bridge/declarative_frontend/jsview/js_progress.h"
17 
18 #include "base/utils/utils.h"
19 #include "bridge/declarative_frontend/jsview/js_interactable_view.h"
20 #include "bridge/declarative_frontend/jsview/js_linear_gradient.h"
21 #include "bridge/declarative_frontend/jsview/models/progress_model_impl.h"
22 #include "core/components/common/properties/color.h"
23 #include "core/components/progress/progress_theme.h"
24 #include "core/components/text/text_theme.h"
25 #include "core/components_ng/pattern/progress/progress_model_ng.h"
26 
27 namespace OHOS::Ace {
28 
29 std::unique_ptr<ProgressModel> ProgressModel::instance_ = nullptr;
30 std::mutex ProgressModel::mutex_;
31 ProgressType g_progressType = ProgressType::LINEAR;
32 
GetInstance()33 ProgressModel* ProgressModel::GetInstance()
34 {
35     if (!instance_) {
36         std::lock_guard<std::mutex> lock(mutex_);
37         if (!instance_) {
38 #ifdef NG_BUILD
39             instance_.reset(new NG::ProgressModelNG());
40 #else
41             if (Container::IsCurrentUseNewPipeline()) {
42                 instance_.reset(new NG::ProgressModelNG());
43             } else {
44                 instance_.reset(new Framework::ProgressModelImpl());
45             }
46 #endif
47         }
48     }
49     return instance_.get();
50 }
51 
52 } // namespace OHOS::Ace
53 
54 namespace OHOS::Ace::Framework {
55 const static int32_t PLATFORM_VERSION_TEN = 10;
Create(const JSCallbackInfo & info)56 void JSProgress::Create(const JSCallbackInfo& info)
57 {
58     if (!info[0]->IsObject()) {
59         return;
60     }
61     auto paramObject = JSRef<JSObject>::Cast(info[0]);
62 
63     auto value = 0;
64     auto jsValue = paramObject->GetProperty("value");
65     if (jsValue->IsNumber()) {
66         value = jsValue->ToNumber<double>();
67     }
68 
69     auto total = 100;
70     auto jsTotal = paramObject->GetProperty("total");
71     if (jsTotal->IsNumber() && jsTotal->ToNumber<int>() > 0) {
72         total = jsTotal->ToNumber<int>();
73     }
74 
75     if (value > total) {
76         value = total;
77     } else if (value < 0) {
78         value = 0;
79     }
80 
81     auto jsStyle = paramObject->GetProperty("type");
82     if (jsStyle->IsNull() || jsStyle->IsUndefined()) {
83         jsStyle = paramObject->GetProperty("style");
84     }
85 
86     auto progressStyle = static_cast<ProgressStyle>(jsStyle->ToNumber<int32_t>());
87     if (progressStyle == ProgressStyle::Eclipse) {
88         g_progressType = ProgressType::MOON;
89     } else if (progressStyle == ProgressStyle::Ring) {
90         g_progressType = ProgressType::RING;
91     } else if (progressStyle == ProgressStyle::ScaleRing) {
92         g_progressType = ProgressType::SCALE;
93     } else if (progressStyle == ProgressStyle::Capsule) {
94         g_progressType = ProgressType::CAPSULE;
95     } else {
96         g_progressType = ProgressType::LINEAR;
97     }
98 
99     ProgressModel::GetInstance()->Create(0.0, value, 0.0, total, static_cast<NG::ProgressType>(g_progressType));
100 }
101 
JSBind(BindingTarget globalObj)102 void JSProgress::JSBind(BindingTarget globalObj)
103 {
104     JSClass<JSProgress>::Declare("Progress");
105     MethodOptions opt = MethodOptions::NONE;
106 
107     JSClass<JSProgress>::StaticMethod("create", &JSProgress::Create, opt);
108     JSClass<JSProgress>::StaticMethod("value", &JSProgress::SetValue, opt);
109     JSClass<JSProgress>::StaticMethod("color", &JSProgress::SetColor, opt);
110     JSClass<JSProgress>::StaticMethod("circularStyle", &JSProgress::SetCircularStyle, opt);
111     JSClass<JSProgress>::StaticMethod("cricularStyle", &JSProgress::SetCircularStyle, opt);
112     JSClass<JSProgress>::StaticMethod("style", &JSProgress::SetCircularStyle, opt);
113     JSClass<JSProgress>::StaticMethod("backgroundColor", &JSProgress::JsBackgroundColor, opt);
114     JSClass<JSProgress>::StaticMethod("onClick", &JSInteractableView::JsOnClick);
115     JSClass<JSProgress>::StaticMethod("onTouch", &JSInteractableView::JsOnTouch);
116     JSClass<JSProgress>::StaticMethod("onKeyEvent", &JSInteractableView::JsOnKey);
117     JSClass<JSProgress>::StaticMethod("onDeleteEvent", &JSInteractableView::JsOnDelete);
118     JSClass<JSProgress>::StaticMethod("onAppear", &JSInteractableView::JsOnAppear);
119     JSClass<JSProgress>::StaticMethod("onDisAppear", &JSInteractableView::JsOnDisAppear);
120     JSClass<JSProgress>::StaticMethod("borderColor", &JSProgress::JsBorderColor, opt);
121     JSClass<JSProgress>::InheritAndBind<JSViewAbstract>(globalObj);
122 }
123 
SetValue(double value)124 void JSProgress::SetValue(double value)
125 {
126     if (std::isnan(value)) {
127         return;
128     }
129     if (value < 0) {
130         value = 0;
131     }
132     ProgressModel::GetInstance()->SetValue(value);
133 }
134 
SetColor(const JSCallbackInfo & info)135 void JSProgress::SetColor(const JSCallbackInfo& info)
136 {
137     Color colorVal;
138     NG::Gradient gradient;
139     RefPtr<ProgressTheme> theme = GetTheme<ProgressTheme>();
140     if (ConvertGradientColor(info[0], gradient)) {
141         ProgressModel::GetInstance()->SetGradientColor(gradient);
142     } else {
143         Color endColor;
144         Color beginColor;
145         if (info[0]->IsNull() || info[0]->IsUndefined() || !ParseJsColor(info[0], colorVal)) {
146             if (g_progressType == ProgressType::RING) {
147                 endColor = theme->GetRingProgressEndSideColor();
148                 beginColor = theme->GetRingProgressBeginSideColor();
149             } else if (g_progressType == ProgressType::CAPSULE) {
150                 colorVal = theme->GetCapsuleSelectColor();
151             } else {
152                 colorVal = theme->GetTrackSelectedColor();
153             }
154         } else {
155             endColor = colorVal;
156             beginColor = colorVal;
157         }
158 
159         NG::GradientColor endSideColor;
160         NG::GradientColor beginSideColor;
161         endSideColor.SetLinearColor(LinearColor(endColor));
162         endSideColor.SetDimension(Dimension(0.0f));
163         beginSideColor.SetLinearColor(LinearColor(beginColor));
164         beginSideColor.SetDimension(Dimension(1.0f));
165         gradient.AddColor(endSideColor);
166         gradient.AddColor(beginSideColor);
167         ProgressModel::GetInstance()->SetGradientColor(gradient);
168         ProgressModel::GetInstance()->SetColor(colorVal);
169     }
170 }
171 
SetCircularStyle(const JSCallbackInfo & info)172 void JSProgress::SetCircularStyle(const JSCallbackInfo& info)
173 {
174     if (!info[0]->IsObject()) {
175         return;
176     }
177 
178     if (PipelineBase::GetCurrentContext() &&
179         PipelineBase::GetCurrentContext()->GetMinPlatformVersion() < PLATFORM_VERSION_TEN) {
180         JsSetProgressStyleOptions(info);
181         return;
182     }
183 
184     JsSetCommonOptions(info);
185 
186     switch (g_progressType) {
187         case ProgressType::LINEAR:
188             JsSetLinearStyleOptions(info);
189             break;
190         case ProgressType::RING:
191             JsSetRingStyleOptions(info);
192             break;
193         case ProgressType::CAPSULE:
194             JsSetCapsuleStyle(info);
195             break;
196         default:
197             JsSetProgressStyleOptions(info);
198             break;
199     }
200 }
201 
JsSetProgressStyleOptions(const JSCallbackInfo & info)202 void JSProgress::JsSetProgressStyleOptions(const JSCallbackInfo& info)
203 {
204     static const char attrsProgressStrokeWidth[] = "strokeWidth";
205     static const char attrsProgressScaleWidth[] = "scaleWidth";
206     auto paramObject = JSRef<JSObject>::Cast(info[0]);
207     RefPtr<ProgressTheme> theme = GetTheme<ProgressTheme>();
208     CHECK_NULL_VOID(theme);
209 
210     CalcDimension strokeWidthDimension;
211     auto jsStrokeWidth = paramObject->GetProperty(attrsProgressStrokeWidth);
212     if (!CheckLength(jsStrokeWidth, strokeWidthDimension, V2::PROGRESS_ETS_TAG, attrsProgressStrokeWidth)) {
213         strokeWidthDimension = theme->GetTrackThickness();
214     }
215 
216     if (strokeWidthDimension.Value() <= 0.0 || strokeWidthDimension.Unit() == DimensionUnit::PERCENT) {
217         strokeWidthDimension = theme->GetTrackThickness();
218     }
219 
220     ProgressModel::GetInstance()->SetStrokeWidth(strokeWidthDimension);
221 
222     auto jsScaleCount = paramObject->GetProperty("scaleCount");
223     auto scaleCount = jsScaleCount->IsNumber() ? jsScaleCount->ToNumber<int32_t>() : theme->GetScaleNumber();
224     if (scaleCount > 1.0) {
225         ProgressModel::GetInstance()->SetScaleCount(scaleCount);
226     } else {
227         ProgressModel::GetInstance()->SetScaleCount(theme->GetScaleNumber());
228     }
229 
230     CalcDimension scaleWidthDimension;
231     auto jsScaleWidth = paramObject->GetProperty(attrsProgressScaleWidth);
232     if (!CheckLength(jsScaleWidth, scaleWidthDimension, V2::PROGRESS_ETS_TAG, attrsProgressScaleWidth)) {
233         scaleWidthDimension = theme->GetScaleWidth();
234     }
235 
236     if ((scaleWidthDimension.Value() <= 0.0) || (scaleWidthDimension.Value() > strokeWidthDimension.Value()) ||
237         scaleWidthDimension.Unit() == DimensionUnit::PERCENT) {
238         scaleWidthDimension = theme->GetScaleWidth();
239     }
240 
241     ProgressModel::GetInstance()->SetScaleWidth(scaleWidthDimension);
242 }
243 
ConvertStrToProgressStatus(const std::string & value)244 NG::ProgressStatus JSProgress::ConvertStrToProgressStatus(const std::string& value)
245 {
246     if (value.compare("LOADING") == 0) {
247         return NG::ProgressStatus::LOADING;
248     } else {
249         return NG::ProgressStatus::PROGRESSING;
250     }
251 }
252 
JsSetRingStyleOptions(const JSCallbackInfo & info)253 void JSProgress::JsSetRingStyleOptions(const JSCallbackInfo& info)
254 {
255     auto paramObject = JSRef<JSObject>::Cast(info[0]);
256     RefPtr<ProgressTheme> theme = GetTheme<ProgressTheme>();
257 
258     // Parse stroke width
259     CalcDimension strokeWidthDimension;
260     auto versionTenOrLarger = PipelineBase::GetCurrentContext() &&
261                               PipelineBase::GetCurrentContext()->GetMinPlatformVersion() >= PLATFORM_VERSION_TEN;
262     auto strokeWidth = paramObject->GetProperty("strokeWidth");
263     if (strokeWidth->IsUndefined() || strokeWidth->IsNull() ||
264         (versionTenOrLarger ? !ParseJsDimensionVpNG(strokeWidth, strokeWidthDimension)
265                             : !ParseJsDimensionVp(strokeWidth, strokeWidthDimension))) {
266         strokeWidthDimension = theme->GetTrackThickness();
267     }
268 
269     if (LessOrEqual(strokeWidthDimension.Value(), 0.0f) || strokeWidthDimension.Unit() == DimensionUnit::PERCENT) {
270         strokeWidthDimension = theme->GetTrackThickness();
271     }
272 
273     ProgressModel::GetInstance()->SetStrokeWidth(strokeWidthDimension);
274 
275     // Parse shadow
276     bool paintShadow = false;
277     auto shadow = paramObject->GetProperty("shadow");
278     if (shadow->IsUndefined() || shadow->IsNull() || !ParseJsBool(shadow, paintShadow)) {
279         paintShadow = false;
280     }
281 
282     ProgressModel::GetInstance()->SetPaintShadow(paintShadow);
283 
284     // Parse progress status
285     std::string statusStr;
286     NG::ProgressStatus progressStatus;
287     auto status = paramObject->GetProperty("status");
288     if (status->IsUndefined() || status->IsNull() || !ParseJsString(status, statusStr)) {
289         progressStatus = NG::ProgressStatus::PROGRESSING;
290     } else {
291         progressStatus = ConvertStrToProgressStatus(statusStr);
292     }
293 
294     ProgressModel::GetInstance()->SetProgressStatus(static_cast<NG::ProgressStatus>(progressStatus));
295 
296     auto jsSweepingEffect = paramObject->GetProperty("enableScanEffect");
297     bool sweepingEffect = false;
298     if (!ParseJsBool(jsSweepingEffect, sweepingEffect)) {
299         sweepingEffect = false;
300     }
301     ProgressModel::GetInstance()->SetRingSweepingEffect(sweepingEffect);
302 }
303 
JsBackgroundColor(const JSCallbackInfo & info)304 void JSProgress::JsBackgroundColor(const JSCallbackInfo& info)
305 {
306     Color colorVal;
307     if (!CheckColor(info[0], colorVal, V2::PROGRESS_ETS_TAG, V2::ATTRS_COMMON_BACKGROUND_COLOR)) {
308         RefPtr<ProgressTheme> theme = GetTheme<ProgressTheme>();
309         CHECK_NULL_VOID(theme);
310         if (g_progressType == ProgressType::CAPSULE) {
311             colorVal = theme->GetCapsuleBgColor();
312         } else if (g_progressType == ProgressType::RING) {
313             colorVal = theme->GetRingProgressBgColor();
314         } else {
315             colorVal = theme->GetTrackBgColor();
316         }
317     }
318 
319     ProgressModel::GetInstance()->SetBackgroundColor(colorVal);
320 }
321 
JsBorderColor(const JSCallbackInfo & info)322 void JSProgress::JsBorderColor(const JSCallbackInfo& info)
323 {
324     JSViewAbstract::JsBorderColor(info);
325 }
326 
JsSetCapsuleStyle(const JSCallbackInfo & info)327 void JSProgress::JsSetCapsuleStyle(const JSCallbackInfo& info)
328 {
329     if (!info[0]->IsObject()) {
330         return;
331     }
332     auto paramObject = JSRef<JSObject>::Cast(info[0]);
333     RefPtr<ProgressTheme> theme = GetTheme<ProgressTheme>();
334 
335     auto jsBorderWidth = paramObject->GetProperty("borderWidth");
336     CalcDimension borderWidth;
337     if (!ParseJsDimensionVpNG(jsBorderWidth, borderWidth)) {
338         borderWidth = theme->GetBorderWidth();
339     }
340     if (LessNotEqual(borderWidth.Value(), 0.0) || borderWidth.Unit() == DimensionUnit::PERCENT) {
341         borderWidth = theme->GetBorderWidth();
342     }
343     ProgressModel::GetInstance()->SetBorderWidth(borderWidth);
344 
345     auto jsBorderColor = paramObject->GetProperty("borderColor");
346     Color colorVal;
347     if (!ParseJsColor(jsBorderColor, colorVal)) {
348         colorVal = theme->GetBorderColor();
349     }
350     ProgressModel::GetInstance()->SetBorderColor(colorVal);
351 
352     auto jsSweepingEffect = paramObject->GetProperty("enableScanEffect");
353     bool sweepingEffect = false;
354     if (!ParseJsBool(jsSweepingEffect, sweepingEffect)) {
355         sweepingEffect = false;
356     }
357     ProgressModel::GetInstance()->SetSweepingEffect(sweepingEffect);
358 
359     auto jsShowDefaultPercentage = paramObject->GetProperty("showDefaultPercentage");
360     bool showDefaultPercentage = false;
361     if (!ParseJsBool(jsShowDefaultPercentage, showDefaultPercentage)) {
362         showDefaultPercentage = false;
363     }
364     ProgressModel::GetInstance()->SetShowText(showDefaultPercentage);
365 
366     auto jsContext = paramObject->GetProperty("content");
367     std::string text;
368     if (jsContext->IsUndefined() || jsContext->IsNull() || (!ParseJsString(jsContext, text))) {
369         ProgressModel::GetInstance()->SetText(std::nullopt);
370     } else {
371         ProgressModel::GetInstance()->SetText(text);
372     }
373 
374     JsSetFontStyle(info);
375 }
376 
JsSetCommonOptions(const JSCallbackInfo & info)377 void JSProgress::JsSetCommonOptions(const JSCallbackInfo& info)
378 {
379     auto paramObject = JSRef<JSObject>::Cast(info[0]);
380 
381     // Parse smooth effect
382     auto jsSmoothEffect = paramObject->GetProperty("enableSmoothEffect");
383     bool enable = true;
384     if (!ParseJsBool(jsSmoothEffect, enable)) {
385         enable = true;
386     }
387     ProgressModel::GetInstance()->SetSmoothEffect(enable);
388 }
389 
JsSetFontStyle(const JSCallbackInfo & info)390 void JSProgress::JsSetFontStyle(const JSCallbackInfo& info)
391 {
392     auto paramObject = JSRef<JSObject>::Cast(info[0]);
393     RefPtr<ProgressTheme> theme = GetTheme<ProgressTheme>();
394     RefPtr<TextTheme> textTheme = GetTheme<TextTheme>();
395     auto jsFontColor = paramObject->GetProperty("fontColor");
396     Color fontColorVal;
397     if (!ParseJsColor(jsFontColor, fontColorVal)) {
398         fontColorVal = theme->GetTextColor();
399     }
400 
401     ProgressModel::GetInstance()->SetFontColor(fontColorVal);
402 
403     auto textStyle = paramObject->GetProperty("font");
404     if (!textStyle->IsObject()) {
405         JsSetFontDefault();
406     } else {
407         auto textObject = JSRef<JSObject>::Cast(textStyle);
408         JsSetFont(textObject);
409     }
410 }
411 
JsSetFontDefault()412 void JSProgress::JsSetFontDefault()
413 {
414     RefPtr<TextTheme> textTheme = GetTheme<TextTheme>();
415     RefPtr<ProgressTheme> progressTheme = GetTheme<ProgressTheme>();
416     ProgressModel::GetInstance()->SetFontSize(progressTheme->GetTextSize());
417     ProgressModel::GetInstance()->SetFontFamily(textTheme->GetTextStyle().GetFontFamilies());
418     ProgressModel::GetInstance()->SetFontWeight(textTheme->GetTextStyle().GetFontWeight());
419     ProgressModel::GetInstance()->SetItalicFontStyle(textTheme->GetTextStyle().GetFontStyle());
420 }
421 
JsSetFont(const JSRef<JSObject> & textObject)422 void JSProgress::JsSetFont(const JSRef<JSObject>& textObject)
423 {
424     RefPtr<ProgressTheme> theme = GetTheme<ProgressTheme>();
425     CHECK_NULL_VOID(theme);
426     RefPtr<TextTheme> textTheme = GetTheme<TextTheme>();
427     CHECK_NULL_VOID(textTheme);
428     auto size = textObject->GetProperty("size");
429     CalcDimension fontSize;
430     if (!ParseJsDimensionNG(size, fontSize, DimensionUnit::FP)) {
431         fontSize = theme->GetTextSize();
432     }
433     if (LessNotEqual(fontSize.Value(), 0.0) || fontSize.Unit() == DimensionUnit::PERCENT) {
434         fontSize = theme->GetTextSize();
435     }
436     ProgressModel::GetInstance()->SetFontSize(fontSize);
437 
438     auto fontWeight = textObject->GetProperty("weight");
439     if (!fontWeight->IsNull()) {
440         std::string weight;
441         if (fontWeight->IsNumber()) {
442             weight = std::to_string(fontWeight->ToNumber<int32_t>());
443         } else {
444             ParseJsString(fontWeight, weight);
445         }
446         ProgressModel::GetInstance()->SetFontWeight(ConvertStrToFontWeight(weight));
447     } else {
448         ProgressModel::GetInstance()->SetFontWeight(textTheme->GetTextStyle().GetFontWeight());
449     }
450 
451     auto family = textObject->GetProperty("family");
452     if (!family->IsNull() && family->IsString()) {
453         auto familyVal = family->ToString();
454         ProgressModel::GetInstance()->SetFontFamily(ConvertStrToFontFamilies(familyVal));
455     } else {
456         ProgressModel::GetInstance()->SetFontFamily(textTheme->GetTextStyle().GetFontFamilies());
457     }
458 
459     auto style = textObject->GetProperty("style");
460     if (!style->IsNull() && style->IsNumber()) {
461         auto styleVal = static_cast<FontStyle>(style->ToNumber<int32_t>());
462         ProgressModel::GetInstance()->SetItalicFontStyle(styleVal);
463     } else {
464         ProgressModel::GetInstance()->SetItalicFontStyle(textTheme->GetTextStyle().GetFontStyle());
465     }
466 }
467 
ConvertGradientColor(const JsiRef<JsiValue> & param,NG::Gradient & gradient)468 bool JSProgress::ConvertGradientColor(const JsiRef<JsiValue>& param, NG::Gradient& gradient)
469 {
470     if (param->IsNull() || param->IsUndefined() || !param->IsObject()) {
471         return false;
472     }
473 
474     JSLinearGradient* jsLinearGradient = JSRef<JSObject>::Cast(param)->Unwrap<JSLinearGradient>();
475     if (!jsLinearGradient || jsLinearGradient->GetGradient().empty()) {
476         return false;
477     }
478 
479     size_t size = jsLinearGradient->GetGradient().size();
480     if (size == 1) {
481         // If there is only one color, then this color is used for both the begin and end side.
482         NG::GradientColor gradientColor;
483         gradientColor.SetLinearColor(LinearColor(jsLinearGradient->GetGradient().front().first));
484         gradientColor.SetDimension(jsLinearGradient->GetGradient().front().second);
485         gradient.AddColor(gradientColor);
486         gradient.AddColor(gradientColor);
487         return true;
488     }
489 
490     for (size_t colorIndex = 0; colorIndex < size; colorIndex++) {
491         NG::GradientColor gradientColor;
492         gradientColor.SetLinearColor(LinearColor(jsLinearGradient->GetGradient().at(colorIndex).first));
493         gradientColor.SetDimension(jsLinearGradient->GetGradient().at(colorIndex).second);
494         gradient.AddColor(gradientColor);
495     }
496     return true;
497 }
498 
JsSetLinearStyleOptions(const JSCallbackInfo & info)499 void JSProgress::JsSetLinearStyleOptions(const JSCallbackInfo& info)
500 {
501     auto paramObject = JSRef<JSObject>::Cast(info[0]);
502     RefPtr<ProgressTheme> theme = GetTheme<ProgressTheme>();
503 
504     // Parse stroke width
505     CalcDimension strokeWidthDimension;
506     auto versionTenOrLarger = PipelineBase::GetCurrentContext() &&
507                               PipelineBase::GetCurrentContext()->GetMinPlatformVersion() >= PLATFORM_VERSION_TEN;
508     auto strokeWidth = paramObject->GetProperty("strokeWidth");
509     if (strokeWidth->IsUndefined() || strokeWidth->IsNull() ||
510         (versionTenOrLarger ? !ParseJsDimensionVpNG(strokeWidth, strokeWidthDimension)
511                             : !ParseJsDimensionVp(strokeWidth, strokeWidthDimension))) {
512         strokeWidthDimension = theme->GetTrackThickness();
513     }
514 
515     if (LessOrEqual(strokeWidthDimension.Value(), 0.0f) || strokeWidthDimension.Unit() == DimensionUnit::PERCENT) {
516         strokeWidthDimension = theme->GetTrackThickness();
517     }
518 
519     ProgressModel::GetInstance()->SetStrokeWidth(strokeWidthDimension);
520 
521     auto jsSweepingEffect = paramObject->GetProperty("enableScanEffect");
522     bool sweepingEffect = false;
523     if (!ParseJsBool(jsSweepingEffect, sweepingEffect)) {
524         sweepingEffect = false;
525     }
526     ProgressModel::GetInstance()->SetLinearSweepingEffect(sweepingEffect);
527 
528     // Parse stroke radius
529     CalcDimension strokeRadiusDimension;
530     auto strokeRadius = paramObject->GetProperty("strokeRadius");
531     if (strokeRadius->IsUndefined() || strokeRadius->IsNull() ||
532         !ParseJsDimensionVpNG(strokeRadius, strokeRadiusDimension)) {
533         ProgressModel::GetInstance()->ResetStrokeRadius();
534         return;
535     }
536 
537     if (LessNotEqual(strokeRadiusDimension.Value(), 0.0f) || strokeRadiusDimension.Unit() == DimensionUnit::PERCENT) {
538         ProgressModel::GetInstance()->ResetStrokeRadius();
539         return;
540     }
541 
542     ProgressModel::GetInstance()->SetStrokeRadius(strokeRadiusDimension);
543 }
544 
545 } // namespace OHOS::Ace::Framework
546