@nativescript-community/ui-image
Version:
Advanced and efficient image display plugin which uses Fresco (Android) and SDWebImage (iOS) to implement caching, placeholders, image effects, and much more.
223 lines (222 loc) • 8.93 kB
TypeScript
import { Color, CoreTypes, Property, View } from '@nativescript/core';
import { EventData as IEventData } from '@nativescript/core/data/observable';
import { ImageAsset } from '@nativescript/core/image-asset';
import { ImageSource } from '@nativescript/core/image-source';
export declare function colorConverter(v: string | Color): Color;
export declare enum CLogTypes {
log = 0,
info = 1,
warning = 2,
error = 3
}
export declare const ImageViewTraceCategory = "NativescriptImage";
export declare const CLog: (type: CLogTypes, ...args: any[]) => void;
export type Transition = 'fade' | 'curlUp';
/**
* Options for scaling the child bounds to the parent bounds
*/
export declare enum ScaleType {
None = "none",
/**
* Scales width and height independently, so that the child matches the parent exactly.
*/
Fill = "fill",
/**
* Scales the child so that it fits entirely inside the parent.
*/
AspectFill = "aspectFill",
/**
* Scales the child so that it fits entirely inside the parent.
*/
AspectFit = "aspectFit",
/**
* Performs no scaling.
*/
Center = "center",
/**
* Scales the child so that both dimensions will be greater than or equal to the corresponding dimension of the parent.
*/
CenterCrop = "centerCrop",
/**
* Scales the child so that it fits entirely inside the parent.
*/
CenterInside = "centerInside",
/**
* Scales the child so that it fits entirely inside the parent.
*/
FitCenter = "fitCenter",
/**
* Scales the child so that it fits entirely inside the parent.
*/
FitEnd = "fitEnd",
/**
* Scales the child so that it fits entirely inside the parent.
*/
FitStart = "fitStart",
/**
* Scales width and height independently, so that the child matches the parent exactly.
*/
FitXY = "fitXY",
/**
* Scales the child so that both dimensions will be greater than or equal to the corresponding dimension of the parent.
*/
FocusCrop = "focusCrop"
}
export interface AnimatedImage {
start(): void;
stop(): void;
isRunning(): boolean;
}
/**
* Encapsulates the common abstraction behind a platform specific object (typically a Bitmap) quality.
*/
export interface QualityInfo {
getQuality(): number;
isOfFullQuality(): boolean;
isOfGoodEnoughQuality(): boolean;
}
/**
* Encapsulates the common abstraction behind a platform specific object (typically a Bitmap's quality) details.
*/
export interface ImageInfo {
getHeight(): number;
getWidth(): number;
getQualityInfo(): QualityInfo;
}
export interface ImageError {
getMessage(): string;
getErrorType(): string;
toString(): string;
}
export declare function wrapNativeException(ex: any, errorType?: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"): any;
/**
* Options for prefetching images with transformations and request options
*/
export interface PrefetchOptions {
/** Custom headers for the request */
headers?: Record<string, string>;
/** Decode width for downsampling */
decodeWidth?: number;
/** Decode height for downsampling */
decodeHeight?: number;
/** Blur radius */
blurRadius?: number;
/** Blur downsampling factor (Android only) */
blurDownSampling?: number;
/** Round image as circle */
roundAsCircle?: boolean;
/** Tint color */
tintColor?: Color;
/** Round corner radius for top left */
roundTopLeftRadius?: number;
/** Round corner radius for top right */
roundTopRightRadius?: number;
/** Round corner radius for bottom left */
roundBottomLeftRadius?: number;
/** Round corner radius for bottom right */
roundBottomRightRadius?: number;
/** image rotation, iOS only */
imageRotation?: number;
}
export interface ImagePipelineConfigSetting {
isDownsampleEnabled?: boolean;
leakTracker?: any;
useOkhttp?: boolean;
onInitialize?: Function;
}
export declare class EventData implements IEventData {
private _eventName;
private _object;
get eventName(): string;
set eventName(value: string);
get object(): any;
set object(value: any);
}
export type Stretch = 'none' | 'fill' | 'aspectFill' | 'aspectFit';
export declare const srcProperty: Property<ImageBase, string | ImageSource | ImageAsset>;
export declare const headersProperty: Property<ImageBase, Record<string, string>>;
export declare const lowerResSrcProperty: Property<ImageBase, string>;
export declare const placeholderImageUriProperty: Property<ImageBase, string>;
export declare const failureImageUriProperty: Property<ImageBase, string>;
export declare const stretchProperty: Property<ImageBase, string>;
export declare const backgroundUriProperty: Property<ImageBase, string>;
export declare const progressiveRenderingEnabledProperty: Property<ImageBase, boolean>;
export declare const localThumbnailPreviewsEnabledProperty: Property<ImageBase, boolean>;
export declare const showProgressBarProperty: Property<ImageBase, boolean>;
export declare const progressBarColorProperty: Property<ImageBase, Color>;
export declare const roundAsCircleProperty: Property<ImageBase, boolean>;
export declare const blurRadiusProperty: Property<ImageBase, number>;
export declare const blurDownSamplingProperty: Property<ImageBase, number>;
export declare const imageRotationProperty: Property<ImageBase, number>;
export declare const autoPlayAnimationsProperty: Property<ImageBase, boolean>;
export declare const tapToRetryEnabledProperty: Property<ImageBase, boolean>;
export declare const aspectRatioProperty: Property<ImageBase, number>;
export declare const decodeWidthProperty: Property<ImageBase, number>;
export declare const decodeHeightProperty: Property<ImageBase, number>;
export declare const tintColorProperty: Property<ImageBase, Color>;
export declare const alwaysFadeProperty: Property<ImageBase, boolean>;
export declare const fadeDurationProperty: Property<ImageBase, number>;
export declare const noCacheProperty: Property<ImageBase, boolean>;
export declare const noRatioEnforceProperty: Property<ImageBase, boolean>;
export declare const roundTopLeftRadiusProperty: Property<ImageBase, CoreTypes.LengthType>;
export declare const roundTopRightRadiusProperty: Property<ImageBase, CoreTypes.LengthType>;
export declare const roundBottomLeftRadiusProperty: Property<ImageBase, CoreTypes.LengthType>;
export declare const roundBottomRightRadiusProperty: Property<ImageBase, CoreTypes.LengthType>;
export declare const loadModeProperty: Property<ImageBase, "sync" | "async">;
export declare const clipToBoundsProperty: Property<ImageBase, boolean>;
export declare const animatedImageViewProperty: Property<ImageBase, boolean>;
export declare const needRequestImage: (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void;
export type BasicSrcType = string | ImageSource | ImageAsset;
export type SrcType = BasicSrcType | (() => BasicSrcType | PromiseLike<BasicSrcType>) | PromiseLike<BasicSrcType>;
export declare abstract class ImageBase extends View {
static finalImageSetEvent: string;
static failureEvent: string;
static intermediateImageFailedEvent: string;
static intermediateImageSetEvent: string;
static releaseEvent: string;
static submitEvent: string;
static fetchingFromEvent: string;
src: SrcType;
lowerResSrc: string;
placeholderImageUri: string;
failureImageUri: string;
stretch: ScaleType;
fadeDuration: number;
imageRotation: number;
backgroundUri: string;
progressiveRenderingEnabled: boolean;
localThumbnailPreviewsEnabled: boolean;
showProgressBar: boolean;
progressBarColor: Color | string;
roundAsCircle: boolean;
roundBottomRightRadius: number;
roundTopLeftRadius: number;
roundTopRightRadius: number;
roundBottomLeftRadius: number;
blurRadius: number;
blurDownSampling: number;
autoPlayAnimations: boolean;
tapToRetryEnabled: boolean;
aspectRatio: number;
decodeWidth: number;
decodeHeight: number;
animatedImageView: boolean;
loadMode: 'sync' | 'async';
alwaysFade: boolean;
noCache: boolean;
noRatioEnforce: boolean;
tintColor: Color;
headers: Record<string, string>;
readonly isLoading: boolean;
get nativeImageViewProtected(): any;
mCanRequestImage: boolean;
mNeedRequestImage: boolean;
protected abstract initImage(): any;
onResumeNativeUpdates(): void;
protected handleImageProgress(value: number, totalSize?: number): void;
private static needsSizeAdjustment;
computeScaleFactor(measureWidth: number, measureHeight: number, widthIsFinite: boolean, heightIsFinite: boolean, nativeWidth: number, nativeHeight: number, aspectRatio: number): {
width: number;
height: number;
};
}