1 /*
2  * Copyright (c) 2023-2024 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FORM_FORM_MODEL_NG_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FORM_FORM_MODEL_NG_H
18 
19 #include "base/geometry/dimension.h"
20 #include "base/geometry/ng/size_t.h"
21 #include "base/memory/referenced.h"
22 #include "base/utils/macros.h"
23 #include "core/components/common/layout/constants.h"
24 #include "core/components/form/resource/form_request_data.h"
25 #include "core/components_ng/base/frame_node.h"
26 #include "core/components_ng/pattern/form/form_event_hub.h"
27 #include "core/components_ng/pattern/form/form_model.h"
28 #include "core/components_ng/pattern/form/form_node.h"
29 
30 namespace OHOS::Ace::NG {
31 class ACE_EXPORT FormModelNG : public OHOS::Ace::FormModel {
32 public:
33     void Create(const RequestFormInfo& info) override;
34     void SetDimension(int32_t value) override;
35     void SetSize(const Dimension& width, const Dimension& height) override;
36     void AllowUpdate(bool value) override;
37     void SetModuleName(const std::string& value) override;
38     void SetOnAcquired(std::function<void(const std::string&)>&& onAcquired) override;
39     void SetOnError(std::function<void(const std::string&)>&& onError) override;
40     void SetOnUninstall(std::function<void(const std::string&)>&& onUninstall) override;
41     void SetOnRouter(std::function<void(const std::string&)>&& onRouter) override;
42     void SetOnLoad(std::function<void(const std::string&)>&& onLoad) override;
43     void SetVisible(VisibleType visible) override;
44     void SetVisibility(VisibleType visible) override;
45     void SetObscured(const std::vector<ObscuredReasons>& reasons) override;
46 
47     static void SetVisibility(FrameNode* frameNode, VisibleType visible);
48     static void AllowUpdate(FrameNode* frameNode, bool value);
49     static void SetDimension(FrameNode* frameNode, int32_t value);
50     static void SetModuleName(FrameNode* frameNode, const std::string& value);
51     static void SetSize(FrameNode* frameNode, const Dimension& width, const Dimension& height);
52     int32_t RequestPublishFormWithSnapshot(const AAFwk::Want& want,
53         const std::string& formBindingDataStr, int64_t& formId, std::string &errMsg) override;
54 };
55 } // namespace OHOS::Ace::NG
56 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FORM_FORM_MODEL_NG_H
57