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 color filter effect on the image span. 102 * 103 * @param { ColorFilter | DrawingColorFilter } filter ColorFilter object. 104 * @returns { ImageSpanAttribute } The attribute of the image span. 105 * @syscap SystemCapability.ArkUI.ArkUI.Full 106 * @crossplatform 107 * @atomicservice 108 * @since 14 109 */ 110 colorFilter(filter: ColorFilter | DrawingColorFilter): ImageSpanAttribute; 111 112 /** 113 * Sets the zoom type of an image. 114 * 115 * @param { ImageFit } value - Image display mode. 116 * @returns { ImageSpanAttribute } The attribute of the image span. 117 * @syscap SystemCapability.ArkUI.ArkUI.Full 118 * @crossplatform 119 * @since 10 120 */ 121 /** 122 * Sets the zoom type of an image. 123 * 124 * @param { ImageFit } value - Image display mode. 125 * @returns { ImageSpanAttribute } The attribute of the image span. 126 * @syscap SystemCapability.ArkUI.ArkUI.Full 127 * @crossplatform 128 * @atomicservice 129 * @since 11 130 */ 131 objectFit(value: ImageFit): ImageSpanAttribute; 132 133 /** 134 * Sets a callback which is triggered when the image is successfully loaded. 135 * The size of the image source that is successfully loaded is returned, in pixels. 136 * 137 * @param { ImageCompleteCallback } callback - Triggered when the image is successfully loaded. 138 * @returns { ImageSpanAttribute } The attribute of the image span. 139 * @syscap SystemCapability.ArkUI.ArkUI.Full 140 * @crossplatform 141 * @atomicservice 142 * @since 12 143 */ 144 onComplete(callback: ImageCompleteCallback): ImageSpanAttribute; 145 146 /** 147 * Sets a callback which is triggered when an exception occurs during image loading. 148 * The field of "message" returned in the callback carries the detailed information of failed image loading. 149 * 150 * @param { ImageErrorCallback } callback - Triggered when an exception occurs during image loading. 151 * @returns { ImageSpanAttribute } The attribute of the image span. 152 * @syscap SystemCapability.ArkUI.ArkUI.Full 153 * @crossplatform 154 * @atomicservice 155 * @since 12 156 */ 157 onError(callback: ImageErrorCallback): ImageSpanAttribute; 158 159 /** 160 * Placeholder displayed on load 161 * 162 * @param { PixelMap } value 163 * @returns { ImageSpanAttribute } 164 * @syscap SystemCapability.ArkUI.ArkUI.Full 165 * @atomicservice 166 * @since 12 167 */ 168 alt(value: PixelMap): ImageSpanAttribute; 169} 170 171/** 172 * Defines ImageSpan Component instance. 173 * 174 * @syscap SystemCapability.ArkUI.ArkUI.Full 175 * @crossplatform 176 * @since 10 177 */ 178/** 179 * Defines ImageSpan Component instance. 180 * 181 * @syscap SystemCapability.ArkUI.ArkUI.Full 182 * @crossplatform 183 * @atomicservice 184 * @since 11 185 */ 186declare const ImageSpan: ImageSpanInterface; 187 188/** 189 * Defines ImageSpan Component. 190 * 191 * @syscap SystemCapability.ArkUI.ArkUI.Full 192 * @crossplatform 193 * @since 10 194 */ 195/** 196 * Defines ImageSpan Component. 197 * 198 * @syscap SystemCapability.ArkUI.ArkUI.Full 199 * @crossplatform 200 * @atomicservice 201 * @since 11 202 */ 203declare const ImageSpanInstance: ImageSpanAttribute; 204 205/** 206 * Callback function triggered when the image is successfully loaded. 207 * 208 * @typedef { function } ImageCompleteCallback 209 * @param { ImageLoadResult } result - the information about the successfully loaded image. 210 * @syscap SystemCapability.ArkUI.ArkUI.Full 211 * @crossplatform 212 * @atomicservice 213 * @since 12 214 */ 215type ImageCompleteCallback = (result: ImageLoadResult) => void; 216 217/** 218 * The information about the successfully loaded image. 219 * 220 * @interface ImageLoadResult 221 * @syscap SystemCapability.ArkUI.ArkUI.Full 222 * @crossplatform 223 * @atomicservice 224 * @since 12 225 */ 226declare interface ImageLoadResult { 227 /** 228 * The width of the image source. 229 * 230 * @type { number } 231 * @syscap SystemCapability.ArkUI.ArkUI.Full 232 * @crossplatform 233 * @atomicservice 234 * @since 12 235 */ 236 width: number; 237 /** 238 * The height of the image source. 239 * 240 * @type { number } 241 * @syscap SystemCapability.ArkUI.ArkUI.Full 242 * @crossplatform 243 * @atomicservice 244 * @since 12 245 */ 246 height: number; 247 /** 248 * The width of the component source. 249 * 250 * @type { number } 251 * @syscap SystemCapability.ArkUI.ArkUI.Full 252 * @crossplatform 253 * @atomicservice 254 * @since 12 255 */ 256 componentWidth: number; 257 /** 258 * The height of the component source. 259 * 260 * @type { number } 261 * @syscap SystemCapability.ArkUI.ArkUI.Full 262 * @crossplatform 263 * @atomicservice 264 * @since 12 265 */ 266 componentHeight: number; 267 /** 268 * The value of the status of the image being loaded successfully. 269 * If the returned status value is 0, the image data is successfully loaded. 270 * If the returned status value is 1, the image is successfully decoded. 271 * 272 * @type { number } 273 * @syscap SystemCapability.ArkUI.ArkUI.Full 274 * @crossplatform 275 * @atomicservice 276 * @since 12 277 */ 278 loadingStatus: number; 279 /** 280 * The width of the picture that is actually drawn. 281 * 282 * @type { number } 283 * @syscap SystemCapability.ArkUI.ArkUI.Full 284 * @crossplatform 285 * @atomicservice 286 * @since 12 287 */ 288 contentWidth: number; 289 /** 290 * The height of the picture that is actually drawn. 291 * 292 * @type { number } 293 * @syscap SystemCapability.ArkUI.ArkUI.Full 294 * @crossplatform 295 * @atomicservice 296 * @since 12 297 */ 298 contentHeight: number; 299 /** 300 * The offset between image content and image component on the X-axis. 301 * 302 * @type { number } 303 * @syscap SystemCapability.ArkUI.ArkUI.Full 304 * @crossplatform 305 * @atomicservice 306 * @since 12 307 */ 308 contentOffsetX: number; 309 /** 310 * The offset between image content and image component on the Y-axis. 311 * 312 * @type { number } 313 * @syscap SystemCapability.ArkUI.ArkUI.Full 314 * @crossplatform 315 * @atomicservice 316 * @since 12 317 */ 318 contentOffsetY: number; 319} 320