1 /*
2  * Copyright (c) 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 UPDATER_UI_EVENT_MANAGER_H
17 #define UPDATER_UI_EVENT_MANAGER_H
18 
19 #include <memory>
20 #include <vector>
21 
22 #include "component/component_factory.h"
23 #include "event_listener.h"
24 #include "macros_updater.h"
25 #include "page/page_manager.h"
26 
27 namespace Updater {
28 class EventManager final {
29     DISALLOW_COPY_MOVE(EventManager);
30 public:
31     void RegisterEventManagerHelper(std::unique_ptr<KeyListener> ptr);
32     EventManager();
33     ~EventManager() = default;
34     static EventManager &GetInstance();
35     void Add(const ComInfo &viewId, std::unique_ptr<LabelOnTouchListener> listener);
36     void Add(const ComInfo &viewId, std::unique_ptr<BtnOnEventListener> listener);
37     void Add(const ComInfo &viewId, std::unique_ptr<BtnOnDragListener> listener);
38     void Add(const ComInfo &viewId, EventType evt, Callback cb);
39     void AddKeyListener();
40 private:
41     PageManager &pgMgr_;
42     std::unique_ptr<KeyListener> helper_ {};
43     std::vector<std::unique_ptr<OHOS::UIView::OnTouchListener>> labelOnTouchListener_;
44     std::vector<std::unique_ptr<OHOS::UIView::OnClickListener>> btnOnClickListener_;
45     std::vector<std::unique_ptr<OHOS::UIView::OnDragListener>> btnOnDragListener;
46 };
47 } // namespace Updater
48 #endif
49