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 11 78 */ 79export interface Button { 80 /** 81 * Defines the button info. 82 * 83 * @type { string } 84 * @syscap SystemCapability.ArkUI.ArkUI.Full 85 * @since 3 86 */ 87 /** 88 * Defines the button info. 89 * 90 * @type { string } 91 * @syscap SystemCapability.ArkUI.ArkUI.Full 92 * @atomicservice 93 * @since 11 94 */ 95 text: string; 96 97 /** 98 * Defines the color of button. 99 * 100 * @type { string } 101 * @syscap SystemCapability.ArkUI.ArkUI.Full 102 * @since 3 103 */ 104 /** 105 * Defines the color of button. 106 * 107 * @type { string } 108 * @syscap SystemCapability.ArkUI.ArkUI.Full 109 * @atomicservice 110 * @since 11 111 */ 112 color: string; 113} 114 115/** 116 * Defines the response of ShowDialog. 117 * 118 * @interface ShowDialogSuccessResponse 119 * @syscap SystemCapability.ArkUI.ArkUI.Full 120 * @since 3 121 */ 122/** 123 * Defines the response of ShowDialog. 124 * 125 * @interface ShowDialogSuccessResponse 126 * @syscap SystemCapability.ArkUI.ArkUI.Full 127 * @atomicservice 128 * @since 11 129 */ 130export interface ShowDialogSuccessResponse { 131 /** 132 * Defines the index of data. 133 * 134 * @type { number } 135 * @syscap SystemCapability.ArkUI.ArkUI.Full 136 * @since 3 137 */ 138 /** 139 * Defines the index of data. 140 * 141 * @type { number } 142 * @syscap SystemCapability.ArkUI.ArkUI.Full 143 * @atomicservice 144 * @since 11 145 */ 146 index: number; 147} 148 149/** 150 * Defines the option of show dialog. 151 * 152 * @interface ShowDialogOptions 153 * @syscap SystemCapability.ArkUI.ArkUI.Full 154 * @since 3 155 */ 156/** 157 * Defines the option of show dialog. 158 * 159 * @interface ShowDialogOptions 160 * @syscap SystemCapability.ArkUI.ArkUI.Full 161 * @atomicservice 162 * @since 11 163 */ 164export interface ShowDialogOptions { 165 /** 166 * Title of the text to display. 167 * 168 * @type { ?string } 169 * @syscap SystemCapability.ArkUI.ArkUI.Full 170 * @since 3 171 */ 172 /** 173 * Title of the text to display. 174 * 175 * @type { ?string } 176 * @syscap SystemCapability.ArkUI.ArkUI.Full 177 * @atomicservice 178 * @since 11 179 */ 180 title?: string; 181 182 /** 183 * Text body. 184 * 185 * @type { ?string } 186 * @syscap SystemCapability.ArkUI.ArkUI.Full 187 * @since 3 188 */ 189 /** 190 * Text body. 191 * 192 * @type { ?string } 193 * @syscap SystemCapability.ArkUI.ArkUI.Full 194 * @atomicservice 195 * @since 11 196 */ 197 message?: string; 198 199 /** 200 * Array of buttons in the dialog box. 201 * The array structure is {text:'button', color: '#666666'}. 202 * 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. 203 * 204 * @type { ?[Button, Button?, Button?] } 205 * @syscap SystemCapability.ArkUI.ArkUI.Full 206 * @since 3 207 */ 208 /** 209 * Array of buttons in the dialog box. 210 * The array structure is {text:'button', color: '#666666'}. 211 * 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. 212 * 213 * @type { ?[Button, Button?, Button?] } 214 * @syscap SystemCapability.ArkUI.ArkUI.Full 215 * @atomicservice 216 * @since 11 217 */ 218 buttons?: [Button, Button?, Button?]; 219 220 /** 221 * Called when the dialog box is displayed. 222 * 223 * @type { ?function } 224 * @syscap SystemCapability.ArkUI.ArkUI.Full 225 * @since 3 226 */ 227 /** 228 * Called when the dialog box is displayed. 229 * 230 * @type { ?function } 231 * @syscap SystemCapability.ArkUI.ArkUI.Full 232 * @atomicservice 233 * @since 11 234 */ 235 success?: (data: ShowDialogSuccessResponse) => void; 236 237 /** 238 * Called when the operation is cancelled. 239 * 240 * @type { ?function } 241 * @syscap SystemCapability.ArkUI.ArkUI.Full 242 * @since 3 243 */ 244 /** 245 * Called when the operation is cancelled. 246 * 247 * @type { ?function } 248 * @syscap SystemCapability.ArkUI.ArkUI.Full 249 * @atomicservice 250 * @since 11 251 */ 252 cancel?: (data: string, code: string) => void; 253 254 /** 255 * Called when the dialog box is closed. 256 * 257 * @type { ?function } 258 * @syscap SystemCapability.ArkUI.ArkUI.Full 259 * @since 3 260 */ 261 /** 262 * Called when the dialog box is closed. 263 * 264 * @type { ?function } 265 * @syscap SystemCapability.ArkUI.ArkUI.Full 266 * @atomicservice 267 * @since 11 268 */ 269 complete?: (data: string) => void; 270} 271 272/** 273 * Defines the option of ShowActionMenu. 274 * 275 * @interface ShowActionMenuOptions 276 * @syscap SystemCapability.ArkUI.ArkUI.Full 277 * @since 6 278 */ 279/** 280 * Defines the option of ShowActionMenu. 281 * 282 * @interface ShowActionMenuOptions 283 * @syscap SystemCapability.ArkUI.ArkUI.Full 284 * @atomicservice 285 * @since 11 286 */ 287export interface ShowActionMenuOptions { 288 /** 289 * Title of the text to display. 290 * 291 * @type { ?string } 292 * @syscap SystemCapability.ArkUI.ArkUI.Full 293 * @since 6 294 */ 295 /** 296 * Title of the text to display. 297 * 298 * @type { ?string } 299 * @syscap SystemCapability.ArkUI.ArkUI.Full 300 * @atomicservice 301 * @since 11 302 */ 303 title?: string; 304 305 /** 306 * Array of buttons in the dialog box. 307 * The array structure is {text:'button', color: '#666666'}. 308 * One to six buttons are supported. 309 * 310 * @type { [Button, Button?, Button?, Button?, Button?, Button?] } 311 * @syscap SystemCapability.ArkUI.ArkUI.Full 312 * @since 6 313 */ 314 /** 315 * Array of buttons in the dialog box. 316 * The array structure is {text:'button', color: '#666666'}. 317 * One to six buttons are supported. 318 * 319 * @type { [Button, Button?, Button?, Button?, Button?, Button?] } 320 * @syscap SystemCapability.ArkUI.ArkUI.Full 321 * @atomicservice 322 * @since 11 323 */ 324 buttons: [Button, Button?, Button?, Button?, Button?, Button?]; 325 326 /** 327 * Called when the dialog box is displayed. 328 * 329 * @type { ?function } 330 * @syscap SystemCapability.ArkUI.ArkUI.Full 331 * @since 6 332 */ 333 /** 334 * Called when the dialog box is displayed. 335 * 336 * @type { ?function } 337 * @syscap SystemCapability.ArkUI.ArkUI.Full 338 * @atomicservice 339 * @since 11 340 */ 341 success?: (tapIndex: number, errMsg: string) => void; 342 343 /** 344 * Called when the operation is cancelled. 345 * 346 * @type { ?function } 347 * @syscap SystemCapability.ArkUI.ArkUI.Full 348 * @since 6 349 */ 350 /** 351 * Called when the operation is cancelled. 352 * 353 * @type { ?function } 354 * @syscap SystemCapability.ArkUI.ArkUI.Full 355 * @atomicservice 356 * @since 11 357 */ 358 fail?: (errMsg: string) => void; 359 360 /** 361 * Called when the dialog box is closed. 362 * 363 * @type { ?function } 364 * @syscap SystemCapability.ArkUI.ArkUI.Full 365 * @since 6 366 */ 367 /** 368 * Called when the dialog box is closed. 369 * 370 * @type { ?function } 371 * @syscap SystemCapability.ArkUI.ArkUI.Full 372 * @atomicservice 373 * @since 11 374 */ 375 complete?: () => void; 376} 377 378/** 379 * Defines the prompt interface. 380 * 381 * @syscap SystemCapability.ArkUI.ArkUI.Full 382 * @since 3 383 */ 384/** 385 * Defines the prompt interface. 386 * 387 * @syscap SystemCapability.ArkUI.ArkUI.Full 388 * @atomicservice 389 * @since 11 390 */ 391export default class Prompt { 392 /** 393 * Displays the notification text. 394 * 395 * @param { ShowToastOptions } options - Options. 396 * @syscap SystemCapability.ArkUI.ArkUI.Full 397 * @since 3 398 */ 399 /** 400 * Displays the notification text. 401 * 402 * @param { ShowToastOptions } options - Options. 403 * @syscap SystemCapability.ArkUI.ArkUI.Full 404 * @atomicservice 405 * @since 11 406 */ 407 static showToast(options: ShowToastOptions): void; 408 409 /** 410 * Displays the dialog box. 411 * 412 * @param { ShowDialogOptions } options - Options. 413 * @syscap SystemCapability.ArkUI.ArkUI.Full 414 * @since 3 415 */ 416 /** 417 * Displays the dialog box. 418 * 419 * @param { ShowDialogOptions } options - Options. 420 * @syscap SystemCapability.ArkUI.ArkUI.Full 421 * @atomicservice 422 * @since 11 423 */ 424 static showDialog(options: ShowDialogOptions): void; 425 426 /** 427 * Displays the menu. 428 * 429 * @param { ShowActionMenuOptions } options - Options. 430 * @syscap SystemCapability.ArkUI.ArkUI.Full 431 * @since 6 432 */ 433 /** 434 * Displays the menu. 435 * 436 * @param { ShowActionMenuOptions } options - Options. 437 * @syscap SystemCapability.ArkUI.ArkUI.Full 438 * @atomicservice 439 * @since 11 440 */ 441 static showActionMenu(options: ShowActionMenuOptions): void; 442} 443