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 #include "bridge/cj_frontend/interfaces/cj_ffi/cj_navigator_ffi.h"
17 
18 #include "bridge/cj_frontend/interfaces/cj_ffi/cj_view_abstract_ffi.h"
19 #include "core/components_ng/pattern/navigator/navigator_model_ng.h"
20 
21 using namespace OHOS::Ace;
22 using namespace OHOS::Ace::Framework;
23 
24 extern "C" {
FfiOHOSAceFrameworkNavigatorCreate(const char * target,int32_t type)25 void FfiOHOSAceFrameworkNavigatorCreate(const char* target, int32_t type)
26 {
27     NavigatorModel::GetInstance()->Create();
28     NavigatorModel::GetInstance()->SetUri(target);
29     NavigatorType navigatorType = NavigatorType(type);
30     if (navigatorType == NavigatorType::DEFAULT) {
31         NavigatorModel::GetInstance()->SetType(NavigatorType::PUSH);
32     } else {
33         NavigatorModel::GetInstance()->SetType(navigatorType);
34     }
35 }
36 
FfiOHOSAceFrameworkNavigatorSetParams(const char * args)37 void FfiOHOSAceFrameworkNavigatorSetParams(const char* args)
38 {
39     NavigatorModel::GetInstance()->SetParams(args);
40 }
41 
FfiOHOSAceFrameworkNavigatorSetActive(bool active)42 void FfiOHOSAceFrameworkNavigatorSetActive(bool active)
43 {
44     NavigatorModel::GetInstance()->SetActive(active);
45 }
46 
FfiOHOSAceFrameworkNavigatorSetWidth(double width,int32_t unit)47 void FfiOHOSAceFrameworkNavigatorSetWidth(double width, int32_t unit)
48 {
49     NavigatorModel::GetInstance()->SetIsDefWidth(true);
50     FfiOHOSAceFrameworkViewAbstractSetWidth(width, unit);
51 }
52 
FfiOHOSAceFrameworkNavigatorSetHeight(double height,int32_t unit)53 void FfiOHOSAceFrameworkNavigatorSetHeight(double height, int32_t unit)
54 {
55     NavigatorModel::GetInstance()->SetIsDefHeight(true);
56     FfiOHOSAceFrameworkViewAbstractSetHeight(height, unit);
57 }
58 
FfiOHOSAceFrameworkNavigatorSetSize(double width,int32_t widthUnit,double height,int32_t heightUnit)59 void FfiOHOSAceFrameworkNavigatorSetSize(double width, int32_t widthUnit, double height, int32_t heightUnit)
60 {
61     FfiOHOSAceFrameworkNavigatorSetWidth(width, widthUnit);
62     FfiOHOSAceFrameworkNavigatorSetHeight(height, heightUnit);
63 }
64 }
65