// @flow import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes' import type { SyntheticEvent } from 'react-native/Libraries/Types/CoreEventTypes' export type OnLoadEvent = SyntheticEvent< $ReadOnly<{ width: number, height: number, // The view's React tag. Missing on Android with the legacy architecture. // TODO: make it required once the New Architecture is the minimum. target?: number, }>, > export type OnErrorEvent = SyntheticEvent< $ReadOnly<{| error: string, |}>, > export type OnProgressEvent = SyntheticEvent< $ReadOnly<{| loaded: number, total: number, // loaded / total, from 0 to 1. progress: number, |}>, > export type ResizeMode = $ReadOnly<{| contain: 'contain', cover: 'cover', stretch: 'stretch', center: 'center', repeat: 'repeat', |}> export type Priority = $ReadOnly<{| low: 'low', normal: 'normal', high: 'high', |}> export type CacheControl = $ReadOnly<{| immutable: 'immutable', web: 'web', cacheOnly: 'cacheOnly', |}> export type ResizeModes = $Values export type Priorities = $Values export type CacheControls = $Values export type LoadResult = | {| ok: true, width: number, height: number |} | {| ok: false, error: string |} export type CacheLimits = {| maxDiskSize?: ?number, maxDiskAge?: ?number, maxMemorySize?: ?number, |} export type CacheState = {| maxDiskSize?: number, maxDiskAge?: number, maxMemorySize?: number, diskSize?: number, |} export type CachePathResult = | {| ok: true, path: string |} | {| ok: false, error: string |} export type ClearCacheResult = {| ok: true |} | {| ok: false, error: string |} export type Transition = $ReadOnly<{| duration?: ?number, betweenImages?: ?boolean, skipOnCacheHit?: ?('none' | 'memory' | 'all'), |}> export type PreloadSuccess = {| uri: string, ok: true, width: number, height: number, |} export type PreloadFailure = {| uri?: string, ok: false, error: string, |} export type PreloadResult = PreloadSuccess | PreloadFailure export type PreloadFn = ( sources: Array, ) => Promise> export type FastImageSource = { uri?: string, headers?: Object, priority?: Priorities, cache?: CacheControls, cacheKey?: string, memoryCache?: boolean, width?: number, height?: number, scale?: number, } export type FastImageProps = $ReadOnly<{| ...ViewProps, onError?: ?(event: OnErrorEvent) => void, onLoad?: ?(event: OnLoadEvent) => void, onLoadEnd?: ?(result: LoadResult) => void, onLoadStart?: ?() => void, onProgress?: ?(event: OnProgressEvent) => void, source?: ?(FastImageSource | Array | number), defaultSource?: ?number, tintColor?: number | string, resizeMode?: ?ResizeModes, fallback?: ?boolean, recyclingKey?: ?string, loop?: ?(boolean | number), imageRendering?: ?('auto' | 'smooth' | 'pixelated'), paused?: ?boolean, transition?: ?(boolean | number | Transition), downsample?: ?boolean, blurRadius?: ?number, testID?: ?string, |}> export type FastImageBackgroundProps = $ReadOnly<{| ...FastImageProps, imageStyle?: $PropertyType, imageRef?: React$Ref, children?: React$Node, |}> declare export var FastImageBackground: React$ComponentType declare export default class FastImage extends React$Component { static resizeMode: ResizeMode; static priority: Priority; static cacheControl: CacheControl; static preload: PreloadFn; static clearMemoryCache: () => Promise; static clearDiskCache: () => Promise; static getCachePath: (source: FastImageSource) => Promise; static configureCache: (limits?: CacheLimits) => Promise; static writeToCache: ( source: FastImageSource, file: string, ) => Promise; }