-
Notifications
You must be signed in to change notification settings - Fork 24k
/
ImageProps.js
174 lines (151 loc) · 4.2 KB
/
ImageProps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
'use strict';
import type {SyntheticEvent, LayoutEvent} from '../Types/CoreEventTypes';
import type {EdgeInsetsProp} from '../StyleSheet/EdgeInsetsPropType';
import type {ImageSource} from './ImageSource';
import type {ViewStyleProp, ImageStyleProp} from '../StyleSheet/StyleSheet';
import type {ViewProps} from '../Components/View/ViewPropTypes';
export type ImageLoadEvent = SyntheticEvent<
$ReadOnly<{|
source: $ReadOnly<{|
width: number,
height: number,
url: string,
|}>,
uri?: string, // Only on Android
|}>,
>;
type IOSImageProps = $ReadOnly<{|
/**
* A static image to display while loading the image source.
*
* See https://reactnative.dev/docs/image.html#defaultsource
*/
defaultSource?: ?ImageSource,
/**
* Invoked when a partial load of the image is complete.
*
* See https://reactnative.dev/docs/image.html#onpartialload
*/
onPartialLoad?: ?() => void,
/**
* Invoked on download progress with `{nativeEvent: {loaded, total}}`.
*
* See https://reactnative.dev/docs/image.html#onprogress
*/
onProgress?: ?(
event: SyntheticEvent<$ReadOnly<{|loaded: number, total: number|}>>,
) => void,
|}>;
type AndroidImageProps = $ReadOnly<{|
loadingIndicatorSource?: ?(number | $ReadOnly<{|uri: string|}>),
progressiveRenderingEnabled?: ?boolean,
fadeDuration?: ?number,
|}>;
export type ImageProps = {|
...$Diff<ViewProps, $ReadOnly<{|style: ?ViewStyleProp|}>>,
...IOSImageProps,
...AndroidImageProps,
/**
* When true, indicates the image is an accessibility element.
*
* See https://reactnative.dev/docs/image.html#accessible
*/
accessible?: ?boolean,
/**
* Internal prop to set an "Analytics Tag" that can will be set on the Image
*/
internal_analyticTag?: ?string,
/**
* The text that's read by the screen reader when the user interacts with
* the image.
*
* See https://reactnative.dev/docs/image.html#accessibilitylabel
*/
accessibilityLabel?: ?Stringish,
/**
* blurRadius: the blur radius of the blur filter added to the image
*
* See https://reactnative.dev/docs/image.html#blurradius
*/
blurRadius?: ?number,
/**
* See https://reactnative.dev/docs/image.html#capinsets
*/
capInsets?: ?EdgeInsetsProp,
/**
* Invoked on load error with `{nativeEvent: {error}}`.
*
* See https://reactnative.dev/docs/image.html#onerror
*/
onError?: ?(
event: SyntheticEvent<
$ReadOnly<{|
error: string,
|}>,
>,
) => void,
/**
* Invoked on mount and layout changes with
* `{nativeEvent: {layout: {x, y, width, height}}}`.
*
* See https://reactnative.dev/docs/image.html#onlayout
*/
onLayout?: ?(event: LayoutEvent) => mixed,
/**
* Invoked when load completes successfully.
*
* See https://reactnative.dev/docs/image.html#onload
*/
onLoad?: ?(event: ImageLoadEvent) => void,
/**
* Invoked when load either succeeds or fails.
*
* See https://reactnative.dev/docs/image.html#onloadend
*/
onLoadEnd?: ?() => void,
/**
* Invoked on load start.
*
* See https://reactnative.dev/docs/image.html#onloadstart
*/
onLoadStart?: ?() => void,
/**
* See https://reactnative.dev/docs/image.html#resizemethod
*/
resizeMethod?: ?('auto' | 'resize' | 'scale'),
/**
* The image source (either a remote URL or a local file resource).
*
* See https://reactnative.dev/docs/image.html#source
*/
source?: ?ImageSource,
/**
* See https://reactnative.dev/docs/image.html#style
*/
style?: ?ImageStyleProp,
/**
* Determines how to resize the image when the frame doesn't match the raw
* image dimensions.
*
* See https://reactnative.dev/docs/image.html#resizemode
*/
resizeMode?: ?('cover' | 'contain' | 'stretch' | 'repeat' | 'center'),
/**
* A unique identifier for this element to be used in UI Automation
* testing scripts.
*
* See https://reactnative.dev/docs/image.html#testid
*/
testID?: ?string,
src?: empty,
children?: empty,
|};