• 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 "frameworks/bridge/declarative_frontend/jsview/js_common_view.h"
17 
18 #include "core/components/proxy/proxy_component.h"
19 #include "core/components_ng/pattern/common_view/common_view.h"
20 #include "frameworks/bridge/declarative_frontend/view_stack_processor.h"
21 
22 namespace OHOS::Ace::Framework {
Create(const JSCallbackInfo & info)23 void JSCommonView::Create(const JSCallbackInfo& info)
24 {
25     if (Container::IsCurrentUseNewPipeline()) {
26         NG::CommonView::Create();
27         return;
28     }
29     auto specializedBox = AceType::MakeRefPtr<OHOS::Ace::ProxyComponent>();
30     specializedBox->SetPassMinSize(false);
31     ViewStackProcessor::GetInstance()->Push(specializedBox);
32 }
33 
JSBind(BindingTarget globalObj)34 void JSCommonView::JSBind(BindingTarget globalObj)
35 {
36     JSClass<JSCommonView>::Declare("__Common__");
37     MethodOptions opt = MethodOptions::NONE;
38     JSClass<JSCommonView>::StaticMethod("create", &JSCommonView::Create, opt);
39     JSClass<JSCommonView>::StaticMethod("onAppear", &JSInteractableView::JsOnAppear);
40     JSClass<JSCommonView>::StaticMethod("onDisAppear", &JSInteractableView::JsOnDisAppear);
41     JSClass<JSCommonView>::StaticMethod("onTouch", &JSInteractableView::JsOnTouch);
42     JSClass<JSCommonView>::StaticMethod("onHover", &JSInteractableView::JsOnHover);
43     JSClass<JSCommonView>::StaticMethod("onKeyEvent", &JSInteractableView::JsOnKey);
44     JSClass<JSCommonView>::StaticMethod("onDeleteEvent", &JSInteractableView::JsOnDelete);
45     JSClass<JSCommonView>::StaticMethod("onClick", &JSInteractableView::JsOnClick);
46     JSClass<JSCommonView>::StaticMethod("remoteMessage", &JSInteractableView::JsCommonRemoteMessage);
47 
48     JSClass<JSCommonView>::Inherit<JSContainerBase>();
49     JSClass<JSCommonView>::Bind<>(globalObj);
50 }
51 } // namespace OHOS::Ace::Framework
52