• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
27     DECLARE_ACE_TYPE(JSCustomDialogController, AceType);
28 
29 public:
JSCustomDialogController(JSView * ownerView)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     void JsGetState(const JSCallbackInfo& info);
39 
40 private:
41     static bool ParseAnimation(
42         const JsiExecutionContext& execContext, const JsiRef<JsiValue>& jsiValue, AnimationOption& result);
43     JSView* ownerView_ = nullptr;
44     bool isShown_ = false;
45     bool pending_ = false;
46     bool hasBind_ = false;
47 
48     // NG
49     std::vector<WeakPtr<AceType>> dialogs_;
50 
51     DialogProperties dialogProperties_;
52     RefPtr<JsWeakFunction> jsBuilderFunction_;
53     RefPtr<JsWeakFunction> jsCancelFunction_;
54     RefPtr<AceType> customDialog_;
55     RefPtr<AceType> dialogComponent_;
56     std::list<DialogOperation> dialogOperation_;
57 };
58 
59 } // namespace OHOS::Ace::Framework
60 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_DIALOG_JS_CUSTOM_DIALOG_CONTROLLER_H
61