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/** 17 * The alignment of dialog, 18 * @since 7 19 */ 20declare enum DialogAlignment { 21 /** 22 * Vertical top alignment. 23 * @since 7 24 */ 25 Top, 26 27 /** 28 * Align vertically to the center. 29 * @since 7 30 */ 31 Center, 32 33 /** 34 * Vertical bottom alignment. 35 * @since 7 36 */ 37 Bottom, 38 39 /** 40 * Default alignment. 41 * @since 7 42 */ 43 Default, 44 45 /** 46 * Align the upper left corner. 47 * @since 8 48 */ 49 TopStart, 50 51 /** 52 * Align the upper right corner. 53 * @since 8 54 */ 55 TopEnd, 56 57 /** 58 * Left center alignment. 59 * @since 8 60 */ 61 CenterStart, 62 63 /** 64 * Right center alignment. 65 * @since 8 66 */ 67 CenterEnd, 68 69 /** 70 * Align the lower left corner. 71 * @since 8 72 */ 73 BottomStart, 74 75 /** 76 * Align the lower right corner. 77 * @since 8 78 */ 79 BottomEnd, 80} 81 82/** 83 * Base param used for AlertDialog.show method. 84 * @since 7 85 */ 86declare interface AlertDialogParam { 87 /** 88 * Title Properties 89 * @since 7 90 */ 91 title?: ResourceStr; 92 93 /** 94 * message Properties 95 * @since 7 96 */ 97 message: ResourceStr; 98 99 /** 100 * Allows users to click the mask layer to exit. 101 * @since 7 102 */ 103 autoCancel?: boolean; 104 105 /** 106 * Execute Cancel Function. 107 * @since 7 108 */ 109 cancel?: () => void; 110 111 /** 112 * Alignment in the vertical direction. 113 * @since 7 114 */ 115 alignment?: DialogAlignment; 116 117 /** 118 * Offset of the pop-up window relative to the alignment position. 119 * @since 7 120 */ 121 offset?: Offset; 122 123 /** 124 * Grid count of dialog. 125 * @since 7 126 */ 127 gridCount?: number; 128} 129 130/** 131 * Defines the AlertDialog with confirm button. 132 * @since 7 133 */ 134declare interface AlertDialogParamWithConfirm extends AlertDialogParam { 135 /** 136 * Invoke the commit function. 137 * @since 7 138 */ 139 confirm?: { 140 /** 141 * Text content of the confirmation button. 142 * @since 7 143 */ 144 value: ResourceStr; 145 146 /** 147 * Text color of the confirmation button. 148 * @since 7 149 */ 150 fontColor?: ResourceColor; 151 152 /** 153 * Background color of the confirmation button. 154 * @since 7 155 */ 156 backgroundColor?: ResourceColor; 157 158 /** 159 * Method executed by the callback. 160 * @since 7 161 */ 162 action: () => void; 163 }; 164} 165 166/** 167 * Defines the dialog param with buttons. 168 * @since 7 169 */ 170declare interface AlertDialogParamWithButtons extends AlertDialogParam { 171 /** 172 * First button. 173 * @since 7 174 */ 175 primaryButton: { 176 /** 177 * Text content of the confirmation button. 178 * @since 7 179 */ 180 value: ResourceStr; 181 182 /** 183 * Text color of the confirmation button. 184 * @since 7 185 */ 186 fontColor?: ResourceColor; 187 188 /** 189 * Background color of the confirmation button. 190 * @since 7 191 */ 192 backgroundColor?: ResourceColor; 193 194 /** 195 * Method executed by the callback. 196 * @since 7 197 */ 198 action: () => void; 199 }; 200 201 /** 202 * Second button. 203 * @since 7 204 */ 205 secondaryButton: { 206 /** 207 * Text content of the confirmation button. 208 * @since 7 209 */ 210 value: ResourceStr; 211 212 /** 213 * Text color of the confirmation button. 214 * @since 7 215 */ 216 fontColor?: ResourceColor; 217 218 /** 219 * Background color of the confirmation button. 220 * @since 7 221 */ 222 backgroundColor?: ResourceColor; 223 224 /** 225 * Method executed by the callback. 226 * @since 7 227 */ 228 action: () => void; 229 }; 230} 231 232/** 233 * Defines AlertDialog which uses show method to show alert dialog. 234 * @since 7 235 */ 236declare class AlertDialog { 237 /** 238 * Invoking method display. 239 * @since 7 240 */ 241 static show(value: AlertDialogParamWithConfirm | AlertDialogParamWithButtons); 242} 243