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 FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_PROGRESS_H
17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_PROGRESS_H
18 
19 #include "bridge/declarative_frontend/engine/functions/js_function.h"
20 #include "bridge/declarative_frontend/jsview/js_view_abstract.h"
21 #include "core/components_ng/pattern/progress/progress_model.h"
22 
23 namespace OHOS::Ace::Framework {
24 
25 enum class ProgressStyle {
26     Linear,
27     Ring,
28     Eclipse,
29     ScaleRing,
30     Capsule,
31 };
32 
33 class JSProgress : public JSViewAbstract {
34 public:
35     static void JSBind(BindingTarget globalObj);
36     static void Create(const JSCallbackInfo& info);
37 
38     static void SetValue(double value);
39     static void SetColor(const JSCallbackInfo& info);
40     static void SetCircularStyle(const JSCallbackInfo& info);
41     static void JsBackgroundColor(const JSCallbackInfo& info);
42     static void JsBorderColor(const JSCallbackInfo& info);
43 
44 private:
45     static bool ConvertGradientColor(const JsiRef<JsiValue>& param, NG::Gradient& gradient);
46     static NG::ProgressStatus ConvertStrToProgressStatus(const std::string& value);
47     static void JsSetProgressStyleOptions(const JSCallbackInfo& info);
48     static void JsSetLinearStyleOptions(const JSCallbackInfo& info);
49     static void JsSetRingStyleOptions(const JSCallbackInfo& info);
50     static void JsSetCapsuleStyle(const JSCallbackInfo& info);
51     static void JsSetFontStyle(const JSCallbackInfo& info);
52     static void JsSetFontDefault();
53     static void JsSetFont(const JSRef<JSObject>& info);
54     static void JsSetCommonOptions(const JSCallbackInfo& info);
55 };
56 
57 } // namespace OHOS::Ace::Framework
58 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_PROGRESS_H
59