• 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 {
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 
37     static void ParseBorderRadius(const JSRef<JSVal>& args, NG::BorderRadiusProperty& radius);
38 
39     void JsOpenDialog(const JSCallbackInfo& info);
40     void JsCloseDialog(const JSCallbackInfo& info);
41 
42 private:
43     static bool ParseAnimation(
44         const JsiExecutionContext& execContext, const JsiRef<JsiValue>& jsiValue, AnimationOption& result);
45 
46     JSView* ownerView_ = nullptr;
47     bool isShown_ = false;
48     bool pending_ = false;
49 
50     // NG
51     std::vector<WeakPtr<AceType>> dialogs_;
52 
53     DialogProperties dialogProperties_;
54     RefPtr<JsFunction> jsBuilderFunction_;
55     RefPtr<JsFunction> jsCancelFunction_;
56     RefPtr<AceType> customDialog_;
57     RefPtr<AceType> dialogComponent_;
58     std::list<DialogOperation> dialogOperation_;
59 };
60 
61 } // namespace OHOS::Ace::Framework
62 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_DIALOG_JS_CUSTOM_DIALOG_CONTROLLER_H
63