Skip to content

Commit 6d68599

Browse files
authored
export progressiveImage component (#3213)
1 parent b4aa69a commit 6d68599

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

src/components/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ export default {
134134
get ProgressBar() {
135135
return require('./progressBar').default;
136136
},
137+
get ProgressiveImage() {
138+
return require('./progressiveImage').default;
139+
},
137140
get StateScreen() {
138141
return require('./stateScreen').default;
139142
},
Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,37 @@
11
import React from 'react';
2-
import PropTypes from 'prop-types';
32
import {View, StyleSheet, Animated} from 'react-native';
4-
import AnimatedImage from '../animatedImage';
3+
import AnimatedImage, {AnimatedImageProps} from '../animatedImage';
54
import {Colors} from '../../style';
65

76
/**
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,
98
* and fades-in the full-sized image with animation once it's loaded
109
* @extends: AnimatedImage
1110
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/ProgressiveImageScreen.js
1211
*/
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, {}> {
1421
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-
};
2122

2223
thumbnailAnimated = new Animated.Value(0);
2324
imageAnimated = new Animated.Value(0);
2425

2526
getThumbnail = () => {
2627
const {thumbnailSource, ...props} = this.props;
2728

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}/>}/>;
3530
};
3631

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()}/>;
4435
}
4536
}
4637

@@ -50,5 +41,4 @@ const styles = StyleSheet.create({
5041
}
5142
});
5243

53-
5444
export default ProgressiveImage;

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export {
124124
PickerMethods
125125
} from './components/picker';
126126
export {default as ProgressBar, ProgressBarProps} from './components/progressBar';
127+
export {default as ProgressiveImage, ProgressiveImageProps} from './components/progressiveImage';
127128
export {default as RadioButton, RadioButtonProps} from './components/radioButton';
128129
export {default as RadioGroup, RadioGroupProps} from './components/radioGroup';
129130
export type {RecorderProps} from './typings/recorderTypes';

0 commit comments

Comments
 (0)