• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2020 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/**
22 * Defines the options of ShowToast.
23 *
24 * @interface ShowToastOptions
25 * @syscap SystemCapability.ArkUI.ArkUI.Full
26 * @since 3
27 * @deprecated since 8
28 * @useinstead ohos.prompt
29 */
30export interface ShowToastOptions {
31  /**
32   * Text to display.
33   *
34   * @type { string }
35   * @syscap SystemCapability.ArkUI.ArkUI.Full
36   * @since 3
37   * @deprecated since 8
38   */
39  message: string;
40
41  /**
42   * Duration of toast dialog box. The default value is 1500.
43   * The recommended value ranges from 1500 ms to 10000ms.
44   * NOTE: A value less than 1500 is automatically changed to 1500. The maximum value is 10000 ms.
45   *
46   * @type { ?number }
47   * @syscap SystemCapability.ArkUI.ArkUI.Full
48   * @since 3
49   * @deprecated since 8
50   */
51  duration?: number;
52
53  /**
54   * The distance between toast dialog box and the bottom of screen.
55   *
56   * @type { ?(string | number) }
57   * @syscap SystemCapability.ArkUI.ArkUI.Full
58   * @since 5
59   * @deprecated since 8
60   */
61  bottom?: string | number;
62}
63
64/**
65 * Defines the prompt info of button.
66 *
67 * @interface Button
68 * @syscap SystemCapability.ArkUI.ArkUI.Full
69 * @since 3
70 */
71/**
72 * Defines the prompt info of button.
73 *
74 * @interface Button
75 * @syscap SystemCapability.ArkUI.ArkUI.Full
76 * @atomicservice
77 * @since arkts {'1.1':'11','1.2':'20'}
78 * @arkts 1.1&1.2
79 */
80export interface Button {
81  /**
82   * Defines the button info.
83   *
84   * @type { string }
85   * @syscap SystemCapability.ArkUI.ArkUI.Full
86   * @since 3
87   */
88  /**
89   * Defines the button info.
90   *
91   * @type { string }
92   * @syscap SystemCapability.ArkUI.ArkUI.Full
93   * @atomicservice
94   * @since arkts {'1.1':'11','1.2':'20'}
95   * @arkts 1.1&1.2
96   */
97  text: string;
98
99  /**
100   * Defines the color of button.
101   *
102   * @type { string }
103   * @syscap SystemCapability.ArkUI.ArkUI.Full
104   * @since 3
105   */
106  /**
107   * Defines the color of button.
108   *
109   * @type { string }
110   * @syscap SystemCapability.ArkUI.ArkUI.Full
111   * @atomicservice
112   * @since arkts {'1.1':'11','1.2':'20'}
113   * @arkts 1.1&1.2
114   */
115  color: string;
116}
117
118/**
119 * Defines the one-button array.
120 *
121 * @typedef { [Button] } PromptSingleButton
122 * @syscap SystemCapability.ArkUI.ArkUI.Full
123 * @crossplatform
124 * @atomicservice
125 * @since 20
126 * @arkts 1.2
127 */
128export type PromptSingleButton = [Button];
129
130/**
131 * Defines the two-buttons array.
132 *
133 * @typedef { [Button, Button | undefined] } PromptDoubleButtons
134 * @syscap SystemCapability.ArkUI.ArkUI.Full
135 * @crossplatform
136 * @atomicservice
137 * @since 20
138 * @arkts 1.2
139 */
140export type PromptDoubleButtons = [Button, Button | undefined];
141
142/**
143 * Defines the three-buttons array.
144 *
145 * @typedef { [Button, Button | undefined, Button | undefined] } PromptTripleButtons
146 * @syscap SystemCapability.ArkUI.ArkUI.Full
147 * @crossplatform
148 * @atomicservice
149 * @since 20
150 * @arkts 1.2
151 */
152export type PromptTripleButtons = [Button, Button | undefined, Button | undefined];
153
154/**
155 * Defines the four-buttons array.
156 *
157 * @typedef { [Button, Button | undefined, Button | undefined, Button | undefined] } PromptQuadrupleButtons
158 * @syscap SystemCapability.ArkUI.ArkUI.Full
159 * @crossplatform
160 * @atomicservice
161 * @since 20
162 * @arkts 1.2
163 */
164export type PromptQuadrupleButtons = [Button, Button | undefined, Button | undefined, Button | undefined];
165
166/**
167 * Defines the five-buttons array.
168 *
169 * @typedef { [Button, Button | undefined, Button | undefined, Button | undefined, Button | undefined] } PromptQuintupleButtons
170 * @syscap SystemCapability.ArkUI.ArkUI.Full
171 * @crossplatform
172 * @atomicservice
173 * @since 20
174 * @arkts 1.2
175 */
176export type PromptQuintupleButtons = [Button, Button | undefined, Button | undefined, Button | undefined, Button | undefined];
177
178/**
179 * Defines the six-buttons array.
180 *
181 * @typedef { [Button, Button | undefined, Button | undefined, Button | undefined, Button | undefined, Button | undefined] } PromptSextupleButtons
182 * @syscap SystemCapability.ArkUI.ArkUI.Full
183 * @crossplatform
184 * @atomicservice
185 * @since 20
186 * @arkts 1.2
187 */
188export type PromptSextupleButtons = [Button, Button | undefined, Button | undefined, Button | undefined, Button | undefined, Button | undefined];
189
190/**
191 * Defines the response of ShowDialog.
192 *
193 * @interface ShowDialogSuccessResponse
194 * @syscap SystemCapability.ArkUI.ArkUI.Full
195 * @since 3
196 */
197/**
198 * Defines the response of ShowDialog.
199 *
200 * @interface ShowDialogSuccessResponse
201 * @syscap SystemCapability.ArkUI.ArkUI.Full
202 * @atomicservice
203 * @since arkts {'1.1':'11','1.2':'20'}
204 * @arkts 1.1&1.2
205 */
206export interface ShowDialogSuccessResponse {
207  /**
208   * Defines the index of data.
209   *
210   * @type { number }
211   * @syscap SystemCapability.ArkUI.ArkUI.Full
212   * @since 3
213   */
214  /**
215   * Defines the index of data.
216   *
217   * @type { number }
218   * @syscap SystemCapability.ArkUI.ArkUI.Full
219   * @atomicservice
220   * @since arkts {'1.1':'11','1.2':'20'}
221   * @arkts 1.1&1.2
222   */
223  index: number;
224}
225
226/**
227 * Defines the option of show dialog.
228 *
229 * @interface ShowDialogOptions
230 * @syscap SystemCapability.ArkUI.ArkUI.Full
231 * @since 3
232 */
233/**
234 * Defines the option of show dialog.
235 *
236 * @interface ShowDialogOptions
237 * @syscap SystemCapability.ArkUI.ArkUI.Full
238 * @atomicservice
239 * @since arkts {'1.1':'11','1.2':'20'}
240 * @arkts 1.1&1.2
241 */
242export interface ShowDialogOptions {
243  /**
244   * Title of the text to display.
245   *
246   * @type { ?string }
247   * @syscap SystemCapability.ArkUI.ArkUI.Full
248   * @since 3
249   */
250  /**
251   * Title of the text to display.
252   *
253   * @type { ?string }
254   * @syscap SystemCapability.ArkUI.ArkUI.Full
255   * @atomicservice
256   * @since arkts {'1.1':'11','1.2':'20'}
257   * @arkts 1.1&1.2
258   */
259  title?: string;
260
261  /**
262   * Text body.
263   *
264   * @type { ?string }
265   * @syscap SystemCapability.ArkUI.ArkUI.Full
266   * @since 3
267   */
268  /**
269   * Text body.
270   *
271   * @type { ?string }
272   * @syscap SystemCapability.ArkUI.ArkUI.Full
273   * @atomicservice
274   * @since arkts {'1.1':'11','1.2':'20'}
275   * @arkts 1.1&1.2
276   */
277  message?: string;
278
279  /**
280   * Array of buttons in the dialog box.
281   * The array structure is {text:'button', color: '#666666'}.
282   * 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.
283   *
284   * @type { ?[Button, Button?, Button?] }
285   * @syscap SystemCapability.ArkUI.ArkUI.Full
286   * @since 3
287   */
288  /**
289   * Array of buttons in the dialog box.
290   * The array structure is {text:'button', color: '#666666'}.
291   * 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.
292   *
293   * @type { ?[Button, Button?, Button?] }
294   * @syscap SystemCapability.ArkUI.ArkUI.Full
295   * @atomicservice
296   * @since 11
297   */
298  buttons?: [Button, Button?, Button?];
299
300  /**
301   * Array of buttons in the dialog box.
302   * The array structure is {text:'button', color: '#666666'}.
303   * 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.
304   *
305   * @type { ?(PromptSingleButton | PromptDoubleButtons | PromptTripleButtons) }
306   * @syscap SystemCapability.ArkUI.ArkUI.Full
307   * @atomicservice
308   * @since 20
309   * @arkts 1.2
310   */
311  buttons?: PromptSingleButton | PromptDoubleButtons | PromptTripleButtons;
312
313  /**
314   * Called when the dialog box is displayed.
315   *
316   * @type { ?function }
317   * @syscap SystemCapability.ArkUI.ArkUI.Full
318   * @since 3
319   */
320  /**
321   * Called when the dialog box is displayed.
322   *
323   * @type { ?function }
324   * @syscap SystemCapability.ArkUI.ArkUI.Full
325   * @atomicservice
326   * @since arkts {'1.1':'11','1.2':'20'}
327   * @arkts 1.1&1.2
328   */
329  success?: (data: ShowDialogSuccessResponse) => void;
330
331  /**
332   * Called when the operation is cancelled.
333   *
334   * @type { ?function }
335   * @syscap SystemCapability.ArkUI.ArkUI.Full
336   * @since 3
337   */
338  /**
339   * Called when the operation is cancelled.
340   *
341   * @type { ?function }
342   * @syscap SystemCapability.ArkUI.ArkUI.Full
343   * @atomicservice
344   * @since arkts {'1.1':'11','1.2':'20'}
345   * @arkts 1.1&1.2
346   */
347  cancel?: (data: string, code: string) => void;
348
349  /**
350   * Called when the dialog box is closed.
351   *
352   * @type { ?function }
353   * @syscap SystemCapability.ArkUI.ArkUI.Full
354   * @since 3
355   */
356  /**
357   * Called when the dialog box is closed.
358   *
359   * @type { ?function }
360   * @syscap SystemCapability.ArkUI.ArkUI.Full
361   * @atomicservice
362   * @since arkts {'1.1':'11','1.2':'20'}
363   * @arkts 1.1&1.2
364   */
365  complete?: (data: string) => void;
366}
367
368/**
369 * Defines the option of ShowActionMenu.
370 *
371 * @interface ShowActionMenuOptions
372 * @syscap SystemCapability.ArkUI.ArkUI.Full
373 * @since 6
374 */
375/**
376 * Defines the option of ShowActionMenu.
377 *
378 * @interface ShowActionMenuOptions
379 * @syscap SystemCapability.ArkUI.ArkUI.Full
380 * @atomicservice
381 * @since arkts {'1.1':'11','1.2':'20'}
382 * @arkts 1.1&1.2
383 */
384export interface ShowActionMenuOptions {
385  /**
386   * Title of the text to display.
387   *
388   * @type { ?string }
389   * @syscap SystemCapability.ArkUI.ArkUI.Full
390   * @since 6
391   */
392  /**
393   * Title of the text to display.
394   *
395   * @type { ?string }
396   * @syscap SystemCapability.ArkUI.ArkUI.Full
397   * @atomicservice
398   * @since arkts {'1.1':'11','1.2':'20'}
399   * @arkts 1.1&1.2
400   */
401  title?: string;
402
403  /**
404   * Array of buttons in the dialog box.
405   * The array structure is {text:'button', color: '#666666'}.
406   * One to six buttons are supported.
407   *
408   * @type { [Button, Button?, Button?, Button?, Button?, Button?] }
409   * @syscap SystemCapability.ArkUI.ArkUI.Full
410   * @since 6
411   */
412  /**
413   * Array of buttons in the dialog box.
414   * The array structure is {text:'button', color: '#666666'}.
415   * One to six buttons are supported.
416   *
417   * @type { [Button, Button?, Button?, Button?, Button?, Button?] }
418   * @syscap SystemCapability.ArkUI.ArkUI.Full
419   * @atomicservice
420   * @since 11
421   */
422  buttons: [Button, Button?, Button?, Button?, Button?, Button?];
423
424  /**
425   * Array of buttons in the dialog box.
426   * The array structure is {text:'button', color: '#666666'}.
427   * One to six buttons are supported.
428   *
429   * @type { PromptSingleButton | PromptDoubleButtons | PromptTripleButtons | PromptQuadrupleButtons | PromptQuintupleButtons | PromptSextupleButtons }
430   * @syscap SystemCapability.ArkUI.ArkUI.Full
431   * @atomicservice
432   * @since 20
433   * @arkts 1.2
434   */
435  buttons: PromptSingleButton | PromptDoubleButtons | PromptTripleButtons | PromptQuadrupleButtons | PromptQuintupleButtons | PromptSextupleButtons;
436
437  /**
438   * Called when the dialog box is displayed.
439   *
440   * @type { ?function }
441   * @syscap SystemCapability.ArkUI.ArkUI.Full
442   * @since 6
443   */
444  /**
445   * Called when the dialog box is displayed.
446   *
447   * @type { ?function }
448   * @syscap SystemCapability.ArkUI.ArkUI.Full
449   * @atomicservice
450   * @since arkts {'1.1':'11','1.2':'20'}
451   * @arkts 1.1&1.2
452   */
453  success?: (tapIndex: number, errMsg: string) => void;
454
455  /**
456   * Called when the operation is cancelled.
457   *
458   * @type { ?function }
459   * @syscap SystemCapability.ArkUI.ArkUI.Full
460   * @since 6
461   */
462  /**
463   * Called when the operation is cancelled.
464   *
465   * @type { ?function }
466   * @syscap SystemCapability.ArkUI.ArkUI.Full
467   * @atomicservice
468   * @since arkts {'1.1':'11','1.2':'20'}
469   * @arkts 1.1&1.2
470   */
471  fail?: (errMsg: string) => void;
472
473  /**
474   * Called when the dialog box is closed.
475   *
476   * @type { ?function }
477   * @syscap SystemCapability.ArkUI.ArkUI.Full
478   * @since 6
479   */
480  /**
481   * Called when the dialog box is closed.
482   *
483   * @type { ?function }
484   * @syscap SystemCapability.ArkUI.ArkUI.Full
485   * @atomicservice
486   * @since arkts {'1.1':'11','1.2':'20'}
487   * @arkts 1.1&1.2
488   */
489  complete?: () => void;
490}
491
492/**
493 * Defines the prompt interface.
494 *
495 * @syscap SystemCapability.ArkUI.ArkUI.Full
496 * @since 3
497 */
498/**
499 * Defines the prompt interface.
500 *
501 * @syscap SystemCapability.ArkUI.ArkUI.Full
502 * @atomicservice
503 * @since arkts {'1.1':'11','1.2':'20'}
504 * @arkts 1.1&1.2
505 */
506export default class Prompt {
507  /**
508   * Displays the notification text.
509   *
510   * @param { ShowToastOptions } options - Options.
511   * @syscap SystemCapability.ArkUI.ArkUI.Full
512   * @since 3
513   */
514  /**
515   * Displays the notification text.
516   *
517   * @param { ShowToastOptions } options - Options.
518   * @syscap SystemCapability.ArkUI.ArkUI.Full
519   * @atomicservice
520   * @since 11
521   */
522  static showToast(options: ShowToastOptions): void;
523
524  /**
525   * Displays the dialog box.
526   *
527   * @param { ShowDialogOptions } options - Options.
528   * @syscap SystemCapability.ArkUI.ArkUI.Full
529   * @since 3
530   */
531  /**
532   * Displays the dialog box.
533   *
534   * @param { ShowDialogOptions } options - Options.
535   * @syscap SystemCapability.ArkUI.ArkUI.Full
536   * @atomicservice
537   * @since arkts {'1.1':'11','1.2':'20'}
538   * @arkts 1.1&1.2
539   */
540  static showDialog(options: ShowDialogOptions): void;
541
542  /**
543   * Displays the menu.
544   *
545   * @param { ShowActionMenuOptions } options - Options.
546   * @syscap SystemCapability.ArkUI.ArkUI.Full
547   * @since 6
548   */
549  /**
550   * Displays the menu.
551   *
552   * @param { ShowActionMenuOptions } options - Options.
553   * @syscap SystemCapability.ArkUI.ArkUI.Full
554   * @atomicservice
555   * @since arkts {'1.1':'11','1.2':'20'}
556   * @arkts 1.1&1.2
557   */
558  static showActionMenu(options: ShowActionMenuOptions): void;
559}
560