• 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 #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/event/ace_event_handler.h"
25 #include "frameworks/bridge/declarative_frontend/engine/bindings_defines.h"
26 #include "frameworks/bridge/declarative_frontend/jsview/js_container_base.h"
27 
28 namespace OHOS::Ace::Framework {
29 
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 JsBackgroundColor(const JSCallbackInfo& info);
40     static void JsRadius(const JSCallbackInfo& info);
41     static void JsWidth(const JSCallbackInfo& info);
42     static void JsHeight(const JSCallbackInfo& info);
43     static void JsAspectRatio(const JSCallbackInfo& info);
44     static void JsOnClick(const JSCallbackInfo& info);
45     static void JsSize(const JSCallbackInfo& info);
46     static void JsRemoteMessage(const JSCallbackInfo& info);
47     static void JsPadding(const JSCallbackInfo& info);
48     static void JsHoverEffect(const JSCallbackInfo& info);
49 
50 public:
51     static void JSBind(BindingTarget globalObj);
52     static void CreateWithChild(const JSCallbackInfo& info);
53     static void CreateWithLabel(const JSCallbackInfo& info);
54 
55 private:
56     static void SetDefaultAttributes(const RefPtr<ButtonComponent>& buttonComponent);
57     static void SetTypeAndStateEffect(const JSRef<JSObject>& obj, const RefPtr<ButtonComponent>& buttonComponent);
58     static void SetTypeAndStateEffect(const JSRef<JSObject>& obj);
59     static Dimension GetSizeValue(const JSCallbackInfo& info);
60     static RefPtr<TextComponent> GetTextComponent();
61     static void ResetButtonHeight();
62 };
63 
64 } // namespace OHOS::Ace::Framework
65 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_BUTTON_H
66