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_TOUCH_HANDLER_H
17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_TOUCH_HANDLER_H
18 
19 #include "core/components/touch_listener/touch_listener_component.h"
20 #include "core/event/ace_event_handler.h"
21 #include "frameworks/bridge/declarative_frontend/engine/functions/js_touch_function.h"
22 #include "frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h"
23 
24 namespace OHOS::Ace::Framework {
25 
26 class JSTouchHandler {
27 private:
28     enum TouchEvent { DOWN, UP, MOVE, CANCEL };
29 
30 private:
31     RefPtr<OHOS::Ace::Component> component_;
32     RefPtr<JsTouchFunction> jsOnDownFunc_;
33     RefPtr<JsTouchFunction> jsOnUpFunc_;
34     RefPtr<JsTouchFunction> jsOnMoveFunc_;
35     RefPtr<JsTouchFunction> jsOnCancelFunc_;
36 
37 public:
38     JSTouchHandler() = default;
~JSTouchHandler()39     virtual ~JSTouchHandler() {}
40 
41     virtual RefPtr<OHOS::Ace::SingleChild> CreateComponent(const JSCallbackInfo& args);
42 
43     static void JSBind(BindingTarget globalObj);
44 
45     void JsHandlerOnTouch(TouchEvent action, const JSCallbackInfo& args);
46     void JsHandlerOnDown(const JSCallbackInfo& args);
47     void JsHandlerOnUp(const JSCallbackInfo& args);
48     void JsHandlerOnMove(const JSCallbackInfo& args);
49     void JsHandlerOnCancel(const JSCallbackInfo& args);
50 }; // JSTouchHandler
51 } // namespace OHOS::Ace::Framework
52 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_TOUCH_HANDLER_H
53