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_window_scene.h" 17 18 #include "core/components_ng/pattern/window_scene/scene/window_scene_model.h" 19 20 namespace OHOS::Ace::Framework { JSBind(BindingTarget globalObj)21void JSWindowScene::JSBind(BindingTarget globalObj) 22 { 23 JSClass<JSWindowScene>::Declare("WindowScene"); 24 JSClass<JSWindowScene>::StaticMethod("create", &JSWindowScene::Create, MethodOptions::NONE); 25 26 JSClass<JSWindowScene>::Inherit<JSInteractableView>(); 27 JSClass<JSWindowScene>::InheritAndBind<JSViewAbstract>(globalObj); 28 } 29 Create(const JSCallbackInfo & info)30void JSWindowScene::Create(const JSCallbackInfo& info) 31 { 32 if (!Container::IsCurrentUseNewPipeline()) { 33 return; 34 } 35 36 if (info.Length() != 1) { 37 return; 38 } 39 40 if (!info[0]->IsNumber()) { 41 return; 42 } 43 44 auto persistentId = static_cast<int32_t>(info[0]->ToNumber<double>()); 45 NG::WindowSceneModel::Create(persistentId); 46 } 47 } // namespace OHOS::Ace::Framework 48