-
Notifications
You must be signed in to change notification settings - Fork 54
/
ImageCapInset.android.js
50 lines (44 loc) · 1.1 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, { Component } 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 Component {
render() {
const {
children,
source,
capInsets,
...rest
} = this.props;
const normalizedSource = resolveAssetSource(source);
return (
<View {...rest}>
<RCTImageCapInset
style={{position: 'absolute', top: 0, left: 0, bottom: 0, right: 0}}
capInsets={capInsets}
source={normalizedSource}
resizeMode={'stretch'}
/>
{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,
}),
};
const RCTImageCapInset = requireNativeComponent('RCTImageCapInset', {
propTypes: ImageCapInset.propTypes,
});
export default ImageCapInset;