1 /*
2 * Copyright (c) 2021-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_row_split.h"
17
18 #include "bridge/declarative_frontend/jsview/js_shape_abstract.h"
19 #include "core/components_ng/base/view_abstract_model.h"
20 #include "core/components_ng/pattern/linear_split/linear_split_model_ng.h"
21 #include "frameworks/bridge/declarative_frontend/view_stack_processor.h"
22
23 namespace OHOS::Ace::Framework {
24
Create()25 void JSRowSplit::Create()
26 {
27 LinearSplitModel::GetInstance()->Create(NG::SplitType::ROW_SPLIT);
28 }
29
JsResizable(bool resizable)30 void JSRowSplit::JsResizable(bool resizable)
31 {
32 LinearSplitModel::GetInstance()->SetResizable(NG::SplitType::ROW_SPLIT, resizable);
33 }
34
JsClip(const JSCallbackInfo & info)35 void JSRowSplit::JsClip(const JSCallbackInfo& info)
36 {
37 if (info[0]->IsUndefined()) {
38 ViewAbstractModel::GetInstance()->SetClipEdge(true);
39 return;
40 }
41 if (info[0]->IsObject()) {
42 JSShapeAbstract* clipShape = JSRef<JSObject>::Cast(info[0])->Unwrap<JSShapeAbstract>();
43 if (clipShape == nullptr) {
44 return;
45 }
46 ViewAbstractModel::GetInstance()->SetClipShape(clipShape->GetBasicShape());
47 } else if (info[0]->IsBoolean()) {
48 ViewAbstractModel::GetInstance()->SetClipEdge(info[0]->ToBoolean());
49 }
50 }
51
JSBind(BindingTarget globalObj)52 void JSRowSplit::JSBind(BindingTarget globalObj)
53 {
54 JSClass<JSRowSplit>::Declare("RowSplit");
55 JSClass<JSRowSplit>::StaticMethod("create", &JSRowSplit::Create, MethodOptions::NONE);
56 JSClass<JSRowSplit>::StaticMethod("resizeable", &JSRowSplit::JsResizable, MethodOptions::NONE);
57 JSClass<JSRowSplit>::StaticMethod("onClick", &JSInteractableView::JsOnClick);
58 JSClass<JSRowSplit>::StaticMethod("onTouch", &JSInteractableView::JsOnTouch);
59 JSClass<JSRowSplit>::StaticMethod("onHover", &JSInteractableView::JsOnHover);
60 JSClass<JSRowSplit>::StaticMethod("onKeyEvent", &JSInteractableView::JsOnKey);
61 JSClass<JSRowSplit>::StaticMethod("onDeleteEvent", &JSInteractableView::JsOnDelete);
62 JSClass<JSRowSplit>::StaticMethod("onAttach", &JSInteractableView::JsOnAttach);
63 JSClass<JSRowSplit>::StaticMethod("onAppear", &JSInteractableView::JsOnAppear);
64 JSClass<JSRowSplit>::StaticMethod("onDetach", &JSInteractableView::JsOnDetach);
65 JSClass<JSRowSplit>::StaticMethod("onDisAppear", &JSInteractableView::JsOnDisAppear);
66 JSClass<JSRowSplit>::StaticMethod("remoteMessage", &JSInteractableView::JsCommonRemoteMessage);
67 JSClass<JSRowSplit>::StaticMethod("clip", &JSRowSplit::JsClip);
68 JSClass<JSRowSplit>::InheritAndBind<JSContainerBase>(globalObj);
69 }
70
71 } // namespace OHOS::Ace::Framework
72