• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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
16import {AsyncCallback} from './basic';
17
18/**
19 * @syscap SystemCapability.ArkUI.ArkUI.Full
20 * @since 8
21 * @import prompt from '@ohos.prompt';
22 */
23declare namespace prompt {
24
25  /**
26   * @since 8
27   */
28  interface ShowToastOptions {
29
30    /**
31     * Text to display.
32     * @since 8
33     */
34    message: string;
35
36    /**
37     * Duration of toast dialog box. The default value is 1500.
38     * The recommended value ranges from 1500 ms to 10000ms.
39     * NOTE: A value less than 1500 is automatically changed to 1500. The maximum value is 10000 ms.
40     * @since 8
41     */
42    duration?: number;
43
44    /**
45     * The distance between toast dialog box and the bottom of screen.
46     * @since 8
47     */
48    bottom?: string | number;
49  }
50
51  /**
52   * @since 8
53   */
54  interface Button {
55
56    /**
57     * @since 8
58     */
59    text: string;
60
61    /**
62     * @since 8
63     */
64    color: string;
65  }
66
67  /**
68   * @since 8
69   */
70  interface ShowDialogSuccessResponse {
71
72    /**
73    * @since 8
74    */
75    index: number;
76  }
77
78  /**
79   * @since 8
80   */
81  interface ShowDialogOptions {
82
83    /**
84     * Title of the text to display.
85     * @since 8
86     */
87    title?: string;
88
89    /**
90     * Text body.
91     * @since 8
92     */
93    message?: string;
94
95    /**
96     * Array of buttons in the dialog box.
97     * The array structure is {text:'button', color: '#666666'}.
98     * One to three buttons are supported. The first button is of the positiveButton type, the second is of the negativeButton type, and the third is of the neutralButton type.
99     * @since 8
100     */
101    buttons?: [Button, Button?, Button?];
102  }
103
104  /**
105   * @since 8
106   */
107  interface ActionMenuSuccessResponse {
108
109    /**
110     * @since 8
111     */
112    index: number;
113  }
114
115  /**
116   * @since 8
117   */
118  interface ActionMenuOptions {
119
120    /**
121     * Title of the text to display.
122     * @since 8
123     */
124    title?: string;
125
126    /**
127     * Array of buttons in the dialog box.
128     * The array structure is {text:'button', color: '#666666'}.
129     * One to six buttons are supported.
130     * @since 8
131     */
132    buttons: [Button, Button?, Button?, Button?, Button?, Button?];
133  }
134
135  /**
136   * Displays the notification text.
137   * @param options Options.
138   * @since 8
139   */
140  function showToast(options: ShowToastOptions):void;
141
142  /**
143   * Displays the dialog box.
144   * @param options Options.
145   * @since 8
146   */
147  function showDialog(options: ShowDialogOptions, callback: AsyncCallback<ShowDialogSuccessResponse>):void;
148  function showDialog(options: ShowDialogOptions): Promise<ShowDialogSuccessResponse>;
149
150  /**
151   * Displays the menu.
152   * @param options Options.
153   * @since 8
154   */
155  function showActionMenu(options: ActionMenuOptions, callback: AsyncCallback<ActionMenuSuccessResponse>):void;
156  function showActionMenu(options: ActionMenuOptions): Promise<ActionMenuSuccessResponse>;
157}
158
159export default prompt;
160