1 /* 2 * Copyright (c) 2021-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 #ifndef FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_DIALOG_JS_CUSTOM_DIALOG_CONTROLLER_H 17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_DIALOG_JS_CUSTOM_DIALOG_CONTROLLER_H 18 19 #include "core/components/dialog/dialog_component.h" 20 #include "frameworks/bridge/declarative_frontend/engine/functions/js_function.h" 21 #include "frameworks/bridge/declarative_frontend/jsview/js_view.h" 22 #include "frameworks/core/components_ng/pattern/dialog/custom_dialog_controller_model.h" 23 24 namespace OHOS::Ace::Framework { 25 26 class JSCustomDialogController : public virtual AceType { DECLARE_ACE_TYPE(JSCustomDialogController,AceType)27 DECLARE_ACE_TYPE(JSCustomDialogController, AceType) 28 29 public: 30 explicit JSCustomDialogController(JSView* ownerView) : ownerView_(ownerView) {} 31 ~JSCustomDialogController() = default; 32 33 static void JSBind(BindingTarget object); 34 static void ConstructorCallback(const JSCallbackInfo& args); 35 static void DestructorCallback(JSCustomDialogController* instance); 36 void JsOpenDialog(const JSCallbackInfo& info); 37 void JsCloseDialog(const JSCallbackInfo& info); 38 39 private: 40 static bool ParseAnimation( 41 const JsiExecutionContext& execContext, const JsiRef<JsiValue>& jsiValue, AnimationOption& result); 42 JSView* ownerView_ = nullptr; 43 bool isShown_ = false; 44 bool pending_ = false; 45 46 // NG 47 std::vector<WeakPtr<AceType>> dialogs_; 48 49 DialogProperties dialogProperties_; 50 RefPtr<JsWeakFunction> jsBuilderFunction_; 51 RefPtr<JsWeakFunction> jsCancelFunction_; 52 RefPtr<AceType> customDialog_; 53 RefPtr<AceType> dialogComponent_; 54 std::list<DialogOperation> dialogOperation_; 55 }; 56 57 } // namespace OHOS::Ace::Framework 58 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_DIALOG_JS_CUSTOM_DIALOG_CONTROLLER_H 59