• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_PATTERN_INDICATOR_CONTROLLER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_INDICATOR_CONTROLLER_H
18 
19 #include "core/components_ng/pattern/swiper/swiper_pattern.h"
20 
21 namespace OHOS::Ace::Framework {
22 class JSIndicatorController;
23 }
24 namespace OHOS::Ace::NG {
25 class IndicatorPattern;
26 class IndicatorController : public virtual AceType {
27     DECLARE_ACE_TYPE(IndicatorController, AceType);
28 
29 public:
30     void ShowPrevious() const;
31 
32     void ShowNext() const;
33 
34     void ChangeIndex(int32_t index, bool useAnimation) const;
35 
36     void ResetJSIndicatorController();
37 
38     void SetJSIndicatorController(std::function<void()> resetFunc);
39 
40     void SetIndicatorPattern(const RefPtr<IndicatorPattern>& indicatorPattern);
41 
42     void SetSwiperNode(const RefPtr<FrameNode>& swiperNode);
43 
SetSwiperNode(const RefPtr<FrameNode> & swiperNode,const RefPtr<FrameNode> & indicatorNode)44     void SetSwiperNode(const RefPtr<FrameNode>& swiperNode, const RefPtr<FrameNode>& indicatorNode)
45     {
46         SetSwiperNode(swiperNode);
47     }
48 
49     const WeakPtr<FrameNode>& GetSwiperNode() const;
50 
ResetSwiperNode()51     void ResetSwiperNode()
52     {
53         swiperNode_ = nullptr;
54     }
55 
56     void ResetIndicatorControllor(
57         const RefPtr<IndicatorController>& controller, const RefPtr<FrameNode>& indicatorNode);
58 
59     void UpdateIndicatorNode();
60 
61     RefPtr<FrameNode> GetIndicatorNode();
62 
63 private:
64     std::function<void()> resetFunc_;
65     WeakPtr<IndicatorPattern> indicatorPattern_;
66     WeakPtr<FrameNode> swiperNode_;
67 };
68 
69 } // namespace OHOS::Ace
70 
71 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SWIPER_SWIPER_CONTROLLER_H
72