• 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
16/// <reference path="../component/units.d.ts" />
17
18import { AsyncCallback } from './basic';
19import { Resource } from 'GlobalResource';
20
21/**
22 * @syscap SystemCapability.ArkUI.ArkUI.Full
23 * @since 8
24 * @deprecated since 9
25 * @useinstead ohos.promptAction
26 */
27declare namespace prompt {
28
29  /**
30   * @since 8
31   */
32  interface ShowToastOptions {
33
34    /**
35     * Text to display.
36     * @type { string }
37     * @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     * @since 8
46     */
47    duration?: number;
48
49    /**
50     * The distance between toast dialog box and the bottom of screen.
51     * @since 8
52     */
53    bottom?: string | number;
54  }
55
56  /**
57   * @since 8
58   */
59  interface Button {
60
61    /**
62     * @type { string }
63     * @since 8
64     */
65    text: string;
66
67    /**
68     * @type { string }
69     * @since 8
70     */
71    color: string;
72  }
73
74  /**
75   * @since 8
76   */
77  interface ShowDialogSuccessResponse {
78
79    /**
80    * @since 8
81    */
82    index: number;
83  }
84
85  /**
86   * @since 8
87   */
88  interface ShowDialogOptions {
89
90    /**
91     * Title of the text to display.
92     * @type { string }
93     * @since 8
94     */
95    title?: string;
96
97    /**
98     * Text body.
99     * @type { string }
100     * @since 8
101     */
102    message?: string;
103
104    /**
105     * Array of buttons in the dialog box.
106     * The array structure is {text:'button', color: '#666666'}.
107     * 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.
108     * @since 8
109     */
110    buttons?: [Button, Button?, Button?];
111  }
112
113  /**
114   * @since 8
115   */
116  interface ActionMenuSuccessResponse {
117
118    /**
119     * @since 8
120     */
121    index: number;
122  }
123
124  /**
125   * @since 8
126   */
127  interface ActionMenuOptions {
128
129    /**
130     * Title of the text to display.
131     * @type { string }
132     * @since 8
133     */
134    title?: string;
135
136    /**
137     * Array of buttons in the dialog box.
138     * The array structure is {text:'button', color: '#666666'}.
139     * One to six buttons are supported.
140     * @since 8
141     */
142    buttons: [Button, Button?, Button?, Button?, Button?, Button?];
143  }
144
145  /**
146   * Displays the notification text.
147   * @param options Options.
148   * @since 8
149   */
150  function showToast(options: ShowToastOptions):void;
151
152  /**
153   * Displays the dialog box.
154   * @param options Options.
155   * @since 8
156   */
157  function showDialog(options: ShowDialogOptions, callback: AsyncCallback<ShowDialogSuccessResponse>):void;
158  function showDialog(options: ShowDialogOptions): Promise<ShowDialogSuccessResponse>;
159
160  /**
161   * Displays the menu.
162   * @param options Options.
163   * @since 8
164   */
165  function showActionMenu(options: ActionMenuOptions, callback: AsyncCallback<ActionMenuSuccessResponse>):void;
166  function showActionMenu(options: ActionMenuOptions): Promise<ActionMenuSuccessResponse>;
167}
168
169export default prompt;
170