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 FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_VIEW_STACK_MODEL_IMPL_H 17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_VIEW_STACK_MODEL_IMPL_H 18 19 #include "base/memory/ace_type.h" 20 #include "base/utils/macros.h" 21 #include "bridge/declarative_frontend/view_stack_processor.h" 22 #include "core/components_ng/base/view_stack_model.h" 23 #include "core/pipeline/base/component.h" 24 25 namespace OHOS::Ace::Framework { 26 27 class ViewStackModelImpl : public ViewStackModel { 28 public: Push(const RefPtr<AceType> & node,bool isCustomView)29 void Push(const RefPtr<AceType>& node, bool isCustomView) override 30 { 31 auto uiNode = AceType::DynamicCast<Component>(node); 32 ViewStackProcessor::GetInstance()->Push(uiNode, isCustomView); 33 } 34 Pop()35 void Pop() override 36 { 37 ViewStackProcessor::GetInstance()->Pop(); 38 } 39 PopContainer()40 void PopContainer() override 41 { 42 ViewStackProcessor::GetInstance()->PopContainer(); 43 } 44 PushKey(const std::string & key)45 void PushKey(const std::string& key) override 46 { 47 ViewStackProcessor::GetInstance()->PushKey(key); 48 } 49 PopKey()50 void PopKey() override 51 { 52 ViewStackProcessor::GetInstance()->PopKey(); 53 } 54 NewScope()55 void NewScope() override 56 { 57 scopeStack_ = std::make_unique<ScopedViewStackProcessor>(); 58 } 59 Finish()60 RefPtr<AceType> Finish() override 61 { 62 auto node = ViewStackProcessor::GetInstance()->Finish(); 63 scopeStack_.reset(); 64 return node; 65 } 66 ProcessViewId(const std::string & viewId)67 std::string ProcessViewId(const std::string& viewId) override 68 { 69 return ViewStackProcessor::GetInstance()->ProcessViewId(viewId); 70 } 71 GetImplicitAnimationOption()72 AnimationOption GetImplicitAnimationOption() override 73 { 74 return ViewStackProcessor::GetInstance()->GetImplicitAnimationOption(); 75 } 76 77 private: 78 std::unique_ptr<ScopedViewStackProcessor> scopeStack_; 79 }; 80 81 } // namespace OHOS::Ace::Framework 82 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_MODELS_VIEW_STACK_MODEL_IMPL_H 83