• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "dialog_model.h"
16 
17 #include "node_model.h"
18 
19 #include "base/error/error_code.h"
20 
21 #include "base/utils/utils.h"
22 
23 #include "node_model.h"
24 
25 namespace OHOS::Ace::DialogModel {
26 namespace {
27     constexpr double LEVEL_ORDER_MIN = -100000.0;
28     constexpr double LEVEL_ORDER_MAX = 100000.0;
29     constexpr int NUM_0 = 0;
30     constexpr int NUM_1 = 1;
31     constexpr int NUM_2 = 2;
32     constexpr int NUM_3 = 3;
33     constexpr int NUM_4 = 4;
34     constexpr int NUM_5 = 5;
35     constexpr int NUM_6 = 6;
36     const int ALLOW_SIZE_7(7);
37     constexpr int COLOR_STRATEGY_STYLE = 1;
38     constexpr int COLOR_STYLE = 2;
39 } // namespace
40 
Create()41 ArkUI_NativeDialogHandle Create()
42 {
43     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
44     if (!impl) {
45         return nullptr;
46     }
47     auto dialog = impl->getDialogAPI()->create();
48     return new ArkUI_NativeDialog({ dialog });
49 }
50 
Dispose(ArkUI_NativeDialogHandle handle)51 void Dispose(ArkUI_NativeDialogHandle handle)
52 {
53     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
54     if (!impl || !handle) {
55         return;
56     }
57     impl->getDialogAPI()->dispose(handle->controller);
58     delete handle;
59     handle = nullptr;
60 }
61 
SetContent(ArkUI_NativeDialogHandle handle,ArkUI_NodeHandle content)62 int32_t SetContent(ArkUI_NativeDialogHandle handle, ArkUI_NodeHandle content)
63 {
64     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
65     if (!impl || !handle || !content) {
66         return ERROR_CODE_PARAM_INVALID;
67     }
68     return impl->getDialogAPI()->setContent(handle->controller, content->uiNodeHandle);
69 }
70 
RemoveContent(ArkUI_NativeDialogHandle handle)71 int32_t RemoveContent(ArkUI_NativeDialogHandle handle)
72 {
73     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
74     if (!impl || !handle) {
75         return ERROR_CODE_PARAM_INVALID;
76     }
77     return impl->getDialogAPI()->removeContent(handle->controller);
78 }
79 
SetContentAlignment(ArkUI_NativeDialogHandle handle,int32_t alignment,float offsetX,float offsetY)80 int32_t SetContentAlignment(ArkUI_NativeDialogHandle handle, int32_t alignment, float offsetX, float offsetY)
81 {
82     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
83     if (!impl || !handle) {
84         return ERROR_CODE_PARAM_INVALID;
85     }
86     return impl->getDialogAPI()->setContentAlignment(handle->controller,
87         alignment, offsetX, offsetY);
88 }
89 
ResetContentAlignment(ArkUI_NativeDialogHandle handle)90 int32_t ResetContentAlignment(ArkUI_NativeDialogHandle handle)
91 {
92     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
93     if (!impl || !handle) {
94         return ERROR_CODE_PARAM_INVALID;
95     }
96     return impl->getDialogAPI()->resetContentAlignment(handle->controller);
97 }
98 
SetModalMode(ArkUI_NativeDialogHandle handle,bool isModal)99 int32_t SetModalMode(ArkUI_NativeDialogHandle handle, bool isModal)
100 {
101     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
102     if (!impl || !handle) {
103         return ERROR_CODE_PARAM_INVALID;
104     }
105     return impl->getDialogAPI()->setModalMode(handle->controller, isModal);
106 }
107 
SetAutoCancel(ArkUI_NativeDialogHandle handle,bool autoCancel)108 int32_t SetAutoCancel(ArkUI_NativeDialogHandle handle, bool autoCancel)
109 {
110     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
111     if (!impl || !handle) {
112         return ERROR_CODE_PARAM_INVALID;
113     }
114     return impl->getDialogAPI()->setAutoCancel(handle->controller, autoCancel);
115 }
116 
SetMask(ArkUI_NativeDialogHandle handle,uint32_t maskColor,const ArkUI_Rect * maskRect)117 int32_t SetMask(ArkUI_NativeDialogHandle handle, uint32_t maskColor, const ArkUI_Rect* maskRect)
118 {
119     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
120     if (!impl || !handle) {
121         return ERROR_CODE_PARAM_INVALID;
122     }
123     if (maskRect) {
124         ArkUIRect rect = { maskRect->x, maskRect->y, maskRect->width, maskRect->height };
125         return impl->getDialogAPI()->setMask(handle->controller, maskColor, &rect);
126     } else {
127         return impl->getDialogAPI()->setMask(handle->controller, maskColor, nullptr);
128     }
129 }
130 
SetBackgroundColor(ArkUI_NativeDialogHandle handle,uint32_t backgroundColor)131 int32_t SetBackgroundColor(ArkUI_NativeDialogHandle handle, uint32_t backgroundColor)
132 {
133     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
134     if (!impl || !handle) {
135         return ERROR_CODE_PARAM_INVALID;
136     }
137     return impl->getDialogAPI()->setBackgroundColor(handle->controller, backgroundColor);
138 }
139 
SetCornerRadius(ArkUI_NativeDialogHandle handle,float topLeft,float topRight,float bottomLeft,float bottomRight)140 int32_t SetCornerRadius(ArkUI_NativeDialogHandle handle, float topLeft, float topRight,
141     float bottomLeft, float bottomRight)
142 {
143     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
144     if (!impl || !handle) {
145         return ERROR_CODE_PARAM_INVALID;
146     }
147     return impl->getDialogAPI()->setCornerRadius(handle->controller,
148         topLeft, topRight, bottomLeft, bottomRight);
149 }
150 
SetGridColumnCount(ArkUI_NativeDialogHandle handle,int32_t gridCount)151 int32_t SetGridColumnCount(ArkUI_NativeDialogHandle handle, int32_t gridCount)
152 {
153     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
154     if (!impl || !handle) {
155         return ERROR_CODE_PARAM_INVALID;
156     }
157     return impl->getDialogAPI()->setGridColumnCount(handle->controller, gridCount);
158 }
159 
EnableCustomStyle(ArkUI_NativeDialogHandle handle,bool enableCustomStyle)160 int32_t EnableCustomStyle(ArkUI_NativeDialogHandle handle, bool enableCustomStyle)
161 {
162     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
163     if (!impl || !handle) {
164         return ERROR_CODE_PARAM_INVALID;
165     }
166     return impl->getDialogAPI()->enableCustomStyle(handle->controller, enableCustomStyle);
167 }
168 
EnableCustomAnimation(ArkUI_NativeDialogHandle handle,bool enableCustomAnimation)169 int32_t EnableCustomAnimation(ArkUI_NativeDialogHandle handle, bool enableCustomAnimation)
170 {
171     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
172     if (!impl || !handle) {
173         return ERROR_CODE_PARAM_INVALID;
174     }
175     return impl->getDialogAPI()->enableCustomAnimation(handle->controller, enableCustomAnimation);
176 }
177 
Show(ArkUI_NativeDialogHandle handle,bool showInSubWindow)178 int32_t Show(ArkUI_NativeDialogHandle handle, bool showInSubWindow)
179 {
180     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
181     if (!impl || !handle) {
182         return ERROR_CODE_PARAM_INVALID;
183     }
184     return impl->getDialogAPI()->show(handle->controller, showInSubWindow);
185 }
186 
Close(ArkUI_NativeDialogHandle handle)187 int32_t Close(ArkUI_NativeDialogHandle handle)
188 {
189     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
190     if (!impl || !handle) {
191         return ERROR_CODE_PARAM_INVALID;
192     }
193     return impl->getDialogAPI()->close(handle->controller);
194 }
195 
RegisterOnWillDismiss(ArkUI_NativeDialogHandle handle,ArkUI_OnWillDismissEvent eventHandler)196 int32_t RegisterOnWillDismiss(ArkUI_NativeDialogHandle handle, ArkUI_OnWillDismissEvent eventHandler)
197 {
198     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
199     if (!impl || !handle) {
200         return ERROR_CODE_PARAM_INVALID;
201     }
202     return impl->getDialogAPI()->registerOnWillDismiss(handle->controller, eventHandler);
203 }
204 
RegisterOnWillDismissWithUserData(ArkUI_NativeDialogHandle handle,void * userData,void (* callback)(ArkUI_DialogDismissEvent * event))205 int32_t RegisterOnWillDismissWithUserData(
206     ArkUI_NativeDialogHandle handle, void* userData, void (*callback)(ArkUI_DialogDismissEvent* event))
207 {
208     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
209     if (!impl || !handle) {
210         return ERROR_CODE_PARAM_INVALID;
211     }
212     int result = impl->getDialogAPI()->registerOnWillDismissWithUserData(handle->controller, userData, callback);
213     return result;
214 }
215 
SetKeyboardAvoidDistance(ArkUI_NativeDialogHandle handle,float distance,ArkUI_LengthMetricUnit unit)216 int32_t SetKeyboardAvoidDistance(
217     ArkUI_NativeDialogHandle handle, float distance, ArkUI_LengthMetricUnit unit)
218 {
219     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
220     if (!impl) {
221         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
222     }
223     if (!handle) {
224         return ARKUI_ERROR_CODE_PARAM_INVALID;
225     }
226     if (unit < ARKUI_LENGTH_METRIC_UNIT_DEFAULT || unit > ARKUI_LENGTH_METRIC_UNIT_FP) {
227         return ARKUI_ERROR_CODE_PARAM_INVALID;
228     }
229     int result = impl->getDialogAPI()->setKeyboardAvoidDistance(handle->controller, distance, unit);
230     return result;
231 }
232 
SetLevelMode(ArkUI_NativeDialogHandle handle,ArkUI_LevelMode levelMode)233 int32_t SetLevelMode(ArkUI_NativeDialogHandle handle, ArkUI_LevelMode levelMode)
234 {
235     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
236     if (!impl) {
237         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
238     }
239     if (!handle) {
240         return ARKUI_ERROR_CODE_PARAM_INVALID;
241     }
242     if (static_cast<int32_t>(levelMode) < static_cast<int32_t>(ARKUI_LEVEL_MODE_OVERLAY) ||
243         static_cast<int32_t>(levelMode) > static_cast<int32_t>(ARKUI_LEVEL_MODE_EMBEDDED)) {
244         return ARKUI_ERROR_CODE_PARAM_INVALID;
245     }
246     return impl->getDialogAPI()->setLevelMode(handle->controller, static_cast<int32_t>(levelMode));
247 }
248 
SetLevelUniqueId(ArkUI_NativeDialogHandle handle,int32_t uniqueId)249 int32_t SetLevelUniqueId(ArkUI_NativeDialogHandle handle, int32_t uniqueId)
250 {
251     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
252     if (!impl) {
253         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
254     }
255     if (!handle || uniqueId < 0) {
256         return ARKUI_ERROR_CODE_PARAM_INVALID;
257     }
258     return impl->getDialogAPI()->setLevelUniqueId(handle->controller, uniqueId);
259 }
260 
SetImmersiveMode(ArkUI_NativeDialogHandle handle,ArkUI_ImmersiveMode immersiveMode)261 int32_t SetImmersiveMode(ArkUI_NativeDialogHandle handle, ArkUI_ImmersiveMode immersiveMode)
262 {
263     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
264     if (!impl) {
265         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
266     }
267     if (!handle) {
268         return ARKUI_ERROR_CODE_PARAM_INVALID;
269     }
270     if (static_cast<int32_t>(immersiveMode) < static_cast<int32_t>(ARKUI_IMMERSIVE_MODE_DEFAULT) ||
271         static_cast<int32_t>(immersiveMode) > static_cast<int32_t>(ARKUI_IMMERSIVE_MODE_EXTEND)) {
272         return ARKUI_ERROR_CODE_PARAM_INVALID;
273     }
274     return impl->getDialogAPI()->setImmersiveMode(handle->controller, static_cast<int32_t>(immersiveMode));
275 }
276 
SetLevelOrder(ArkUI_NativeDialogHandle handle,double levelOrder)277 int32_t SetLevelOrder(ArkUI_NativeDialogHandle handle, double levelOrder)
278 {
279     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
280     if (!impl) {
281         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
282     }
283     if (!handle) {
284         return ARKUI_ERROR_CODE_PARAM_INVALID;
285     }
286     if (levelOrder < LEVEL_ORDER_MIN || levelOrder > LEVEL_ORDER_MAX) {
287         return ARKUI_ERROR_CODE_PARAM_INVALID;
288     }
289     return impl->getDialogAPI()->setLevelOrder(handle->controller, levelOrder);
290 }
291 
RegisterOnWillAppear(ArkUI_NativeDialogHandle handle,void * userData,void (* callback)(void * userData))292 int32_t RegisterOnWillAppear(ArkUI_NativeDialogHandle handle, void* userData, void (*callback)(void* userData))
293 {
294     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
295     if (!impl || !handle) {
296         return ARKUI_ERROR_CODE_PARAM_INVALID;
297     }
298     int result = impl->getDialogAPI()->registerOnWillAppear(handle->controller, userData, callback);
299     return result;
300 }
301 
RegisterOnDidAppear(ArkUI_NativeDialogHandle handle,void * userData,void (* callback)(void * userData))302 int32_t RegisterOnDidAppear(ArkUI_NativeDialogHandle handle, void* userData, void (*callback)(void* userData))
303 {
304     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
305     if (!impl || !handle) {
306         return ARKUI_ERROR_CODE_PARAM_INVALID;
307     }
308     int result = impl->getDialogAPI()->registerOnDidAppear(handle->controller, userData, callback);
309     return result;
310 }
311 
RegisterOnWillDisappear(ArkUI_NativeDialogHandle handle,void * userData,void (* callback)(void * userData))312 int32_t RegisterOnWillDisappear(ArkUI_NativeDialogHandle handle, void* userData, void (*callback)(void* userData))
313 {
314     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
315     if (!impl || !handle) {
316         return ARKUI_ERROR_CODE_PARAM_INVALID;
317     }
318     int result = impl->getDialogAPI()->registerOnWillDisappear(handle->controller, userData, callback);
319     return result;
320 }
321 
RegisterOnDidDisappear(ArkUI_NativeDialogHandle handle,void * userData,void (* callback)(void * userData))322 int32_t RegisterOnDidDisappear(ArkUI_NativeDialogHandle handle, void* userData, void (*callback)(void* userData))
323 {
324     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
325     if (!impl || !handle) {
326         return ARKUI_ERROR_CODE_PARAM_INVALID;
327     }
328     int result = impl->getDialogAPI()->registerOnDidDisappear(handle->controller, userData, callback);
329     return result;
330 }
331 
SetBorderWidth(ArkUI_NativeDialogHandle handle,float top,float right,float bottom,float left,ArkUI_LengthMetricUnit unit)332 int32_t SetBorderWidth(
333     ArkUI_NativeDialogHandle handle, float top, float right, float bottom, float left, ArkUI_LengthMetricUnit unit)
334 {
335     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
336     if (!impl) {
337         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
338     }
339     if (!handle) {
340         return ARKUI_ERROR_CODE_PARAM_INVALID;
341     }
342     if (unit < ARKUI_LENGTH_METRIC_UNIT_DEFAULT || unit > ARKUI_LENGTH_METRIC_UNIT_FP) {
343         return ARKUI_ERROR_CODE_PARAM_INVALID;
344     }
345     return impl->getDialogAPI()->setBorderWidth(handle->controller, top, right, bottom, left, unit);
346 }
347 
SetBorderColor(ArkUI_NativeDialogHandle handle,uint32_t top,uint32_t right,uint32_t bottom,uint32_t left)348 int32_t SetBorderColor(ArkUI_NativeDialogHandle handle, uint32_t top, uint32_t right, uint32_t bottom, uint32_t left)
349 {
350     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
351     if (!impl) {
352         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
353     }
354     if (!handle) {
355         return ARKUI_ERROR_CODE_PARAM_INVALID;
356     }
357     return impl->getDialogAPI()->setBorderColor(handle->controller, top, right, bottom, left);
358 }
359 
SetBorderStyle(ArkUI_NativeDialogHandle handle,int32_t top,int32_t right,int32_t bottom,int32_t left)360 int32_t SetBorderStyle(ArkUI_NativeDialogHandle handle, int32_t top, int32_t right, int32_t bottom, int32_t left)
361 {
362     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
363     if (!impl) {
364         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
365     }
366     if (!handle) {
367         return ARKUI_ERROR_CODE_PARAM_INVALID;
368     }
369     return impl->getDialogAPI()->setBorderStyle(handle->controller, top, right, bottom, left);
370 }
371 
SetWidth(ArkUI_NativeDialogHandle handle,float width,ArkUI_LengthMetricUnit unit)372 int32_t SetWidth(ArkUI_NativeDialogHandle handle, float width, ArkUI_LengthMetricUnit unit)
373 {
374     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
375     if (!impl) {
376         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
377     }
378     if (!handle) {
379         return ARKUI_ERROR_CODE_PARAM_INVALID;
380     }
381     if (unit < ARKUI_LENGTH_METRIC_UNIT_DEFAULT || unit > ARKUI_LENGTH_METRIC_UNIT_FP) {
382         return ARKUI_ERROR_CODE_PARAM_INVALID;
383     }
384     int result = impl->getDialogAPI()->setWidth(handle->controller, width, unit);
385     return result;
386 }
387 
SetHeight(ArkUI_NativeDialogHandle handle,float height,ArkUI_LengthMetricUnit unit)388 int32_t SetHeight(ArkUI_NativeDialogHandle handle, float height, ArkUI_LengthMetricUnit unit)
389 {
390     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
391     if (!impl) {
392         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
393     }
394     if (!handle) {
395         return ARKUI_ERROR_CODE_PARAM_INVALID;
396     }
397     if (unit < ARKUI_LENGTH_METRIC_UNIT_DEFAULT || unit > ARKUI_LENGTH_METRIC_UNIT_FP) {
398         return ARKUI_ERROR_CODE_PARAM_INVALID;
399     }
400     int result = impl->getDialogAPI()->setHeight(handle->controller, height, unit);
401     return result;
402 }
403 
SetShadow(ArkUI_NativeDialogHandle handle,ArkUI_ShadowStyle shadow)404 int32_t SetShadow(ArkUI_NativeDialogHandle handle, ArkUI_ShadowStyle shadow)
405 {
406     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
407     if (!impl) {
408         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
409     }
410     if (!handle) {
411         return ARKUI_ERROR_CODE_PARAM_INVALID;
412     }
413     int result = impl->getDialogAPI()->setShadow(handle->controller, shadow);
414     return result;
415 }
416 
SetCustomShadow(ArkUI_NativeDialogHandle handle,const ArkUI_AttributeItem * customShadow)417 int32_t SetCustomShadow(ArkUI_NativeDialogHandle handle, const ArkUI_AttributeItem* customShadow)
418 {
419     if (customShadow->size == 0) {
420         return ARKUI_ERROR_CODE_PARAM_INVALID;
421     }
422     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
423     if (!impl) {
424         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
425     }
426     if (!handle) {
427         return ARKUI_ERROR_CODE_PARAM_INVALID;
428     }
429     ArkUIInt32orFloat32 shadows[ALLOW_SIZE_7] = { 0, { .i32 = NUM_2 }, 0, 0, { .i32 = 0 }, { .u32 = 0 }, { .i32 = 0 } };
430     int length = customShadow->size;
431     if (length > NUM_0) {
432         if (LessNotEqual(customShadow->value[NUM_0].f32, 0.0f)) {
433             return ARKUI_ERROR_CODE_PARAM_INVALID;
434         }
435         shadows[NUM_0].f32 = customShadow->value[NUM_0].f32; // radius
436     }
437     if (length > NUM_2) {
438         shadows[NUM_2].f32 = customShadow->value[NUM_2].f32; // OffsetX
439     }
440     if (length > NUM_3) {
441         shadows[NUM_3].f32 = customShadow->value[NUM_3].f32; // OffsetY
442     }
443     if (length > NUM_4) {
444         if (!InRegion(NUM_0, NUM_1, customShadow->value[NUM_4].i32)) {
445             return ARKUI_ERROR_CODE_PARAM_INVALID;
446         }
447         shadows[NUM_4].i32 = customShadow->value[NUM_4].i32;
448     }
449     if (length > NUM_5) {
450         if (customShadow->value[NUM_1].i32) {
451             if (!InRegion(NUM_0, NUM_2, customShadow->value[NUM_5].i32)) {
452                 return ARKUI_ERROR_CODE_PARAM_INVALID;
453             }
454             shadows[NUM_1].i32 = COLOR_STRATEGY_STYLE;
455             shadows[NUM_5].i32 = customShadow->value[NUM_5].i32;
456         } else {
457             shadows[NUM_1].i32 = COLOR_STYLE;
458             shadows[NUM_5].u32 = customShadow->value[NUM_5].u32;
459         }
460     }
461     if (length > NUM_6) {
462         shadows[NUM_6].i32 = customShadow->value[NUM_6].i32;
463     }
464     int result = impl->getDialogAPI()->setCustomShadow(handle->controller, shadows, ALLOW_SIZE_7);
465     return result;
466 }
467 
SetBackgroundBlurStyle(ArkUI_NativeDialogHandle handle,ArkUI_BlurStyle blurStyle)468 int32_t SetBackgroundBlurStyle(ArkUI_NativeDialogHandle handle, ArkUI_BlurStyle blurStyle)
469 {
470     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
471     if (!impl) {
472         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
473     }
474     if (!handle) {
475         return ARKUI_ERROR_CODE_PARAM_INVALID;
476     }
477     int result = impl->getDialogAPI()->setBackgroundBlurStyle(handle->controller, blurStyle);
478     return result;
479 }
480 
SetKeyboardAvoidMode(ArkUI_NativeDialogHandle handle,ArkUI_KeyboardAvoidMode keyboardAvoidMode)481 int32_t SetKeyboardAvoidMode(ArkUI_NativeDialogHandle handle, ArkUI_KeyboardAvoidMode keyboardAvoidMode)
482 {
483     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
484     if (!impl) {
485         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
486     }
487     if (!handle) {
488         return ARKUI_ERROR_CODE_PARAM_INVALID;
489     }
490     int result = impl->getDialogAPI()->setKeyboardAvoidMode(handle->controller, keyboardAvoidMode);
491     return result;
492 }
493 
EnableHoverMode(ArkUI_NativeDialogHandle handle,bool enableHoverMode)494 int32_t EnableHoverMode(ArkUI_NativeDialogHandle handle, bool enableHoverMode)
495 {
496     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
497     if (!impl) {
498         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
499     }
500     if (!handle) {
501         return ARKUI_ERROR_CODE_PARAM_INVALID;
502     }
503     int result = impl->getDialogAPI()->enableHoverMode(handle->controller, enableHoverMode);
504     return result;
505 }
506 
SetHoverModeArea(ArkUI_NativeDialogHandle handle,ArkUI_HoverModeAreaType hoverModeAreaType)507 int32_t SetHoverModeArea(ArkUI_NativeDialogHandle handle, ArkUI_HoverModeAreaType hoverModeAreaType)
508 {
509     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
510     if (!impl) {
511         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
512     }
513     if (!handle) {
514         return ARKUI_ERROR_CODE_PARAM_INVALID;
515     }
516     int result = impl->getDialogAPI()->setHoverModeArea(handle->controller, hoverModeAreaType);
517     return result;
518 }
519 
SetFocusable(ArkUI_NativeDialogHandle handle,bool focusable)520 int32_t SetFocusable(ArkUI_NativeDialogHandle handle, bool focusable)
521 {
522     const auto* impl = OHOS::Ace::NodeModel::GetFullImpl();
523     if (!impl) {
524         return ARKUI_ERROR_CODE_CAPI_INIT_ERROR;
525     }
526     if (!handle) {
527         return ARKUI_ERROR_CODE_PARAM_INVALID;
528     }
529     return impl->getDialogAPI()->setFocusable(handle->controller, focusable);
530 }
531 } // namespace OHOS::Ace::NG::DialogModel
532 
533 #ifdef __cplusplus
534 extern "C" {
535 #endif
536 
OH_ArkUI_DialogDismissEvent_SetShouldBlockDismiss(ArkUI_DialogDismissEvent * event,bool shouldBlockDismiss)537 void OH_ArkUI_DialogDismissEvent_SetShouldBlockDismiss(ArkUI_DialogDismissEvent* event, bool shouldBlockDismiss)
538 {
539     if (!event) {
540         return;
541     }
542     event->BlockDismiss = shouldBlockDismiss;
543 }
544 
OH_ArkUI_DialogDismissEvent_GetUserData(ArkUI_DialogDismissEvent * event)545 void* OH_ArkUI_DialogDismissEvent_GetUserData(ArkUI_DialogDismissEvent* event)
546 {
547     if (!event) {
548         return nullptr;
549     }
550     return event->userData;
551 }
552 
OH_ArkUI_DialogDismissEvent_GetDismissReason(ArkUI_DialogDismissEvent * event)553 int32_t OH_ArkUI_DialogDismissEvent_GetDismissReason(ArkUI_DialogDismissEvent* event)
554 {
555     if (!event) {
556         return -1;
557     }
558     return event->reason;
559 }
560 
561 #ifdef __cplusplus
562 };
563 #endif