• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_BUTTON_H
17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_BUTTON_H
18 
19 #include <variant>
20 
21 #include "core/components/button/button_component.h"
22 #include "core/components/text/text_component.h"
23 #include "core/components/touch_listener/touch_listener_component.h"
24 #include "core/components_ng/pattern/button/button_request_data.h"
25 #include "core/event/ace_event_handler.h"
26 #include "frameworks/bridge/declarative_frontend/engine/bindings_defines.h"
27 #include "frameworks/bridge/declarative_frontend/jsview/js_container_base.h"
28 
29 namespace OHOS::Ace::Framework {
30 class JSButton : public JSContainerBase {
31 public:
32     static void SetFontSize(const JSCallbackInfo& info);
33     static void SetFontWeight(const std::string& value);
34     static void SetFontStyle(int32_t value);
35     static void SetFontFamily(const JSCallbackInfo& info);
36     static void SetTextColor(const JSCallbackInfo& info);
37     static void SetType(const JSCallbackInfo& info);
38     static void SetStateEffect(bool stateEffect);
39     static void SetLableStyle(const JSCallbackInfo& info);
40     static void JsBackgroundColor(const JSCallbackInfo& info);
41     static void JsRadius(const JSCallbackInfo& info);
42     static void JsBorder(const JSCallbackInfo& info);
43     static void JsWidth(const JSCallbackInfo& info);
44     static void JsHeight(const JSCallbackInfo& info);
45     static void JsAspectRatio(const JSCallbackInfo& info);
46     static void JsOnClick(const JSCallbackInfo& info);
47     static void JsSize(const JSCallbackInfo& info);
48     static void JsRemoteMessage(const JSCallbackInfo& info);
49     static void JsPadding(const JSCallbackInfo& info);
50     static void JsHoverEffect(const JSCallbackInfo& info);
51 
52     static void JSBind(BindingTarget globalObj);
53     static void CreateWithChild(const JSCallbackInfo& info);
54     static void CreateWithLabel(const JSCallbackInfo& info);
55 
56 private:
57     static void HandleDifferentRadius(const JSRef<JSVal>& args);
58     static void GetFontContent(JSRef<JSVal>& font, ButtonParameters& buttonParameters);
59     static void CompleteParameters(ButtonParameters& buttonParameters);
60     static CalcDimension GetSizeValue(const JSCallbackInfo& info);
61     static NG::PaddingProperty GetNewPadding(const JSCallbackInfo& info);
62     static Edge GetOldPadding(const JSCallbackInfo& info);
63     static NG::PaddingProperty SetPaddings(const std::optional<CalcDimension>& top,
64         const std::optional<CalcDimension>& bottom, const std::optional<CalcDimension>& left,
65         const std::optional<CalcDimension>& right);
66     static bool isLabelButton_;
67 };
68 } // namespace OHOS::Ace::Framework
69 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_BUTTON_H
70