-
Notifications
You must be signed in to change notification settings - Fork 4
/
ImageCapInset.android.js
50 lines (44 loc) · 1.36 KB
/
ImageCapInset.android.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
import React from 'react';
import PropTypes from 'prop-types';
import {
View,
Image,
requireNativeComponent,
} from 'react-native';
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
class ImageCapInset extends React.Component {
render() {
const {children, source, capInsets, ...rest} = this.props;
const normalizedSource = resolveAssetSource(source);
// noinspection JSUnresolvedVariable
return (
<View {...rest}>
<RCTImageCapInset
capInsets={capInsets}
resizeMode={'stretch'}
source={normalizedSource}
style={{position: 'absolute', top: 0, left: 0, bottom: 0, right: 0}} />
{children}
</View>
);
}
}
ImageCapInset.propTypes = {
...View.propTypes,
source: Image.propTypes.source,
capInsets: PropTypes.shape({
top: PropTypes.number,
left: PropTypes.number,
right: PropTypes.number,
bottom: PropTypes.number,
}),
};
ImageCapInset.defaultProps = {
...View.defaultProps,
capInsets: {top: 0, left: 0, right: 0, bottom: 0},
};
const RCTImageCapInset = requireNativeComponent('RCTImageCapInset', {
propTypes: ImageCapInset.propTypes,
});
// noinspection JSUnusedGlobalSymbols
export default ImageCapInset;