1/* 2 * Copyright (c) 2023 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 * Provide image decoration in the text component. 23 * 24 * @interface ImageSpanInterface 25 * @syscap SystemCapability.ArkUI.ArkUI.Full 26 * @crossplatform 27 * @since 10 28 */ 29/** 30 * Provide image decoration in the text component. 31 * 32 * @interface ImageSpanInterface 33 * @syscap SystemCapability.ArkUI.ArkUI.Full 34 * @crossplatform 35 * @atomicservice 36 * @since 11 37 */ 38interface ImageSpanInterface { 39 /** 40 * Called when image is entered in span. 41 * 42 * @param { ResourceStr | PixelMap } value - The image resource. 43 * @returns { ImageSpanAttribute } The attribute of the image span. 44 * @syscap SystemCapability.ArkUI.ArkUI.Full 45 * @crossplatform 46 * @since 10 47 */ 48 /** 49 * Called when image is entered in span. 50 * 51 * @param { ResourceStr | PixelMap } value - The image resource. 52 * @returns { ImageSpanAttribute } The attribute of the image span. 53 * @syscap SystemCapability.ArkUI.ArkUI.Full 54 * @crossplatform 55 * @atomicservice 56 * @since 11 57 */ 58 (value: ResourceStr | PixelMap): ImageSpanAttribute; 59} 60 61/** 62 * Define the ImageSpan attribute functions. 63 * 64 * @extends CommonMethod<ImageSpanAttribute> 65 * @syscap SystemCapability.ArkUI.ArkUI.Full 66 * @crossplatform 67 * @since 10 68 */ 69/** 70 * Define the ImageSpan attribute functions. 71 * 72 * @extends BaseSpan<ImageSpanAttribute> 73 * @syscap SystemCapability.ArkUI.ArkUI.Full 74 * @crossplatform 75 * @atomicservice 76 * @since 11 77 */ 78declare class ImageSpanAttribute extends BaseSpan<ImageSpanAttribute> { 79 /** 80 * Called when the alignment of image span is set. 81 * 82 * @param { ImageSpanAlignment } value - The alignment type of image span. 83 * @returns { ImageSpanAttribute } The attribute of the image span. 84 * @syscap SystemCapability.ArkUI.ArkUI.Full 85 * @crossplatform 86 * @since 10 87 */ 88 /** 89 * Called when the alignment of image span is set. 90 * 91 * @param { ImageSpanAlignment } value - The alignment type of image span. 92 * @returns { ImageSpanAttribute } The attribute of the image span. 93 * @syscap SystemCapability.ArkUI.ArkUI.Full 94 * @crossplatform 95 * @atomicservice 96 * @since 11 97 */ 98 verticalAlign(value: ImageSpanAlignment): ImageSpanAttribute; 99 100 /** 101 * Sets the zoom type of an image. 102 * 103 * @param { ImageFit } value - Image display mode. 104 * @returns { ImageSpanAttribute } The attribute of the image span. 105 * @syscap SystemCapability.ArkUI.ArkUI.Full 106 * @crossplatform 107 * @since 10 108 */ 109 /** 110 * Sets the zoom type of an image. 111 * 112 * @param { ImageFit } value - Image display mode. 113 * @returns { ImageSpanAttribute } The attribute of the image span. 114 * @syscap SystemCapability.ArkUI.ArkUI.Full 115 * @crossplatform 116 * @atomicservice 117 * @since 11 118 */ 119 objectFit(value: ImageFit): ImageSpanAttribute; 120 121 /** 122 * Sets a callback which is triggered when the image is successfully loaded. 123 * The size of the image source that is successfully loaded is returned, in pixels. 124 * 125 * @param { ImageCompleteCallback } callback - Triggered when the image is successfully loaded. 126 * @returns { ImageSpanAttribute } The attribute of the image span. 127 * @syscap SystemCapability.ArkUI.ArkUI.Full 128 * @crossplatform 129 * @atomicservice 130 * @since 12 131 */ 132 onComplete(callback: ImageCompleteCallback): ImageSpanAttribute; 133 134 /** 135 * Sets a callback which is triggered when an exception occurs during image loading. 136 * The field of "message" returned in the callback carries the detailed information of failed image loading. 137 * 138 * @param { ImageErrorCallback } callback - Triggered when an exception occurs during image loading. 139 * @returns { ImageSpanAttribute } The attribute of the image span. 140 * @syscap SystemCapability.ArkUI.ArkUI.Full 141 * @crossplatform 142 * @atomicservice 143 * @since 12 144 */ 145 onError(callback: ImageErrorCallback): ImageSpanAttribute; 146 147 /** 148 * Placeholder displayed on load 149 * 150 * @param { PixelMap } value 151 * @returns { ImageSpanAttribute } 152 * @syscap SystemCapability.ArkUI.ArkUI.Full 153 * @atomicservice 154 * @since 12 155 */ 156 alt(value: PixelMap): ImageSpanAttribute; 157} 158 159/** 160 * Defines ImageSpan Component instance. 161 * 162 * @syscap SystemCapability.ArkUI.ArkUI.Full 163 * @crossplatform 164 * @since 10 165 */ 166/** 167 * Defines ImageSpan Component instance. 168 * 169 * @syscap SystemCapability.ArkUI.ArkUI.Full 170 * @crossplatform 171 * @atomicservice 172 * @since 11 173 */ 174declare const ImageSpan: ImageSpanInterface; 175 176/** 177 * Defines ImageSpan Component. 178 * 179 * @syscap SystemCapability.ArkUI.ArkUI.Full 180 * @crossplatform 181 * @since 10 182 */ 183/** 184 * Defines ImageSpan Component. 185 * 186 * @syscap SystemCapability.ArkUI.ArkUI.Full 187 * @crossplatform 188 * @atomicservice 189 * @since 11 190 */ 191declare const ImageSpanInstance: ImageSpanAttribute; 192 193/** 194 * Callback function triggered when the image is successfully loaded. 195 * 196 * @typedef { function } ImageCompleteCallback 197 * @param { ImageLoadResult } result - the information about the successfully loaded image. 198 * @syscap SystemCapability.ArkUI.ArkUI.Full 199 * @crossplatform 200 * @atomicservice 201 * @since 12 202 */ 203type ImageCompleteCallback = (result: ImageLoadResult) => void; 204 205/** 206 * The information about the successfully loaded image. 207 * 208 * @interface ImageLoadResult 209 * @syscap SystemCapability.ArkUI.ArkUI.Full 210 * @crossplatform 211 * @atomicservice 212 * @since 12 213 */ 214declare interface ImageLoadResult { 215 /** 216 * The width of the image source. 217 * 218 * @type { number } 219 * @syscap SystemCapability.ArkUI.ArkUI.Full 220 * @crossplatform 221 * @atomicservice 222 * @since 12 223 */ 224 width: number; 225 /** 226 * The height of the image source. 227 * 228 * @type { number } 229 * @syscap SystemCapability.ArkUI.ArkUI.Full 230 * @crossplatform 231 * @atomicservice 232 * @since 12 233 */ 234 height: number; 235 /** 236 * The width of the component source. 237 * 238 * @type { number } 239 * @syscap SystemCapability.ArkUI.ArkUI.Full 240 * @crossplatform 241 * @atomicservice 242 * @since 12 243 */ 244 componentWidth: number; 245 /** 246 * The height of the component source. 247 * 248 * @type { number } 249 * @syscap SystemCapability.ArkUI.ArkUI.Full 250 * @crossplatform 251 * @atomicservice 252 * @since 12 253 */ 254 componentHeight: number; 255 /** 256 * The value of the status of the image being loaded successfully. 257 * If the returned status value is 0, the image data is successfully loaded. 258 * If the returned status value is 1, the image is successfully decoded. 259 * 260 * @type { number } 261 * @syscap SystemCapability.ArkUI.ArkUI.Full 262 * @crossplatform 263 * @atomicservice 264 * @since 12 265 */ 266 loadingStatus: number; 267 /** 268 * The width of the picture that is actually drawn. 269 * 270 * @type { number } 271 * @syscap SystemCapability.ArkUI.ArkUI.Full 272 * @crossplatform 273 * @atomicservice 274 * @since 12 275 */ 276 contentWidth: number; 277 /** 278 * The height of the picture that is actually drawn. 279 * 280 * @type { number } 281 * @syscap SystemCapability.ArkUI.ArkUI.Full 282 * @crossplatform 283 * @atomicservice 284 * @since 12 285 */ 286 contentHeight: number; 287 /** 288 * The offset between image content and image component on the X-axis. 289 * 290 * @type { number } 291 * @syscap SystemCapability.ArkUI.ArkUI.Full 292 * @crossplatform 293 * @atomicservice 294 * @since 12 295 */ 296 contentOffsetX: number; 297 /** 298 * The offset between image content and image component on the Y-axis. 299 * 300 * @type { number } 301 * @syscap SystemCapability.ArkUI.ArkUI.Full 302 * @crossplatform 303 * @atomicservice 304 * @since 12 305 */ 306 contentOffsetY: number; 307} 308