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/** 17 * @file 18 * @kit ArkUI 19 */ 20 21 22import { AsyncCallback } from './@ohos.base'; 23 24/** 25 * @namespace promptAction 26 * @syscap SystemCapability.ArkUI.ArkUI.Full 27 * @since 9 28 */ 29/** 30 * @namespace promptAction 31 * @syscap SystemCapability.ArkUI.ArkUI.Full 32 * @crossplatform 33 * @since 10 34 */ 35/** 36 * @namespace promptAction 37 * @syscap SystemCapability.ArkUI.ArkUI.Full 38 * @crossplatform 39 * @atomicservice 40 * @since 11 41 */ 42declare namespace promptAction { 43 /** 44 * @typedef ShowToastOptions 45 * @syscap SystemCapability.ArkUI.ArkUI.Full 46 * @since 9 47 */ 48 /** 49 * @typedef ShowToastOptions 50 * @syscap SystemCapability.ArkUI.ArkUI.Full 51 * @crossplatform 52 * @since 10 53 */ 54 /** 55 * @typedef ShowToastOptions 56 * @syscap SystemCapability.ArkUI.ArkUI.Full 57 * @crossplatform 58 * @atomicservice 59 * @since 11 60 */ 61 interface ShowToastOptions { 62 63 /** 64 * Text to display. 65 * 66 * @type { string | Resource } 67 * @syscap SystemCapability.ArkUI.ArkUI.Full 68 * @since 9 69 */ 70 /** 71 * Text to display. 72 * 73 * @type { string | Resource } 74 * @syscap SystemCapability.ArkUI.ArkUI.Full 75 * @crossplatform 76 * @since 10 77 */ 78 /** 79 * Text to display. 80 * 81 * @type { string | Resource } 82 * @syscap SystemCapability.ArkUI.ArkUI.Full 83 * @crossplatform 84 * @atomicservice 85 * @since 11 86 */ 87 message: string | Resource; 88 89 /** 90 * Duration of toast dialog box. The default value is 1500. 91 * The recommended value ranges from 1500ms to 10000ms. 92 * NOTE: A value less than 1500 is automatically changed to 1500. The maximum value is 10000ms. 93 * 94 * @type { ?number } 95 * @syscap SystemCapability.ArkUI.ArkUI.Full 96 * @since 9 97 */ 98 /** 99 * Duration of toast dialog box. The default value is 1500. 100 * The recommended value ranges from 1500ms to 10000ms. 101 * NOTE: A value less than 1500 is automatically changed to 1500. The maximum value is 10000ms. 102 * 103 * @type { ?number } 104 * @syscap SystemCapability.ArkUI.ArkUI.Full 105 * @crossplatform 106 * @since 10 107 */ 108 /** 109 * Duration of toast dialog box. The default value is 1500. 110 * The recommended value ranges from 1500ms to 10000ms. 111 * NOTE: A value less than 1500 is automatically changed to 1500. The maximum value is 10000ms. 112 * 113 * @type { ?number } 114 * @syscap SystemCapability.ArkUI.ArkUI.Full 115 * @crossplatform 116 * @atomicservice 117 * @since 11 118 */ 119 duration?: number; 120 121 /** 122 * The distance between toast dialog box and the bottom of screen. 123 * 124 * @type { ?(string | number) } 125 * @syscap SystemCapability.ArkUI.ArkUI.Full 126 * @since 9 127 */ 128 /** 129 * The distance between toast dialog box and the bottom of screen. 130 * 131 * @type { ?(string | number) } 132 * @syscap SystemCapability.ArkUI.ArkUI.Full 133 * @crossplatform 134 * @since 10 135 */ 136 /** 137 * The distance between toast dialog box and the bottom of screen. 138 * 139 * @type { ?(string | number) } 140 * @syscap SystemCapability.ArkUI.ArkUI.Full 141 * @crossplatform 142 * @atomicservice 143 * @since 11 144 */ 145 bottom?: string | number; 146 147 /** 148 * Determine the show mode of the toast. 149 * 150 * @type { ?ToastShowMode } 151 * @default ToastShowMode.DEFAULT 152 * @syscap SystemCapability.ArkUI.ArkUI.Full 153 * @since 11 154 */ 155 /** 156 * Determine the show mode of the toast. 157 * 158 * @type { ?ToastShowMode } 159 * @default ToastShowMode.DEFAULT 160 * @syscap SystemCapability.ArkUI.ArkUI.Full 161 * @crossplatform 162 * @atomicservice 163 * @since 12 164 */ 165 showMode?: ToastShowMode; 166 /** 167 * Defines the toast alignment of the screen. 168 * 169 * @type { ?Alignment } 170 * @syscap SystemCapability.ArkUI.ArkUI.Full 171 * @crossplatform 172 * @atomicservice 173 * @since 12 174 */ 175 alignment?: Alignment; 176 /** 177 * Defines the toast offset. 178 * 179 * @type { ?Offset } 180 * @syscap SystemCapability.ArkUI.ArkUI.Full 181 * @crossplatform 182 * @atomicservice 183 * @since 12 184 */ 185 offset?: Offset; 186 /** 187 * Background color of toast. 188 * 189 * @type { ?ResourceColor } 190 * @syscap SystemCapability.ArkUI.ArkUI.Full 191 * @crossplatform 192 * @atomicservice 193 * @since 12 194 */ 195 backgroundColor?: ResourceColor; 196 /** 197 * Text color of toast. 198 * 199 * @type { ?ResourceColor } 200 * @syscap SystemCapability.ArkUI.ArkUI.Full 201 * @crossplatform 202 * @atomicservice 203 * @since 12 204 */ 205 textColor?: ResourceColor; 206 /** 207 * Background blur Style of toast. 208 * 209 * @type { ?BlurStyle } 210 * @syscap SystemCapability.ArkUI.ArkUI.Full 211 * @crossplatform 212 * @atomicservice 213 * @since 12 214 */ 215 backgroundBlurStyle?: BlurStyle; 216 /** 217 * Shadow of toast. 218 * 219 * @type { ?(ShadowOptions | ShadowStyle) } 220 * @syscap SystemCapability.ArkUI.ArkUI.Full 221 * @crossplatform 222 * @atomicservice 223 * @since 12 224 */ 225 shadow?: ShadowOptions | ShadowStyle; 226 227 /** 228 * Define whether to respond to the hover mode. 229 * 230 * @type { ?boolean } 231 * @default false 232 * @syscap SystemCapability.ArkUI.ArkUI.Full 233 * @crossplatform 234 * @atomicservice 235 * @since 14 236 */ 237 enableHoverMode?: boolean; 238 239 /** 240 * Defines the toast's display area in hover mode. 241 * 242 * @type { ?HoverModeAreaType } 243 * @default HoverModeAreaType.BOTTOM_SCREEN 244 * @syscap SystemCapability.ArkUI.ArkUI.Full 245 * @crossplatform 246 * @atomicservice 247 * @since 14 248 */ 249 hoverModeArea?: HoverModeAreaType; 250 } 251 252 /** 253 * Enum for the toast showMode. 254 * 255 * @enum { number } 256 * @syscap SystemCapability.ArkUI.ArkUI.Full 257 * @since 11 258 */ 259 /** 260 * Enum for the toast showMode. 261 * 262 * @enum { number } 263 * @syscap SystemCapability.ArkUI.ArkUI.Full 264 * @crossplatform 265 * @atomicservice 266 * @since 12 267 */ 268 export enum ToastShowMode { 269 /** 270 * Toast shows in app. 271 * 272 * @syscap SystemCapability.ArkUI.ArkUI.Full 273 * @since 11 274 */ 275 /** 276 * Toast shows in app. 277 * 278 * @syscap SystemCapability.ArkUI.ArkUI.Full 279 * @crossplatform 280 * @atomicservice 281 * @since 12 282 */ 283 DEFAULT = 0, 284 285 /** 286 * Toast shows at the top. 287 * 288 * @syscap SystemCapability.ArkUI.ArkUI.Full 289 * @since 11 290 */ 291 /** 292 * Toast shows at the top. 293 * 294 * @syscap SystemCapability.ArkUI.ArkUI.Full 295 * @crossplatform 296 * @atomicservice 297 * @since 12 298 */ 299 TOP_MOST = 1, 300 301 /** 302 * Toast shows in SYSTEM_TOAST window. 303 * 304 * @syscap SystemCapability.ArkUI.ArkUI.Full 305 * @systemapi 306 * @since 12 307 */ 308 SYSTEM_TOP_MOST = 2 309 } 310 311 /** 312 * @typedef Button 313 * @syscap SystemCapability.ArkUI.ArkUI.Full 314 * @since 9 315 */ 316 /** 317 * @typedef Button 318 * @syscap SystemCapability.ArkUI.ArkUI.Full 319 * @crossplatform 320 * @since 10 321 */ 322 /** 323 * @typedef Button 324 * @syscap SystemCapability.ArkUI.ArkUI.Full 325 * @crossplatform 326 * @atomicservice 327 * @since 11 328 */ 329 interface Button { 330 331 /** 332 * The text displayed in the button. 333 * 334 * @type { string | Resource } 335 * @syscap SystemCapability.ArkUI.ArkUI.Full 336 * @since 9 337 */ 338 /** 339 * The text displayed in the button. 340 * 341 * @type { string | Resource } 342 * @syscap SystemCapability.ArkUI.ArkUI.Full 343 * @crossplatform 344 * @since 10 345 */ 346 /** 347 * The text displayed in the button. 348 * 349 * @type { string | Resource } 350 * @syscap SystemCapability.ArkUI.ArkUI.Full 351 * @crossplatform 352 * @atomicservice 353 * @since 11 354 */ 355 text: string | Resource; 356 357 /** 358 * The foreground color of button. 359 * 360 * @type { string | Resource } 361 * @syscap SystemCapability.ArkUI.ArkUI.Full 362 * @since 9 363 */ 364 /** 365 * The foreground color of button. 366 * 367 * @type { string | Resource } 368 * @syscap SystemCapability.ArkUI.ArkUI.Full 369 * @crossplatform 370 * @since 10 371 */ 372 /** 373 * The foreground color of button. 374 * 375 * @type { string | Resource } 376 * @syscap SystemCapability.ArkUI.ArkUI.Full 377 * @crossplatform 378 * @atomicservice 379 * @since 11 380 */ 381 color: string | Resource; 382 /** 383 * Define whether the button responds to Enter/Space key by default. 384 * 385 * @type { ?boolean } 386 * @syscap SystemCapability.ArkUI.ArkUI.Full 387 * @crossplatform 388 * @atomicservice 389 * @since 12 390 */ 391 primary?: boolean; 392 } 393 394 /** 395 * @typedef ShowDialogSuccessResponse 396 * @syscap SystemCapability.ArkUI.ArkUI.Full 397 * @since 9 398 */ 399 /** 400 * @typedef ShowDialogSuccessResponse 401 * @syscap SystemCapability.ArkUI.ArkUI.Full 402 * @crossplatform 403 * @since 10 404 */ 405 /** 406 * @typedef ShowDialogSuccessResponse 407 * @syscap SystemCapability.ArkUI.ArkUI.Full 408 * @crossplatform 409 * @atomicservice 410 * @since 11 411 */ 412 interface ShowDialogSuccessResponse { 413 414 /** 415 * Index of the selected button, starting from 0. 416 * 417 * @type { number } 418 * @syscap SystemCapability.ArkUI.ArkUI.Full 419 * @since 9 420 */ 421 /** 422 * Index of the selected button, starting from 0. 423 * 424 * @type { number } 425 * @syscap SystemCapability.ArkUI.ArkUI.Full 426 * @crossplatform 427 * @since 10 428 */ 429 /** 430 * Index of the selected button, starting from 0. 431 * 432 * @type { number } 433 * @syscap SystemCapability.ArkUI.ArkUI.Full 434 * @crossplatform 435 * @atomicservice 436 * @since 11 437 */ 438 index: number; 439 } 440 441 /** 442 * @typedef ShowDialogOptions 443 * @syscap SystemCapability.ArkUI.ArkUI.Full 444 * @since 9 445 */ 446 /** 447 * @typedef ShowDialogOptions 448 * @syscap SystemCapability.ArkUI.ArkUI.Full 449 * @crossplatform 450 * @since 10 451 */ 452 /** 453 * @typedef ShowDialogOptions 454 * @syscap SystemCapability.ArkUI.ArkUI.Full 455 * @crossplatform 456 * @atomicservice 457 * @since 11 458 */ 459 interface ShowDialogOptions { 460 461 /** 462 * Title of the text to display. 463 * 464 * @type { ?(string | Resource) } 465 * @syscap SystemCapability.ArkUI.ArkUI.Full 466 * @since 9 467 */ 468 /** 469 * Title of the text to display. 470 * 471 * @type { ?(string | Resource) } 472 * @syscap SystemCapability.ArkUI.ArkUI.Full 473 * @crossplatform 474 * @since 10 475 */ 476 /** 477 * Title of the text to display. 478 * 479 * @type { ?(string | Resource) } 480 * @syscap SystemCapability.ArkUI.ArkUI.Full 481 * @crossplatform 482 * @atomicservice 483 * @since 11 484 */ 485 title?: string | Resource; 486 487 /** 488 * Text body. 489 * 490 * @type { ?(string | Resource) } 491 * @syscap SystemCapability.ArkUI.ArkUI.Full 492 * @since 9 493 */ 494 /** 495 * Text body. 496 * 497 * @type { ?(string | Resource) } 498 * @syscap SystemCapability.ArkUI.ArkUI.Full 499 * @crossplatform 500 * @since 10 501 */ 502 /** 503 * Text body. 504 * 505 * @type { ?(string | Resource) } 506 * @syscap SystemCapability.ArkUI.ArkUI.Full 507 * @crossplatform 508 * @atomicservice 509 * @since 11 510 */ 511 message?: string | Resource; 512 513 /** 514 * Array of buttons in the dialog box. 515 * The array structure is {text:'button', color: '#666666'}. 516 * One to three buttons are supported. 517 * The first button is of the positiveButton type, the second is of the negativeButton type, and the third is of the neutralButton type. 518 * 519 * @type { ?Array<Button> } 520 * @syscap SystemCapability.ArkUI.ArkUI.Full 521 * @since 9 522 */ 523 /** 524 * Array of buttons in the dialog box. 525 * The array structure is {text:'button', color: '#666666'}. 526 * More than one buttons are supported. 527 * 528 * @type { ?Array<Button> } 529 * @syscap SystemCapability.ArkUI.ArkUI.Full 530 * @crossplatform 531 * @since 10 532 */ 533 /** 534 * Array of buttons in the dialog box. 535 * The array structure is {text:'button', color: '#666666'}. 536 * More than one buttons are supported. 537 * 538 * @type { ?Array<Button> } 539 * @syscap SystemCapability.ArkUI.ArkUI.Full 540 * @crossplatform 541 * @atomicservice 542 * @since 11 543 */ 544 buttons?: Array<Button>; 545 546 /** 547 * Mask Region of dialog. The size can't exceed the main window. 548 * 549 * @type { ?Rectangle } 550 * @syscap SystemCapability.ArkUI.ArkUI.Full 551 * @crossplatform 552 * @since 10 553 */ 554 /** 555 * Mask Region of dialog. The size can't exceed the main window. 556 * 557 * @type { ?Rectangle } 558 * @syscap SystemCapability.ArkUI.ArkUI.Full 559 * @crossplatform 560 * @atomicservice 561 * @since 11 562 */ 563 maskRect?: Rectangle; 564 565 /** 566 * Defines the dialog alignment of the screen. 567 * 568 * @type { ?DialogAlignment } 569 * @syscap SystemCapability.ArkUI.ArkUI.Full 570 * @crossplatform 571 * @since 10 572 */ 573 /** 574 * Defines the dialog alignment of the screen. 575 * 576 * @type { ?DialogAlignment } 577 * @syscap SystemCapability.ArkUI.ArkUI.Full 578 * @crossplatform 579 * @atomicservice 580 * @since 11 581 */ 582 alignment?: DialogAlignment; 583 584 /** 585 * Defines the dialog offset. 586 * 587 * @type { ?Offset } 588 * @syscap SystemCapability.ArkUI.ArkUI.Full 589 * @crossplatform 590 * @since 10 591 */ 592 /** 593 * Defines the dialog offset. 594 * 595 * @type { ?Offset } 596 * @syscap SystemCapability.ArkUI.ArkUI.Full 597 * @crossplatform 598 * @atomicservice 599 * @since 11 600 */ 601 offset?: Offset; 602 603 /** 604 * Whether to display in the sub window. 605 * 606 * @type { ?boolean } 607 * @default false 608 * @syscap SystemCapability.ArkUI.ArkUI.Full 609 * @crossplatform 610 * @since 11 611 */ 612 /** 613 * Whether to display in the sub window. 614 * 615 * @type { ?boolean } 616 * @default false 617 * @syscap SystemCapability.ArkUI.ArkUI.Full 618 * @crossplatform 619 * @atomicservice 620 * @since 12 621 */ 622 showInSubWindow?: boolean; 623 624 /** 625 * Whether it is a modal dialog 626 * @type { ?boolean } 627 * @default true 628 * @syscap SystemCapability.ArkUI.ArkUI.Full 629 * @crossplatform 630 * @since 11 631 */ 632 /** 633 * Whether it is a modal dialog 634 * @type { ?boolean } 635 * @default true 636 * @syscap SystemCapability.ArkUI.ArkUI.Full 637 * @crossplatform 638 * @atomicservice 639 * @since 12 640 */ 641 isModal?: boolean; 642 643 /** 644 * Defines the dialog's background color. 645 * 646 * @type { ?ResourceColor } 647 * @default Color.Transparent 648 * @syscap SystemCapability.ArkUI.ArkUI.Full 649 * @crossplatform 650 * @atomicservice 651 * @since 12 652 */ 653 backgroundColor?: ResourceColor; 654 655 /** 656 * Defines the dialog's background blur Style 657 * 658 * @type { ?BlurStyle } 659 * @default BlurStyle.COMPONENT_ULTRA_THICK 660 * @syscap SystemCapability.ArkUI.ArkUI.Full 661 * @crossplatform 662 * @atomicservice 663 * @since 12 664 */ 665 backgroundBlurStyle?: BlurStyle; 666 667 /** 668 * Defines the dialog's shadow. 669 * 670 * @type { ?(ShadowOptions | ShadowStyle) } 671 * @syscap SystemCapability.ArkUI.ArkUI.Full 672 * @crossplatform 673 * @atomicservice 674 * @since 12 675 */ 676 shadow?: ShadowOptions | ShadowStyle; 677 678 /** 679 * Defines whether to respond to the hover mode. 680 * 681 * @type { ?boolean } 682 * @default false 683 * @syscap SystemCapability.ArkUI.ArkUI.Full 684 * @crossplatform 685 * @atomicservice 686 * @since 14 687 */ 688 enableHoverMode?: boolean; 689 690 /** 691 * Defines the dialog's display area in hover mode. 692 * 693 * @type { ?HoverModeAreaType } 694 * @default HoverModeAreaType.BOTTOM_SCREEN 695 * @syscap SystemCapability.ArkUI.ArkUI.Full 696 * @crossplatform 697 * @atomicservice 698 * @since 14 699 */ 700 hoverModeArea?: HoverModeAreaType; 701 } 702 703 /** 704 * Dialog base options 705 * 706 * @typedef BaseDialogOptions 707 * @syscap SystemCapability.ArkUI.ArkUI.Full 708 * @crossplatform 709 * @since 11 710 */ 711 /** 712 * Dialog base options 713 * 714 * @typedef BaseDialogOptions 715 * @syscap SystemCapability.ArkUI.ArkUI.Full 716 * @crossplatform 717 * @atomicservice 718 * @since 12 719 */ 720 interface BaseDialogOptions { 721 /** 722 * Mask Region of dialog. The size can't exceed the main window. 723 * 724 * @type { ?Rectangle } 725 * @syscap SystemCapability.ArkUI.ArkUI.Full 726 * @crossplatform 727 * @since 11 728 */ 729 /** 730 * Mask Region of dialog. The size can't exceed the main window. 731 * 732 * @type { ?Rectangle } 733 * @syscap SystemCapability.ArkUI.ArkUI.Full 734 * @crossplatform 735 * @atomicservice 736 * @since 12 737 */ 738 maskRect?: Rectangle; 739 740 /** 741 * Defines the dialog alignment of the screen. 742 * 743 * @type { ?DialogAlignment } 744 * @syscap SystemCapability.ArkUI.ArkUI.Full 745 * @crossplatform 746 * @since 11 747 */ 748 /** 749 * Defines the dialog alignment of the screen. 750 * 751 * @type { ?DialogAlignment } 752 * @syscap SystemCapability.ArkUI.ArkUI.Full 753 * @crossplatform 754 * @atomicservice 755 * @since 12 756 */ 757 alignment?: DialogAlignment; 758 759 /** 760 * Defines the dialog offset. 761 * 762 * @type { ?Offset } 763 * @syscap SystemCapability.ArkUI.ArkUI.Full 764 * @crossplatform 765 * @since 11 766 */ 767 /** 768 * Defines the dialog offset. 769 * 770 * @type { ?Offset } 771 * @syscap SystemCapability.ArkUI.ArkUI.Full 772 * @crossplatform 773 * @atomicservice 774 * @since 12 775 */ 776 offset?: Offset; 777 778 /** 779 * Whether to display in the sub window. 780 * 781 * @type { ?boolean } 782 * @default false 783 * @syscap SystemCapability.ArkUI.ArkUI.Full 784 * @crossplatform 785 * @since 11 786 */ 787 /** 788 * Whether to display in the sub window. 789 * 790 * @type { ?boolean } 791 * @default false 792 * @syscap SystemCapability.ArkUI.ArkUI.Full 793 * @crossplatform 794 * @atomicservice 795 * @since 12 796 */ 797 showInSubWindow?: boolean; 798 799 /** 800 * Whether it is a modal dialog 801 * @type { ?boolean } 802 * @default true 803 * @syscap SystemCapability.ArkUI.ArkUI.Full 804 * @crossplatform 805 * @since 11 806 */ 807 /** 808 * Whether it is a modal dialog 809 * @type { ?boolean } 810 * @default true 811 * @syscap SystemCapability.ArkUI.ArkUI.Full 812 * @crossplatform 813 * @atomicservice 814 * @since 12 815 */ 816 isModal?: boolean; 817 818 /** 819 * Allows users to click the mask layer to exit. 820 * 821 * @type { ?boolean } 822 * @default true 823 * @syscap SystemCapability.ArkUI.ArkUI.Full 824 * @crossplatform 825 * @atomicservice 826 * @since 12 827 */ 828 autoCancel?: boolean; 829 830 /** 831 * Transition parameters of opening/closing custom dialog. 832 * 833 * @type { ?TransitionEffect } 834 * @syscap SystemCapability.ArkUI.ArkUI.Full 835 * @crossplatform 836 * @atomicservice 837 * @since 12 838 */ 839 transition?: TransitionEffect; 840 841 /** 842 * Defines custom dialog maskColor 843 * 844 * @type { ?ResourceColor } 845 * @syscap SystemCapability.ArkUI.ArkUI.Full 846 * @crossplatform 847 * @atomicservice 848 * @since 12 849 */ 850 maskColor?: ResourceColor; 851 852 /** 853 * Callback function when the CustomDialog interactive dismiss. 854 * 855 * @type { ?Callback<DismissDialogAction> } 856 * @syscap SystemCapability.ArkUI.ArkUI.Full 857 * @crossplatform 858 * @atomicservice 859 * @since 12 860 */ 861 onWillDismiss?: Callback<DismissDialogAction>; 862 863 /** 864 * Callback function when the dialog appears. 865 * 866 * @type { ?function } 867 * @syscap SystemCapability.ArkUI.ArkUI.Full 868 * @crossplatform 869 * @atomicservice 870 * @since 12 871 */ 872 onDidAppear?: () => void; 873 874 /** 875 * Callback function when the dialog disappears. 876 * 877 * @type { ?function } 878 * @syscap SystemCapability.ArkUI.ArkUI.Full 879 * @crossplatform 880 * @atomicservice 881 * @since 12 882 */ 883 onDidDisappear?: () => void; 884 885 /** 886 * Callback function before the dialog openAnimation starts. 887 * 888 * @type { ?function } 889 * @syscap SystemCapability.ArkUI.ArkUI.Full 890 * @crossplatform 891 * @atomicservice 892 * @since 12 893 */ 894 onWillAppear?: () => void; 895 896 /** 897 * Callback function before the dialog closeAnimation starts. 898 * 899 * @type { ?function } 900 * @syscap SystemCapability.ArkUI.ArkUI.Full 901 * @crossplatform 902 * @atomicservice 903 * @since 12 904 */ 905 onWillDisappear?: () => void; 906 907 /** 908 * Defines the customDialog's keyboard avoid mode 909 * 910 * @type { ?KeyboardAvoidMode } 911 * @default KeyboardAvoidMode.DEFAULT 912 * @syscap SystemCapability.ArkUI.ArkUI.Full 913 * @crossplatform 914 * @atomicservice 915 * @since 12 916 */ 917 keyboardAvoidMode?: KeyboardAvoidMode; 918 919 /** 920 * Defines whether to respond to the hover mode. 921 * 922 * @type { ?boolean } 923 * @default false 924 * @syscap SystemCapability.ArkUI.ArkUI.Full 925 * @crossplatform 926 * @atomicservice 927 * @since 14 928 */ 929 enableHoverMode?: boolean; 930 931 /** 932 * Defines the dialog's display area in hover mode. 933 * 934 * @type { ?HoverModeAreaType } 935 * @default HoverModeAreaType.BOTTOM_SCREEN 936 * @syscap SystemCapability.ArkUI.ArkUI.Full 937 * @crossplatform 938 * @atomicservice 939 * @since 14 940 */ 941 hoverModeArea?: HoverModeAreaType; 942 } 943 944 /** 945 * Dialog's custom content options 946 * 947 * @interface CustomDialogOptions 948 * @syscap SystemCapability.ArkUI.ArkUI.Full 949 * @crossplatform 950 * @since 11 951 */ 952 /** 953 * Dialog's custom content options 954 * 955 * @interface CustomDialogOptions 956 * @syscap SystemCapability.ArkUI.ArkUI.Full 957 * @crossplatform 958 * @atomicservice 959 * @since 12 960 */ 961 interface CustomDialogOptions extends BaseDialogOptions { 962 /** 963 * Allow developer custom dialog's content. 964 * 965 * @type { CustomBuilder } 966 * @syscap SystemCapability.ArkUI.ArkUI.Full 967 * @crossplatform 968 * @since 11 969 */ 970 /** 971 * Allow developer custom dialog's content. 972 * 973 * @type { CustomBuilder } 974 * @syscap SystemCapability.ArkUI.ArkUI.Full 975 * @crossplatform 976 * @atomicservice 977 * @since 12 978 */ 979 builder: CustomBuilder; 980 981 /** 982 * Defines the custom dialog's background color. 983 * 984 * @type { ?ResourceColor } 985 * @syscap SystemCapability.ArkUI.ArkUI.Full 986 * @crossplatform 987 * @atomicservice 988 * @since 12 989 */ 990 backgroundColor?: ResourceColor; 991 992 /** 993 * Defines the custom dialog's corner radius. 994 * 995 * @type { ?(Dimension | BorderRadiuses) } 996 * @syscap SystemCapability.ArkUI.ArkUI.Full 997 * @crossplatform 998 * @atomicservice 999 * @since 12 1000 */ 1001 cornerRadius?: Dimension | BorderRadiuses; 1002 1003 /** 1004 * Defines the custom dialog's width. 1005 * 1006 * @type { ?Dimension } 1007 * @syscap SystemCapability.ArkUI.ArkUI.Full 1008 * @crossplatform 1009 * @atomicservice 1010 * @since 12 1011 */ 1012 width?: Dimension; 1013 1014 /** 1015 * Defines the custom dialog's height. 1016 * 1017 * @type { ?Dimension } 1018 * @syscap SystemCapability.ArkUI.ArkUI.Full 1019 * @crossplatform 1020 * @atomicservice 1021 * @since 12 1022 */ 1023 height?: Dimension; 1024 1025 /** 1026 * Defines the custom dialog's border width. 1027 * 1028 * @type { ?(Dimension | EdgeWidths) } 1029 * @syscap SystemCapability.ArkUI.ArkUI.Full 1030 * @crossplatform 1031 * @atomicservice 1032 * @since 12 1033 */ 1034 borderWidth?: Dimension | EdgeWidths; 1035 1036 /** 1037 * Defines the custom dialog's border color. 1038 * 1039 * @type { ?(ResourceColor | EdgeColors) } 1040 * @syscap SystemCapability.ArkUI.ArkUI.Full 1041 * @crossplatform 1042 * @atomicservice 1043 * @since 12 1044 */ 1045 borderColor?: ResourceColor | EdgeColors; 1046 1047 /** 1048 * Defines the custom dialog's border style. 1049 * 1050 * @type { ?(BorderStyle | EdgeStyles) } 1051 * @syscap SystemCapability.ArkUI.ArkUI.Full 1052 * @crossplatform 1053 * @atomicservice 1054 * @since 12 1055 */ 1056 borderStyle?: BorderStyle | EdgeStyles; 1057 1058 /** 1059 * Defines the custom dialog's shadow. 1060 * 1061 * @type { ?(ShadowOptions | ShadowStyle) } 1062 * @syscap SystemCapability.ArkUI.ArkUI.Full 1063 * @crossplatform 1064 * @atomicservice 1065 * @since 12 1066 */ 1067 shadow?: ShadowOptions | ShadowStyle; 1068 1069 /** 1070 * Defines the customDialog's background blur Style 1071 * 1072 * @type { ?BlurStyle } 1073 * @default BlurStyle.COMPONENT_ULTRA_THICK 1074 * @syscap SystemCapability.ArkUI.ArkUI.Full 1075 * @crossplatform 1076 * @atomicservice 1077 * @since 12 1078 */ 1079 backgroundBlurStyle?: BlurStyle; 1080 } 1081 1082 /** 1083 * @typedef ActionMenuSuccessResponse 1084 * @syscap SystemCapability.ArkUI.ArkUI.Full 1085 * @since 9 1086 */ 1087 /** 1088 * @typedef ActionMenuSuccessResponse 1089 * @syscap SystemCapability.ArkUI.ArkUI.Full 1090 * @crossplatform 1091 * @since 10 1092 */ 1093 /** 1094 * @typedef ActionMenuSuccessResponse 1095 * @syscap SystemCapability.ArkUI.ArkUI.Full 1096 * @crossplatform 1097 * @atomicservice 1098 * @since 11 1099 */ 1100 interface ActionMenuSuccessResponse { 1101 /** 1102 * Index of the selected button, starting from 0. 1103 * 1104 * @type { number } 1105 * @syscap SystemCapability.ArkUI.ArkUI.Full 1106 * @since 9 1107 */ 1108 /** 1109 * Index of the selected button, starting from 0. 1110 * 1111 * @type { number } 1112 * @syscap SystemCapability.ArkUI.ArkUI.Full 1113 * @crossplatform 1114 * @since 10 1115 */ 1116 /** 1117 * Index of the selected button, starting from 0. 1118 * 1119 * @type { number } 1120 * @syscap SystemCapability.ArkUI.ArkUI.Full 1121 * @crossplatform 1122 * @atomicservice 1123 * @since 11 1124 */ 1125 index: number; 1126 } 1127 1128 /** 1129 * @typedef ActionMenuOptions 1130 * @syscap SystemCapability.ArkUI.ArkUI.Full 1131 * @since 9 1132 */ 1133 /** 1134 * @typedef ActionMenuOptions 1135 * @syscap SystemCapability.ArkUI.ArkUI.Full 1136 * @crossplatform 1137 * @since 10 1138 */ 1139 /** 1140 * @typedef ActionMenuOptions 1141 * @syscap SystemCapability.ArkUI.ArkUI.Full 1142 * @crossplatform 1143 * @atomicservice 1144 * @since 11 1145 */ 1146 interface ActionMenuOptions { 1147 /** 1148 * Title of the text to display. 1149 * 1150 * @type { ?(string | Resource) } 1151 * @syscap SystemCapability.ArkUI.ArkUI.Full 1152 * @since 9 1153 */ 1154 /** 1155 * Title of the text to display. 1156 * 1157 * @type { ?(string | Resource) } 1158 * @syscap SystemCapability.ArkUI.ArkUI.Full 1159 * @crossplatform 1160 * @since 10 1161 */ 1162 /** 1163 * Title of the text to display. 1164 * 1165 * @type { ?(string | Resource) } 1166 * @syscap SystemCapability.ArkUI.ArkUI.Full 1167 * @crossplatform 1168 * @atomicservice 1169 * @since 11 1170 */ 1171 title?: string | Resource; 1172 1173 /** 1174 * Array of buttons in the dialog box. 1175 * The array structure is {text:'button', color: '#666666'}. 1176 * One to six buttons are supported. 1177 * 1178 * @type { [Button, Button?, Button?, Button?, Button?, Button?] } 1179 * @syscap SystemCapability.ArkUI.ArkUI.Full 1180 * @since 9 1181 */ 1182 /** 1183 * Array of buttons in the dialog box. 1184 * The array structure is {text:'button', color: '#666666'}. 1185 * One to six buttons are supported. 1186 * 1187 * @type { [Button, Button?, Button?, Button?, Button?, Button?] } 1188 * @syscap SystemCapability.ArkUI.ArkUI.Full 1189 * @crossplatform 1190 * @since 10 1191 */ 1192 /** 1193 * Array of buttons in the dialog box. 1194 * The array structure is {text:'button', color: '#666666'}. 1195 * One to six buttons are supported. 1196 * 1197 * @type { [Button, Button?, Button?, Button?, Button?, Button?] } 1198 * @syscap SystemCapability.ArkUI.ArkUI.Full 1199 * @crossplatform 1200 * @atomicservice 1201 * @since 11 1202 */ 1203 buttons: [Button, Button?, Button?, Button?, Button?, Button?]; 1204 1205 /** 1206 * Whether to display in the sub window. 1207 * 1208 * @type { ?boolean } 1209 * @default false 1210 * @syscap SystemCapability.ArkUI.ArkUI.Full 1211 * @crossplatform 1212 * @since 11 1213 */ 1214 /** 1215 * Whether to display in the sub window. 1216 * 1217 * @type { ?boolean } 1218 * @default false 1219 * @syscap SystemCapability.ArkUI.ArkUI.Full 1220 * @crossplatform 1221 * @atomicservice 1222 * @since 12 1223 */ 1224 showInSubWindow?: boolean; 1225 1226 /** 1227 * Whether it is a modal dialog 1228 * @type { ?boolean } 1229 * @default true 1230 * @syscap SystemCapability.ArkUI.ArkUI.Full 1231 * @crossplatform 1232 * @since 11 1233 */ 1234 /** 1235 * Whether it is a modal dialog 1236 * @type { ?boolean } 1237 * @default true 1238 * @syscap SystemCapability.ArkUI.ArkUI.Full 1239 * @crossplatform 1240 * @atomicservice 1241 * @since 12 1242 */ 1243 isModal?: boolean; 1244 } 1245 1246 /** 1247 * Displays the notification text. 1248 * 1249 * @param { ShowToastOptions } options - Options. 1250 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1251 * <br> 1. Mandatory parameters are left unspecified. 1252 * <br> 2. Incorrect parameters types. 1253 * <br> 3. Parameter verification failed. 1254 * @throws { BusinessError } 100001 - Internal error. 1255 * @syscap SystemCapability.ArkUI.ArkUI.Full 1256 * @since 9 1257 */ 1258 /** 1259 * Displays the notification text. 1260 * 1261 * @param { ShowToastOptions } options - Options. 1262 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1263 * <br> 1. Mandatory parameters are left unspecified. 1264 * <br> 2. Incorrect parameters types. 1265 * <br> 3. Parameter verification failed. 1266 * @throws { BusinessError } 100001 - Internal error. 1267 * @syscap SystemCapability.ArkUI.ArkUI.Full 1268 * @crossplatform 1269 * @since 10 1270 */ 1271 /** 1272 * Displays the notification text. 1273 * 1274 * @param { ShowToastOptions } options - Options. 1275 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1276 * <br> 1. Mandatory parameters are left unspecified. 1277 * <br> 2. Incorrect parameters types. 1278 * <br> 3. Parameter verification failed. 1279 * @throws { BusinessError } 100001 - Internal error. 1280 * @syscap SystemCapability.ArkUI.ArkUI.Full 1281 * @crossplatform 1282 * @atomicservice 1283 * @since 11 1284 */ 1285 function showToast(options: ShowToastOptions): void; 1286 1287 /** 1288 * Displays the dialog box. 1289 * 1290 * @param { ShowDialogOptions } options - Options. 1291 * @param { AsyncCallback<ShowDialogSuccessResponse> } callback - the callback of showDialog. 1292 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1293 * <br> 1. Mandatory parameters are left unspecified. 1294 * <br> 2. Incorrect parameters types. 1295 * <br> 3. Parameter verification failed. 1296 * @throws { BusinessError } 100001 - Internal error. 1297 * @syscap SystemCapability.ArkUI.ArkUI.Full 1298 * @since 9 1299 */ 1300 /** 1301 * Displays the dialog box. 1302 * 1303 * @param { ShowDialogOptions } options - Options. 1304 * @param { AsyncCallback<ShowDialogSuccessResponse> } callback - the callback of showDialog. 1305 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1306 * <br> 1. Mandatory parameters are left unspecified. 1307 * <br> 2. Incorrect parameters types. 1308 * <br> 3. Parameter verification failed. 1309 * @throws { BusinessError } 100001 - Internal error. 1310 * @syscap SystemCapability.ArkUI.ArkUI.Full 1311 * @crossplatform 1312 * @since 10 1313 */ 1314 /** 1315 * Displays the dialog box. 1316 * 1317 * @param { ShowDialogOptions } options - Options. 1318 * @param { AsyncCallback<ShowDialogSuccessResponse> } callback - the callback of showDialog. 1319 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1320 * <br> 1. Mandatory parameters are left unspecified. 1321 * <br> 2. Incorrect parameters types. 1322 * <br> 3. Parameter verification failed. 1323 * @throws { BusinessError } 100001 - Internal error. 1324 * @syscap SystemCapability.ArkUI.ArkUI.Full 1325 * @crossplatform 1326 * @atomicservice 1327 * @since 11 1328 */ 1329 function showDialog(options: ShowDialogOptions, callback: AsyncCallback<ShowDialogSuccessResponse>): void; 1330 1331 /** 1332 * Displays the dialog box. 1333 * 1334 * @param { ShowDialogOptions } options - Options. 1335 * @returns { Promise<ShowDialogSuccessResponse> } the promise returned by the function. 1336 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1337 * <br> 1. Mandatory parameters are left unspecified. 1338 * <br> 2. Incorrect parameters types. 1339 * <br> 3. Parameter verification failed. 1340 * @throws { BusinessError } 100001 - Internal error. 1341 * @syscap SystemCapability.ArkUI.ArkUI.Full 1342 * @since 9 1343 */ 1344 /** 1345 * Displays the dialog box. 1346 * 1347 * @param { ShowDialogOptions } options - Options. 1348 * @returns { Promise<ShowDialogSuccessResponse> } the promise returned by the function. 1349 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1350 * <br> 1. Mandatory parameters are left unspecified. 1351 * <br> 2. Incorrect parameters types. 1352 * <br> 3. Parameter verification failed. 1353 * @throws { BusinessError } 100001 - Internal error. 1354 * @syscap SystemCapability.ArkUI.ArkUI.Full 1355 * @crossplatform 1356 * @since 10 1357 */ 1358 /** 1359 * Displays the dialog box. 1360 * 1361 * @param { ShowDialogOptions } options - Options. 1362 * @returns { Promise<ShowDialogSuccessResponse> } the promise returned by the function. 1363 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1364 * <br> 1. Mandatory parameters are left unspecified. 1365 * <br> 2. Incorrect parameters types. 1366 * <br> 3. Parameter verification failed. 1367 * @throws { BusinessError } 100001 - Internal error. 1368 * @syscap SystemCapability.ArkUI.ArkUI.Full 1369 * @crossplatform 1370 * @atomicservice 1371 * @since 11 1372 */ 1373 function showDialog(options: ShowDialogOptions): Promise<ShowDialogSuccessResponse>; 1374 1375 /** 1376 * Open the custom dialog. 1377 * 1378 * @param { CustomDialogOptions } options - Options. 1379 * @returns { Promise<number> } return the dialog id that will be used by closeCustomDialog. 1380 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1381 * <br> 1. Mandatory parameters are left unspecified. 1382 * <br> 2. Incorrect parameters types. 1383 * <br> 3. Parameter verification failed. 1384 * @throws { BusinessError } 100001 - Internal error. 1385 * @syscap SystemCapability.ArkUI.ArkUI.Full 1386 * @crossplatform 1387 * @since 11 1388 */ 1389 /** 1390 * Open the custom dialog. 1391 * 1392 * @param { CustomDialogOptions } options - Options. 1393 * @returns { Promise<number> } return the dialog id that will be used by closeCustomDialog. 1394 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1395 * <br> 1. Mandatory parameters are left unspecified. 1396 * <br> 2. Incorrect parameters types. 1397 * <br> 3. Parameter verification failed. 1398 * @throws { BusinessError } 100001 - Internal error. 1399 * @syscap SystemCapability.ArkUI.ArkUI.Full 1400 * @crossplatform 1401 * @atomicservice 1402 * @since 12 1403 */ 1404 function openCustomDialog(options: CustomDialogOptions): Promise<number>; 1405 1406 /** 1407 * Close the custom dialog. 1408 * 1409 * @param { number } dialogId - the dialog id that returned by openCustomDialog. 1410 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1411 * <br> 1. Mandatory parameters are left unspecified. 1412 * <br> 2. Incorrect parameters types. 1413 * <br> 3. Parameter verification failed. 1414 * @throws { BusinessError } 100001 - Internal error. 1415 * @syscap SystemCapability.ArkUI.ArkUI.Full 1416 * @crossplatform 1417 * @since 11 1418 */ 1419 /** 1420 * Close the custom dialog. 1421 * 1422 * @param { number } dialogId - the dialog id that returned by openCustomDialog. 1423 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1424 * <br> 1. Mandatory parameters are left unspecified. 1425 * <br> 2. Incorrect parameters types. 1426 * <br> 3. Parameter verification failed. 1427 * @throws { BusinessError } 100001 - Internal error. 1428 * @syscap SystemCapability.ArkUI.ArkUI.Full 1429 * @crossplatform 1430 * @atomicservice 1431 * @since 12 1432 */ 1433 function closeCustomDialog(dialogId: number): void; 1434 1435 /** 1436 * Displays the menu. 1437 * 1438 * @param { ActionMenuOptions } options - Options. 1439 * @param { AsyncCallback<ActionMenuSuccessResponse> } callback - the callback of showActionMenu. 1440 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1441 * <br> 1. Mandatory parameters are left unspecified. 1442 * <br> 2. Incorrect parameters types. 1443 * <br> 3. Parameter verification failed. 1444 * @throws { BusinessError } 100001 - Internal error. 1445 * @syscap SystemCapability.ArkUI.ArkUI.Full 1446 * @since 9 1447 */ 1448 /** 1449 * Displays the menu. 1450 * 1451 * @param { ActionMenuOptions } options - Options. 1452 * @param { AsyncCallback<ActionMenuSuccessResponse> } callback - the callback of showActionMenu. 1453 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1454 * <br> 1. Mandatory parameters are left unspecified. 1455 * <br> 2. Incorrect parameters types. 1456 * <br> 3. Parameter verification failed. 1457 * @throws { BusinessError } 100001 - Internal error. 1458 * @syscap SystemCapability.ArkUI.ArkUI.Full 1459 * @crossplatform 1460 * @since 10 1461 */ 1462 /** 1463 * Displays the menu. 1464 * 1465 * @param { ActionMenuOptions } options - Options. 1466 * @param { AsyncCallback<ActionMenuSuccessResponse> } callback - the callback of showActionMenu. 1467 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1468 * <br> 1. Mandatory parameters are left unspecified. 1469 * <br> 2. Incorrect parameters types. 1470 * <br> 3. Parameter verification failed. 1471 * @throws { BusinessError } 100001 - Internal error. 1472 * @syscap SystemCapability.ArkUI.ArkUI.Full 1473 * @crossplatform 1474 * @atomicservice 1475 * @since 11 1476 */ 1477 function showActionMenu(options: ActionMenuOptions, callback: AsyncCallback<ActionMenuSuccessResponse>): void; 1478 1479 /** 1480 * Displays the dialog box. 1481 * 1482 * @param { ActionMenuOptions } options - Options. 1483 * @returns { Promise<ActionMenuSuccessResponse> } the promise returned by the function. 1484 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1485 * <br> 1. Mandatory parameters are left unspecified. 1486 * <br> 2. Incorrect parameters types. 1487 * <br> 3. Parameter verification failed. 1488 * @throws { BusinessError } 100001 - Internal error. 1489 * @syscap SystemCapability.ArkUI.ArkUI.Full 1490 * @since 9 1491 */ 1492 /** 1493 * Displays the dialog box. 1494 * 1495 * @param { ActionMenuOptions } options - Options. 1496 * @returns { Promise<ActionMenuSuccessResponse> } the promise returned by the function. 1497 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1498 * <br> 1. Mandatory parameters are left unspecified. 1499 * <br> 2. Incorrect parameters types. 1500 * <br> 3. Parameter verification failed. 1501 * @throws { BusinessError } 100001 - Internal error. 1502 * @syscap SystemCapability.ArkUI.ArkUI.Full 1503 * @crossplatform 1504 * @since 10 1505 */ 1506 /** 1507 * Displays the dialog box. 1508 * 1509 * @param { ActionMenuOptions } options - Options. 1510 * @returns { Promise<ActionMenuSuccessResponse> } the promise returned by the function. 1511 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1512 * <br> 1. Mandatory parameters are left unspecified. 1513 * <br> 2. Incorrect parameters types. 1514 * <br> 3. Parameter verification failed. 1515 * @throws { BusinessError } 100001 - Internal error. 1516 * @syscap SystemCapability.ArkUI.ArkUI.Full 1517 * @crossplatform 1518 * @atomicservice 1519 * @since 11 1520 */ 1521 function showActionMenu(options: ActionMenuOptions): Promise<ActionMenuSuccessResponse>; 1522} 1523 1524/** 1525 * Component dialog dismiss action. 1526 * 1527 * @interface DismissDialogAction 1528 * @syscap SystemCapability.ArkUI.ArkUI.Full 1529 * @crossplatform 1530 * @atomicservice 1531 * @since 12 1532 */ 1533declare interface DismissDialogAction { 1534 /** 1535 * Defines dialog dismiss function. 1536 * 1537 * @type { Callback<void> } 1538 * @syscap SystemCapability.ArkUI.ArkUI.Full 1539 * @crossplatform 1540 * @atomicservice 1541 * @since 12 1542 */ 1543 dismiss: Callback<void>; 1544 1545 /** 1546 * Dismiss reason type. 1547 * 1548 * @type { DismissReason } 1549 * @syscap SystemCapability.ArkUI.ArkUI.Full 1550 * @crossplatform 1551 * @atomicservice 1552 * @since 12 1553 */ 1554 reason: DismissReason; 1555} 1556 1557export default promptAction; 1558