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