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/window_scene/js_screen.h" 17 18 #include "core/components_ng/pattern/window_scene/screen/screen_model.h" 19 20 namespace OHOS::Ace::Framework { JSBind(BindingTarget globalObj)21void JSScreen::JSBind(BindingTarget globalObj) 22 { 23 JSClass<JSScreen>::Declare("Screen"); 24 JSClass<JSScreen>::StaticMethod("create", &JSScreen::Create, MethodOptions::NONE); 25 26 JSClass<JSScreen>::Inherit<JSInteractableView>(); 27 JSClass<JSScreen>::InheritAndBind<JSViewAbstract>(globalObj); 28 } 29 Create(const JSCallbackInfo & info)30void JSScreen::Create(const JSCallbackInfo& info) 31 { 32 if (!Container::IsCurrentUseNewPipeline()) { 33 LOGE("Window scene is only supported on new pipeline!"); 34 return; 35 } 36 37 if (info.Length() != 1) { 38 LOGE("The arg is wrong, it is supposed to have 1 argument"); 39 return; 40 } 41 42 if (!info[0]->IsNumber()) { 43 LOGE("The arg is not a number"); 44 return; 45 } 46 47 auto screenId = static_cast<uint64_t>(info[0]->ToNumber<double>()); 48 NG::ScreenModel::Create(screenId); 49 } 50 } // namespace OHOS::Ace::Framework 51