/
ImageProps.js
284 lines (249 loc) · 6.55 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/**
* Copyright (c) Meta Platforms, Inc. and 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 {ViewProps} from '../Components/View/ViewPropTypes';
import type {EdgeInsetsProp} from '../StyleSheet/EdgeInsetsPropType';
import type {
ColorValue,
ImageStyleProp,
ViewStyleProp,
} from '../StyleSheet/StyleSheet';
import type {LayoutEvent, SyntheticEvent} from '../Types/CoreEventTypes';
import typeof Image from './Image';
import type {ImageSource} from './ImageSource';
import type {Node, Ref} from 'react';
export type ImageLoadEvent = SyntheticEvent<
$ReadOnly<{|
source: $ReadOnly<{|
width: number,
height: number,
uri: string,
|}>,
|}>,
>;
type IOSImageProps = $ReadOnly<{|
/**
* A static image to display while loading the image source.
*
* See https://reactnative.dev/docs/image#defaultsource
*/
defaultSource?: ?ImageSource,
/**
* Invoked when a partial load of the image is complete.
*
* See https://reactnative.dev/docs/image#onpartialload
*/
onPartialLoad?: ?() => void,
/**
* Invoked on download progress with `{nativeEvent: {loaded, total}}`.
*
* See https://reactnative.dev/docs/image#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#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#accessibilitylabel
*/
accessibilityLabel?: ?Stringish,
/**
* Alias for accessibilityLabel
* See https://reactnative.dev/docs/image#accessibilitylabel
*/
'aria-label'?: ?Stringish,
/**
* Reperesents the nativeID of the associated label. When the assistive technology focuses on the component with this props.
*
* @platform android
*/
'aria-labelledby'?: ?string,
/**
* The text that's read by the screen reader when the user interacts with
* the image.
*
* See https://reactnative.dev/docs/image#alt
*/
alt?: ?Stringish,
/**
* blurRadius: the blur radius of the blur filter added to the image
*
* See https://reactnative.dev/docs/image#blurradius
*/
blurRadius?: ?number,
/**
* See https://reactnative.dev/docs/image#capinsets
*/
capInsets?: ?EdgeInsetsProp,
/**
* Adds the CORS related header to the request.
* Similar to crossorigin from HTML.
*
* See https://reactnative.dev/docs/image#crossorigin
*/
crossOrigin?: ?('anonymous' | 'use-credentials'),
/**
* Height of the image component.
*
* See https://reactnative.dev/docs/image#height
*/
height?: number,
/**
* Width of the image component.
*
* See https://reactnative.dev/docs/image#width
*/
width?: number,
/**
* Invoked on load error with `{nativeEvent: {error}}`.
*
* See https://reactnative.dev/docs/image#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#onlayout
*/
onLayout?: ?(event: LayoutEvent) => mixed,
/**
* Invoked when load completes successfully.
*
* See https://reactnative.dev/docs/image#onload
*/
onLoad?: ?(event: ImageLoadEvent) => void,
/**
* Invoked when load either succeeds or fails.
*
* See https://reactnative.dev/docs/image#onloadend
*/
onLoadEnd?: ?() => void,
/**
* Invoked on load start.
*
* See https://reactnative.dev/docs/image#onloadstart
*/
onLoadStart?: ?() => void,
/**
* See https://reactnative.dev/docs/image#resizemethod
*/
resizeMethod?: ?('auto' | 'resize' | 'scale'),
/**
* The image source (either a remote URL or a local file resource).
*
* See https://reactnative.dev/docs/image#source
*/
source?: ?ImageSource,
/**
* See https://reactnative.dev/docs/image#style
*/
style?: ?ImageStyleProp,
/**
* A string indicating which referrer to use when fetching the resource.
* Similar to referrerpolicy from HTML.
*
* See https://reactnative.dev/docs/image#referrerpolicy
*/
referrerPolicy?: ?(
| 'no-referrer'
| 'no-referrer-when-downgrade'
| 'origin'
| 'origin-when-cross-origin'
| 'same-origin'
| 'strict-origin'
| 'strict-origin-when-cross-origin'
| 'unsafe-url'
),
/**
* Determines how to resize the image when the frame doesn't match the raw
* image dimensions.
*
* See https://reactnative.dev/docs/image#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#testid
*/
testID?: ?string,
/**
* Changes the color of all the non-transparent pixels to the tintColor.
*
* See https://reactnative.dev/docs/image#tintcolor
*/
tintColor?: ColorValue,
/**
* A string representing the resource identifier for the image. Similar to
* src from HTML.
*
* See https://reactnative.dev/docs/image#src
*/
src?: ?string,
/**
* Similar to srcset from HTML.
*
* See https://reactnative.dev/docs/image#srcset
*/
srcSet?: ?string,
children?: empty,
|};
export type ImageBackgroundProps = $ReadOnly<{|
...ImageProps,
children?: Node,
/**
* Style applied to the outer View component
*
* See https://reactnative.dev/docs/imagebackground#style
*/
style?: ?ViewStyleProp,
/**
* Style applied to the inner Image component
*
* See https://reactnative.dev/docs/imagebackground#imagestyle
*/
imageStyle?: ?ImageStyleProp,
/**
* Allows to set a reference to the inner Image component
*
* See https://reactnative.dev/docs/imagebackground#imageref
*/
imageRef?: Ref<Image>,
|}>;