1import * as React from 'react';
2import { StyleSheet, View, ViewStyle } from 'react-native';
3
4import { defaultImage } from './images';
5import { ImageProps } from './types';
6
7type PropsType = {
8  style?: ViewStyle;
9  imageProps: ImageProps;
10  ImageComponent: React.ComponentType<any>;
11};
12
13export default class ImageTestView extends React.PureComponent<PropsType> {
14  render() {
15    const { imageProps, ImageComponent } = this.props;
16    const { style, defaultStyle, source, ...otherImageProps } = imageProps;
17    return (
18      <View style={styles.container}>
19        <ImageComponent
20          style={[defaultStyle || styles.image, defaultStyle ? undefined : this.props.style, style]}
21          source={source || defaultImage}
22          {...otherImageProps}
23        />
24      </View>
25    );
26  }
27}
28
29const styles = StyleSheet.create({
30  container: {
31    flex: 1,
32    justifyContent: 'center',
33    alignItems: 'center',
34    backgroundColor: 'white',
35  },
36  image: {
37    width: 200,
38    height: 200,
39  },
40});
41