1
1
import React from 'react' ;
2
- import PropTypes from 'prop-types' ;
3
2
import { View , StyleSheet , Animated } from 'react-native' ;
4
- import AnimatedImage from '../animatedImage' ;
3
+ import AnimatedImage , { AnimatedImageProps } from '../animatedImage' ;
5
4
import { Colors } from '../../style' ;
6
5
7
6
/**
8
- * @description : Image component that loads first a small thumbnail of the images,
7
+ * @description : Image component that loads first a small thumbnail of the images,
9
8
* and fades-in the full-sized image with animation once it's loaded
10
9
* @extends : AnimatedImage
11
10
* @example : https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/ProgressiveImageScreen.js
12
11
*/
13
- class ProgressiveImage extends React . Component {
12
+
13
+ export type ProgressiveImageProps = {
14
+ /**
15
+ * small thumbnail source to display while the full-size image is loading
16
+ */
17
+ thumbnailSource : AnimatedImageProps [ 'source' ] ;
18
+ } ;
19
+
20
+ class ProgressiveImage extends React . Component < ProgressiveImageProps , { } > {
14
21
static displayName = 'ProgressiveImage' ;
15
- static propTypes = {
16
- /**
17
- * small thumbnail source to display while the full-size image is loading
18
- */
19
- thumbnailSource : PropTypes . object
20
- } ;
21
22
22
23
thumbnailAnimated = new Animated . Value ( 0 ) ;
23
24
imageAnimated = new Animated . Value ( 0 ) ;
24
25
25
26
getThumbnail = ( ) => {
26
27
const { thumbnailSource, ...props } = this . props ;
27
28
28
- return (
29
- < AnimatedImage
30
- { ...props }
31
- source = { thumbnailSource }
32
- loader = { < View style = { styles . container } /> }
33
- />
34
- ) ;
29
+ return < AnimatedImage { ...props } source = { thumbnailSource } loader = { < View style = { styles . container } /> } /> ;
35
30
} ;
36
31
37
- render ( ) {
38
- return (
39
- < AnimatedImage
40
- { ...this . props }
41
- loader = { this . getThumbnail ( ) }
42
- />
43
- ) ;
32
+ render ( ) {
33
+ //@ts -ignore
34
+ return < AnimatedImage { ...this . props } loader = { this . getThumbnail ( ) } /> ;
44
35
}
45
36
}
46
37
@@ -50,5 +41,4 @@ const styles = StyleSheet.create({
50
41
}
51
42
} ) ;
52
43
53
-
54
44
export default ProgressiveImage ;
0 commit comments