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_column_split.h"
17
18 #include "bridge/declarative_frontend/jsview/js_view_common_def.h"
19 #include "core/components_ng/pattern/linear_split/linear_split_model_ng.h"
20 #include "frameworks/bridge/declarative_frontend/jsview/js_linear_split.h"
21 #include "frameworks/bridge/declarative_frontend/view_stack_processor.h"
22
23 namespace OHOS::Ace::Framework {
24
Create()25 void JSColumnSplit::Create()
26 {
27 LinearSplitModel::GetInstance()->Create(NG::SplitType::COLUMN_SPLIT);
28 }
29
JsResizeable(bool resizeable)30 void JSColumnSplit::JsResizeable(bool resizeable)
31 {
32 LinearSplitModel::GetInstance()->SetResizeable(NG::SplitType::COLUMN_SPLIT, resizeable);
33 }
34
JsDivider(const JSCallbackInfo & args)35 void JSColumnSplit::JsDivider(const JSCallbackInfo& args)
36 {
37 if (args.Length() < 1 || !args[0]->IsObject()) {
38 LOGW("Invalid params");
39 return;
40 }
41
42 JSRef<JSObject> obj = JSRef<JSObject>::Cast(args[0]);
43 NG::ItemDivider divider;
44 ConvertFromJSValue(obj->GetProperty("startMargin"), divider.startMargin);
45 ConvertFromJSValue(obj->GetProperty("endMargin"), divider.endMargin);
46 LinearSplitModel::GetInstance()->SetDivider(NG::SplitType::COLUMN_SPLIT, divider);
47
48 args.ReturnSelf();
49 }
50
JSBind(BindingTarget globalObj)51 void JSColumnSplit::JSBind(BindingTarget globalObj)
52 {
53 JSClass<JSColumnSplit>::Declare("ColumnSplit");
54 JSClass<JSColumnSplit>::StaticMethod("create", &JSColumnSplit::Create, MethodOptions::NONE);
55 JSClass<JSColumnSplit>::StaticMethod("resizeable", &JSColumnSplit::JsResizeable, MethodOptions::NONE);
56 JSClass<JSColumnSplit>::StaticMethod("divider", &JSColumnSplit::JsDivider, MethodOptions::NONE);
57 JSClass<JSColumnSplit>::StaticMethod("onClick", &JSInteractableView::JsOnClick);
58 JSClass<JSColumnSplit>::StaticMethod("onTouch", &JSInteractableView::JsOnTouch);
59 JSClass<JSColumnSplit>::StaticMethod("onHover", &JSInteractableView::JsOnHover);
60 JSClass<JSColumnSplit>::StaticMethod("onKeyEvent", &JSInteractableView::JsOnKey);
61 JSClass<JSColumnSplit>::StaticMethod("onDeleteEvent", &JSInteractableView::JsOnDelete);
62 JSClass<JSColumnSplit>::StaticMethod("onAppear", &JSInteractableView::JsOnAppear);
63 JSClass<JSColumnSplit>::StaticMethod("onDisAppear", &JSInteractableView::JsOnDisAppear);
64 JSClass<JSColumnSplit>::StaticMethod("remoteMessage", &JSInteractableView::JsCommonRemoteMessage);
65 JSClass<JSColumnSplit>::InheritAndBind<JSContainerBase>(globalObj);
66 }
67
68 } // namespace OHOS::Ace::Framework
69