• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_STAGE_STAGE_MANAGER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_STAGE_STAGE_MANAGER_H
18 
19 #include <cstdint>
20 
21 #include "base/memory/ace_type.h"
22 #include "base/memory/referenced.h"
23 #include "base/utils/noncopyable.h"
24 #include "core/animation/page_transition_common.h"
25 #include "core/components_ng/base/ui_node.h"
26 
27 namespace OHOS::Ace::NG {
28 class FrameNode;
29 class StagePattern;
30 class OverlayManager;
31 
32 // StageManager is the base class for root render node to perform page switch.
33 class ACE_EXPORT StageManager : public virtual AceType {
34     DECLARE_ACE_TYPE(StageManager, AceType);
35 
36 public:
37     explicit StageManager(const RefPtr<FrameNode>& stage);
38     ~StageManager() override = default;
39 
40     bool PushPage(const RefPtr<FrameNode>& node, bool needHideLast = true, bool needTransition = true);
41     bool PopPage(bool needShowNext = true, bool needTransition = true);
42     bool PopPageToIndex(int32_t index, bool needShowNext = true, bool needTransition = true);
43     bool CleanPageStack();
44 
45     bool MovePageToFront(const RefPtr<FrameNode>& node, bool needHideLast = true, bool needTransition = true);
46 
47     void StartTransition(const RefPtr<FrameNode>& srcPage, const RefPtr<FrameNode>& destPage, RouteType type);
48 
49     static void FirePageHide(const RefPtr<UINode>& node, PageTransitionType transitionType = PageTransitionType::NONE);
50     static void FirePageShow(const RefPtr<UINode>& node, PageTransitionType transitionType = PageTransitionType::NONE);
51 
52     RefPtr<FrameNode> GetLastPage();
53 
54     void ReloadStage();
55 
56 private:
57     void StopPageTransition();
58     RefPtr<FrameNode> stageNode_;
59     RefPtr<StagePattern> stagePattern_;
60     WeakPtr<FrameNode> destPageNode_;
61     WeakPtr<FrameNode> srcPageNode_;
62 
63     ACE_DISALLOW_COPY_AND_MOVE(StageManager);
64 };
65 } // namespace OHOS::Ace::NG
66 
67 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_STAGE_STAGE_MANAGER_H
68