1 /*
2  * Copyright (c) 2024 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SCROLLABLE_SCROLLER_OBSERVER_MANAGER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SCROLLABLE_SCROLLER_OBSERVER_MANAGER_H
18 
19 #include <cstdint>
20 #include <unordered_map>
21 
22 #include "base/memory/referenced.h"
23 #include "core/components_ng/pattern/scrollable/scrollable_properties.h"
24 
25 namespace OHOS::Ace {
26 class ScrollerObserverManager : public Referenced {
27 public:
28     ScrollerObserverManager() = default;
29     ~ScrollerObserverManager() = default;
30 
31     void AddObserver(const ScrollerObserver& obs, int32_t id);
32     void RemoveObserver(int32_t id);
33 
34     void HandleOnTouchEvent(TouchEventInfo& info);
35     void HandleOnReachEvent(bool end);
36     void HandleOnScrollStartEvent();
37     void HandleOnScrollStopEvent();
38     void HandleOnDidScrollEvent(Dimension dimension, ScrollState state,
39         ScrollSource source, bool isAtTop, bool isAtBottom);
40 
41 private:
42     std::unordered_map<int32_t, ScrollerObserver> observers_;
43 };
44 } // namespace OHOS::Ace
45 
46 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SCROLLABLE_SCROLLER_OBSERVER_MANAGER_H
47