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.h" 25 #include "page/page_manager.h" 26 27 namespace Updater { 28 class EventManager final { 29 DISALLOW_COPY_MOVE(EventManager); 30 public: 31 EventManager(); 32 ~EventManager() = default; 33 static EventManager &GetInstance(); 34 void Add(const ComInfo &viewId, std::unique_ptr<LabelOnTouchListener> listener); 35 void Add(const ComInfo &viewId, std::unique_ptr<BtnOnEventListener> listener); 36 void Add(const ComInfo &viewId, std::unique_ptr<BtnOnDragListener> listener); 37 void Add(const ComInfo &viewId, EventType evt, Callback cb); 38 void AddKeyListener(); 39 private: 40 PageManager &pgMgr_; 41 std::unique_ptr<KeyListener> keyListener_; 42 std::vector<std::unique_ptr<OHOS::UIView::OnTouchListener>> labelOnTouchListener_; 43 std::vector<std::unique_ptr<OHOS::UIView::OnClickListener>> btnOnClickListener_; 44 std::vector<std::unique_ptr<OHOS::UIView::OnDragListener>> btnOnDragListener; 45 }; 46 } // namespace Updater 47 #endif 48