1 /*
2  * Copyright (c) 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 OHOS_ABILITY_RUNTIME_AUTO_FILL_CUSTOM_CONFIG_H
17 #define OHOS_ABILITY_RUNTIME_AUTO_FILL_CUSTOM_CONFIG_H
18 
19 #include <optional>
20 #include <string>
21 
22 #include "view_data.h"
23 
24 namespace OHOS {
25 namespace AbilityRuntime {
26 namespace AutoFill {
27 enum class PopupPlacement {
28     LEFT,
29     RIGHT,
30     TOP,
31     BOTTOM,
32     TOP_LEFT,
33     TOP_RIGHT,
34     BOTTOM_LEFT,
35     BOTTOM_RIGHT,
36     LEFT_TOP,
37     LEFT_BOTTOM,
38     RIGHT_TOP,
39     RIGHT_BOTTOM,
40     NONE,
41 };
42 
43 enum class PopupDimensionUnit {
44     PX = 0,
45     VP,
46     FP,
47     PERCENT,
48     LPX,
49     AUTO,
50     CALC,
51 };
52 
53 struct PopupOffset {
54     PopupDimensionUnit unit = PopupDimensionUnit::PX;
55     double deltaX = 0.0;
56     double deltaY = 0.0;
57 };
58 
59 struct PopupSize {
60     PopupDimensionUnit unit = PopupDimensionUnit::PX;
61     double width = 0.0;
62     double height = 0.0;
63 };
64 
65 struct PopupLength {
66     PopupDimensionUnit unit = PopupDimensionUnit::PX;
67     double length = 0.0;
68 };
69 
70 struct AutoFillCustomConfig {
71     bool isShowInSubWindow = true;
72     std::string inspectorId;
73     std::int32_t nodeId = -1;
74     std::optional<bool> isAutoCancel;
75     std::optional<bool> isEnableArrow;
76     std::optional<PopupSize> targetSize;
77     std::optional<PopupOffset> targetOffset;
78     std::optional<PopupLength> targetSpace;
79     std::optional<PopupLength> arrowOffset;
80     std::optional<PopupPlacement> placement;
81     std::optional<int32_t> backgroundColor;
82     std::optional<int32_t> maskColor;
83     std::function<void(const std::string&)> onStateChange;
84 };
85 
86 enum class AutoFillCommand {
87     NONE,
88     FILL,
89     SAVE,
90     UPDATE,
91     RESIZE,
92     INPUT,
93     RELOAD_IN_MODAL
94 };
95 
96 /**
97  * @struct AutoFillRequest
98  * AutoFillRequest is used to define the auto fill request parameter structure.
99  */
100 struct AutoFillRequest {
101     AbilityBase::AutoFillType autoFillType = AbilityBase::AutoFillType::UNSPECIFIED;
102     AutoFillCommand autoFillCommand = AutoFillCommand::NONE;
103     AbilityBase::ViewData viewData;
104     AutoFillCustomConfig config;
105     std::function<void()> doAfterAsyncModalBinding;
106     std::function<void()> onUIExtensionProxyReady;
107 };
108 
109 struct AutoFillResult {
110     bool isPopup = false;
111     uint32_t autoFillSessionId = 0;
112 };
113 } // AutoFill
114 } // namespace AbilityRuntime
115 } // namespace OHOS
116 #endif // OHOS_ABILITY_RUNTIME_AUTO_FILL_CUSTOM_CONFIG_H