1 /*
2 * Copyright (c) 2023 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/js_menu.h"
17
18 #include "core/components_ng/pattern/menu/menu_view.h"
19
20 namespace OHOS::Ace::Framework {
Create(const JSCallbackInfo &)21 void JSMenu::Create(const JSCallbackInfo& /* info */)
22 {
23 if (Container::IsCurrentUseNewPipeline()) {
24 NG::MenuView::Create();
25 return;
26 }
27 }
28
FontSize(const JSCallbackInfo & info)29 void JSMenu::FontSize(const JSCallbackInfo& info)
30 {
31 if (info.Length() < 1) {
32 LOGE("The argv is wrong, it is supposed to have at least 1 argument");
33 return;
34 }
35 Dimension fontSize;
36 if (!ParseJsDimensionFp(info[0], fontSize)) {
37 return;
38 }
39 if (Container::IsCurrentUseNewPipeline()) {
40 NG::MenuView::SetFontSize(fontSize);
41 return;
42 }
43 }
44
JSBind(BindingTarget globalObj)45 void JSMenu::JSBind(BindingTarget globalObj)
46 {
47 JSClass<JSMenu>::Declare("Menu");
48 MethodOptions opt = MethodOptions::NONE;
49 JSClass<JSMenu>::StaticMethod("create", &JSMenu::Create, opt);
50
51 JSClass<JSMenu>::StaticMethod("fontSize", &JSMenu::FontSize, opt);
52 JSClass<JSMenu>::Inherit<JSViewAbstract>();
53 JSClass<JSMenu>::Bind(globalObj);
54 }
55 } // namespace OHOS::Ace::Framework