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 * Defines the options of ShowToast. 18 * @syscap SystemCapability.ArkUI.ArkUI.Full 19 * @since 3 20 */ 21export interface ShowToastOptions { 22 /** 23 * Text to display. 24 * @syscap SystemCapability.ArkUI.ArkUI.Full 25 * @since 3 26 */ 27 message: string; 28 29 /** 30 * Duration of toast dialog box. The default value is 1500. 31 * The recommended value ranges from 1500 ms to 10000ms. 32 * NOTE: A value less than 1500 is automatically changed to 1500. The maximum value is 10000 ms. 33 * @syscap SystemCapability.ArkUI.ArkUI.Full 34 * @since 3 35 */ 36 duration?: number; 37 38 /** 39 * The distance between toast dialog box and the bottom of screen. 40 * @syscap SystemCapability.ArkUI.ArkUI.Full 41 * @since 5 42 */ 43 bottom?: string | number; 44} 45 46/** 47 * Defines the prompt info of button. 48 * @syscap SystemCapability.ArkUI.ArkUI.Full 49 * @since 3 50 */ 51export interface Button { 52 /** 53 * Defines the button info. 54 * @syscap SystemCapability.ArkUI.ArkUI.Full 55 * @since 3 56 */ 57 text: string; 58 59 /** 60 * Defines the color of button. 61 * @syscap SystemCapability.ArkUI.ArkUI.Full 62 * @since 3 63 */ 64 color: string; 65} 66 67/** 68 * Defines the response of ShowDialog. 69 * @syscap SystemCapability.ArkUI.ArkUI.Full 70 * @since 3 71 */ 72export interface ShowDialogSuccessResponse { 73 /** 74 * Defines the index of data. 75 * @syscap SystemCapability.ArkUI.ArkUI.Full 76 * @since 3 77 */ 78 index: number; 79} 80 81/** 82 * Defines the option of show dialog. 83 * @syscap SystemCapability.ArkUI.ArkUI.Full 84 * @since 3 85 */ 86export interface ShowDialogOptions { 87 /** 88 * Title of the text to display. 89 * @syscap SystemCapability.ArkUI.ArkUI.Full 90 * @since 3 91 */ 92 title?: string; 93 94 /** 95 * Text body. 96 * @syscap SystemCapability.ArkUI.ArkUI.Full 97 * @since 3 98 */ 99 message?: string; 100 101 /** 102 * Array of buttons in the dialog box. 103 * The array structure is {text:'button', color: '#666666'}. 104 * 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. 105 * @syscap SystemCapability.ArkUI.ArkUI.Full 106 * @since 3 107 */ 108 buttons?: [Button, Button?, Button?]; 109 110 /** 111 * Called when the dialog box is displayed. 112 * @syscap SystemCapability.ArkUI.ArkUI.Full 113 * @since 3 114 */ 115 success?: (data: ShowDialogSuccessResponse) => void; 116 117 /** 118 * Called when the operation is cancelled. 119 * @syscap SystemCapability.ArkUI.ArkUI.Full 120 * @since 3 121 */ 122 cancel?: (data: string, code: string) => void; 123 124 /** 125 * Called when the dialog box is closed. 126 * @syscap SystemCapability.ArkUI.ArkUI.Full 127 * @since 3 128 */ 129 complete?: (data: string) => void; 130} 131 132/** 133 * Defines the option of ShowActionMenu. 134 * @syscap SystemCapability.ArkUI.ArkUI.Full 135 * @since 6 136 */ 137export interface ShowActionMenuOptions { 138 /** 139 * Title of the text to display. 140 * @syscap SystemCapability.ArkUI.ArkUI.Full 141 * @since 6 142 */ 143 title?: string; 144 145 /** 146 * Array of buttons in the dialog box. 147 * The array structure is {text:'button', color: '#666666'}. 148 * One to six buttons are supported. 149 * @syscap SystemCapability.ArkUI.ArkUI.Full 150 * @since 6 151 */ 152 buttons: [Button, Button?, Button?, Button?, Button?, Button?]; 153 154 /** 155 * Called when the dialog box is displayed. 156 * @syscap SystemCapability.ArkUI.ArkUI.Full 157 * @since 6 158 */ 159 success?: (tapIndex: number, errMsg: string) => void; 160 161 /** 162 * Called when the operation is cancelled. 163 * @syscap SystemCapability.ArkUI.ArkUI.Full 164 * @since 6 165 */ 166 fail?: (errMsg: string) => void; 167 168 /** 169 * Called when the dialog box is closed. 170 * @syscap SystemCapability.ArkUI.ArkUI.Full 171 * @since 6 172 */ 173 complete?: () => void; 174} 175 176/** 177 * Defines the prompt interface. 178 * @syscap SystemCapability.ArkUI.ArkUI.Full 179 * @since 3 180 */ 181export default class Prompt { 182 /** 183 * Displays the notification text. 184 * @syscap SystemCapability.ArkUI.ArkUI.Full 185 * @param options Options. 186 * @since 3 187 */ 188 static showToast(options: ShowToastOptions): void; 189 190 /** 191 * Displays the dialog box. 192 * @syscap SystemCapability.ArkUI.ArkUI.Full 193 * @param options Options. 194 * @since 3 195 */ 196 static showDialog(options: ShowDialogOptions): void; 197 198 /** 199 * Displays the menu. 200 * @syscap SystemCapability.ArkUI.ArkUI.Full 201 * @param options Options. 202 * @since 6 203 */ 204 static showActionMenu(options: ShowActionMenuOptions): void; 205} 206