• 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 #include "bridge/declarative_frontend/jsview/models/navigator_model_impl.h"
17 
18 #include "core/components/box/box_component.h"
19 #include "core/components/navigator/navigator_component.h"
20 #include "frameworks/bridge/declarative_frontend/view_stack_processor.h"
21 
22 namespace OHOS::Ace::Framework {
23 
Create()24 void NavigatorModelImpl::Create()
25 {
26     RefPtr<OHOS::Ace::Component> child;
27     auto navigatorComponent = AceType::MakeRefPtr<OHOS::Ace::NavigatorComponent>(child);
28     ViewStackProcessor::GetInstance()->Push(navigatorComponent);
29 }
30 
SetType(NavigatorType value)31 void NavigatorModelImpl::SetType(NavigatorType value)
32 {
33     auto navigator = AceType::DynamicCast<NavigatorComponent>(ViewStackProcessor::GetInstance()->GetMainComponent());
34     if (navigator) {
35         navigator->SetType(value);
36     }
37 }
38 
SetActive(bool active)39 void NavigatorModelImpl::SetActive(bool active)
40 {
41     auto navigator = AceType::DynamicCast<NavigatorComponent>(ViewStackProcessor::GetInstance()->GetMainComponent());
42     if (navigator) {
43         navigator->SetActive(active);
44     }
45 }
46 
SetUri(const std::string & uri)47 void NavigatorModelImpl::SetUri(const std::string& uri)
48 {
49     auto navigator = AceType::DynamicCast<NavigatorComponent>(ViewStackProcessor::GetInstance()->GetMainComponent());
50     if (navigator) {
51         navigator->SetUri(uri);
52     }
53 }
54 
SetParams(const std::string & params)55 void NavigatorModelImpl::SetParams(const std::string& params)
56 {
57     auto navigator = AceType::DynamicCast<NavigatorComponent>(ViewStackProcessor::GetInstance()->GetMainComponent());
58     if (navigator) {
59         navigator->SetParams(params);
60     }
61 }
62 
SetIsDefWidth(bool isDefWidth)63 void NavigatorModelImpl::SetIsDefWidth(bool isDefWidth)
64 {
65     auto navigator = AceType::DynamicCast<NavigatorComponent>(ViewStackProcessor::GetInstance()->GetMainComponent());
66     if (navigator) {
67         navigator->SetIsDefWidth(true);
68     }
69 }
70 
SetIsDefHeight(bool isDefHeight)71 void NavigatorModelImpl::SetIsDefHeight(bool isDefHeight)
72 {
73     auto navigator = AceType::DynamicCast<NavigatorComponent>(ViewStackProcessor::GetInstance()->GetMainComponent());
74     if (navigator) {
75         navigator->SetIsDefHeight(true);
76     }
77 }
78 
79 } // namespace OHOS::Ace::Framework
80