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 "bridge/declarative_frontend/ark_theme/theme_apply/js_progress_theme.h"
23 #include "core/components/common/properties/color.h"
24 #include "core/components/progress/progress_theme.h"
25 #include "core/components/text/text_theme.h"
26 #include "core/components_ng/pattern/progress/progress_model_ng.h"
27
28 namespace OHOS::Ace {
29
30 std::unique_ptr<ProgressModel> ProgressModel::instance_ = nullptr;
31 std::mutex ProgressModel::mutex_;
32 ProgressType g_progressType = ProgressType::LINEAR;
33
GetInstance()34 ProgressModel* ProgressModel::GetInstance()
35 {
36 if (!instance_) {
37 std::lock_guard<std::mutex> lock(mutex_);
38 if (!instance_) {
39 #ifdef NG_BUILD
40 instance_.reset(new NG::ProgressModelNG());
41 #else
42 if (Container::IsCurrentUseNewPipeline()) {
43 instance_.reset(new NG::ProgressModelNG());
44 } else {
45 instance_.reset(new Framework::ProgressModelImpl());
46 }
47 #endif
48 }
49 }
50 return instance_.get();
51 }
52
53 } // namespace OHOS::Ace
54
55 namespace OHOS::Ace::Framework {
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 JSProgressTheme::ApplyTheme(progressStyle);
101 }
102
JSBind(BindingTarget globalObj)103 void JSProgress::JSBind(BindingTarget globalObj)
104 {
105 JSClass<JSProgress>::Declare("Progress");
106 MethodOptions opt = MethodOptions::NONE;
107
108 JSClass<JSProgress>::StaticMethod("create", &JSProgress::Create, opt);
109 JSClass<JSProgress>::StaticMethod("value", &JSProgress::SetValue, opt);
110 JSClass<JSProgress>::StaticMethod("color", &JSProgress::SetColor, opt);
111 JSClass<JSProgress>::StaticMethod("circularStyle", &JSProgress::SetCircularStyle, opt);
112 JSClass<JSProgress>::StaticMethod("cricularStyle", &JSProgress::SetCircularStyle, opt);
113 JSClass<JSProgress>::StaticMethod("style", &JSProgress::SetCircularStyle, opt);
114 JSClass<JSProgress>::StaticMethod("backgroundColor", &JSProgress::JsBackgroundColor, opt);
115 JSClass<JSProgress>::StaticMethod("onClick", &JSInteractableView::JsOnClick);
116 JSClass<JSProgress>::StaticMethod("onTouch", &JSInteractableView::JsOnTouch);
117 JSClass<JSProgress>::StaticMethod("onKeyEvent", &JSInteractableView::JsOnKey);
118 JSClass<JSProgress>::StaticMethod("onDeleteEvent", &JSInteractableView::JsOnDelete);
119 JSClass<JSProgress>::StaticMethod("onAttach", &JSInteractableView::JsOnAttach);
120 JSClass<JSProgress>::StaticMethod("onAppear", &JSInteractableView::JsOnAppear);
121 JSClass<JSProgress>::StaticMethod("onDetach", &JSInteractableView::JsOnDetach);
122 JSClass<JSProgress>::StaticMethod("onDisAppear", &JSInteractableView::JsOnDisAppear);
123 JSClass<JSProgress>::StaticMethod("borderColor", &JSProgress::JsBorderColor, opt);
124 JSClass<JSProgress>::InheritAndBind<JSViewAbstract>(globalObj);
125 }
126
SetValue(double value)127 void JSProgress::SetValue(double value)
128 {
129 if (std::isnan(value)) {
130 return;
131 }
132 if (value < 0) {
133 value = 0;
134 }
135 ProgressModel::GetInstance()->SetValue(value);
136 }
137
SetColor(const JSCallbackInfo & info)138 void JSProgress::SetColor(const JSCallbackInfo& info)
139 {
140 Color colorVal;
141 NG::Gradient gradient;
142 RefPtr<ProgressTheme> theme = GetTheme<ProgressTheme>();
143 if (ConvertGradientColor(info[0], gradient)) {
144 ProgressModel::GetInstance()->SetGradientColor(gradient);
145 } else {
146 Color endColor;
147 Color beginColor;
148 if (info[0]->IsNull() || info[0]->IsUndefined() || !ParseJsColor(info[0], colorVal)) {
149 endColor = theme->GetRingProgressEndSideColor();
150 beginColor = theme->GetRingProgressBeginSideColor();
151 if (g_progressType == ProgressType::CAPSULE) {
152 colorVal = theme->GetCapsuleSelectColor();
153 } else {
154 colorVal = theme->GetTrackSelectedColor();
155 }
156 } else {
157 endColor = colorVal;
158 beginColor = colorVal;
159 }
160
161 NG::GradientColor endSideColor;
162 NG::GradientColor beginSideColor;
163 endSideColor.SetLinearColor(LinearColor(endColor));
164 endSideColor.SetDimension(Dimension(0.0f));
165 beginSideColor.SetLinearColor(LinearColor(beginColor));
166 beginSideColor.SetDimension(Dimension(1.0f));
167 gradient.AddColor(endSideColor);
168 gradient.AddColor(beginSideColor);
169 ProgressModel::GetInstance()->SetGradientColor(gradient);
170 ProgressModel::GetInstance()->SetColor(colorVal);
171 }
172 }
173
SetCircularStyle(const JSCallbackInfo & info)174 void JSProgress::SetCircularStyle(const JSCallbackInfo& info)
175 {
176 if (!info[0]->IsObject()) {
177 return;
178 }
179
180 if (Container::LessThanAPIVersion(PlatformVersion::VERSION_TEN)) {
181 JsSetProgressStyleOptions(info);
182 return;
183 }
184
185 JsSetCommonOptions(info);
186
187 switch (g_progressType) {
188 case ProgressType::LINEAR:
189 JsSetLinearStyleOptions(info);
190 break;
191 case ProgressType::RING:
192 JsSetRingStyleOptions(info);
193 break;
194 case ProgressType::CAPSULE:
195 JsSetCapsuleStyle(info);
196 break;
197 default:
198 JsSetProgressStyleOptions(info);
199 break;
200 }
201 }
202
JsSetProgressStyleOptions(const JSCallbackInfo & info)203 void JSProgress::JsSetProgressStyleOptions(const JSCallbackInfo& info)
204 {
205 static const char attrsProgressStrokeWidth[] = "strokeWidth";
206 static const char attrsProgressScaleWidth[] = "scaleWidth";
207 auto paramObject = JSRef<JSObject>::Cast(info[0]);
208 RefPtr<ProgressTheme> theme = GetTheme<ProgressTheme>();
209 CHECK_NULL_VOID(theme);
210
211 CalcDimension strokeWidthDimension;
212 auto jsStrokeWidth = paramObject->GetProperty(attrsProgressStrokeWidth);
213 if (!CheckLength(jsStrokeWidth, strokeWidthDimension, V2::PROGRESS_ETS_TAG, attrsProgressStrokeWidth)) {
214 strokeWidthDimension = theme->GetTrackThickness();
215 }
216
217 if (strokeWidthDimension.Value() <= 0.0 || strokeWidthDimension.Unit() == DimensionUnit::PERCENT) {
218 strokeWidthDimension = theme->GetTrackThickness();
219 }
220
221 ProgressModel::GetInstance()->SetStrokeWidth(strokeWidthDimension);
222
223 auto jsScaleCount = paramObject->GetProperty("scaleCount");
224 auto scaleCount = jsScaleCount->IsNumber() ? jsScaleCount->ToNumber<int32_t>() : theme->GetScaleNumber();
225 if (scaleCount > 1.0) {
226 ProgressModel::GetInstance()->SetScaleCount(scaleCount);
227 } else {
228 ProgressModel::GetInstance()->SetScaleCount(theme->GetScaleNumber());
229 }
230
231 CalcDimension scaleWidthDimension;
232 auto jsScaleWidth = paramObject->GetProperty(attrsProgressScaleWidth);
233 if (!CheckLength(jsScaleWidth, scaleWidthDimension, V2::PROGRESS_ETS_TAG, attrsProgressScaleWidth)) {
234 scaleWidthDimension = theme->GetScaleWidth();
235 }
236
237 if ((scaleWidthDimension.Value() <= 0.0) || (scaleWidthDimension.Value() > strokeWidthDimension.Value()) ||
238 scaleWidthDimension.Unit() == DimensionUnit::PERCENT) {
239 scaleWidthDimension = theme->GetScaleWidth();
240 }
241
242 ProgressModel::GetInstance()->SetScaleWidth(scaleWidthDimension);
243 }
244
ConvertStrToProgressStatus(const std::string & value)245 NG::ProgressStatus JSProgress::ConvertStrToProgressStatus(const std::string& value)
246 {
247 if (value.compare("LOADING") == 0) {
248 return NG::ProgressStatus::LOADING;
249 } else {
250 return NG::ProgressStatus::PROGRESSING;
251 }
252 }
253
JsSetRingStyleOptions(const JSCallbackInfo & info)254 void JSProgress::JsSetRingStyleOptions(const JSCallbackInfo& info)
255 {
256 auto paramObject = JSRef<JSObject>::Cast(info[0]);
257 RefPtr<ProgressTheme> theme = GetTheme<ProgressTheme>();
258
259 // Parse stroke width
260 CalcDimension strokeWidthDimension;
261 auto versionTenOrLarger = Container::GreatOrEqualAPIVersion(PlatformVersion::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 = Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TEN);
507 auto strokeWidth = paramObject->GetProperty("strokeWidth");
508 if (strokeWidth->IsUndefined() || strokeWidth->IsNull() ||
509 (versionTenOrLarger ? !ParseJsDimensionVpNG(strokeWidth, strokeWidthDimension)
510 : !ParseJsDimensionVp(strokeWidth, strokeWidthDimension))) {
511 strokeWidthDimension = theme->GetTrackThickness();
512 }
513
514 if (LessOrEqual(strokeWidthDimension.Value(), 0.0f) || strokeWidthDimension.Unit() == DimensionUnit::PERCENT) {
515 strokeWidthDimension = theme->GetTrackThickness();
516 }
517
518 ProgressModel::GetInstance()->SetStrokeWidth(strokeWidthDimension);
519
520 auto jsSweepingEffect = paramObject->GetProperty("enableScanEffect");
521 bool sweepingEffect = false;
522 if (!ParseJsBool(jsSweepingEffect, sweepingEffect)) {
523 sweepingEffect = false;
524 }
525 ProgressModel::GetInstance()->SetLinearSweepingEffect(sweepingEffect);
526
527 // Parse stroke radius
528 CalcDimension strokeRadiusDimension;
529 auto strokeRadius = paramObject->GetProperty("strokeRadius");
530 if (strokeRadius->IsUndefined() || strokeRadius->IsNull() ||
531 !ParseJsDimensionVpNG(strokeRadius, strokeRadiusDimension)) {
532 ProgressModel::GetInstance()->ResetStrokeRadius();
533 return;
534 }
535
536 if (LessNotEqual(strokeRadiusDimension.Value(), 0.0f) || strokeRadiusDimension.Unit() == DimensionUnit::PERCENT) {
537 ProgressModel::GetInstance()->ResetStrokeRadius();
538 return;
539 }
540
541 ProgressModel::GetInstance()->SetStrokeRadius(strokeRadiusDimension);
542 }
543
544 } // namespace OHOS::Ace::Framework
545