forked from rusfearuth/react-native-9patch-image
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.android.js
More file actions
41 lines (35 loc) · 901 Bytes
/
index.android.js
File metadata and controls
41 lines (35 loc) · 901 Bytes
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
import React, { Component } from 'react';
import {
View,
Image,
requireNativeComponent,
} from 'react-native';
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
class NinePatchView extends Component {
render() {
const {
children,
source,
...rest
} = this.props;
const normalizedSource = resolveAssetSource(source);
return (
<View {...rest}>
<RCTImageCapInset
style={{position: 'absolute', top: 0, left: 0, bottom: 0, right: 0}}
source={normalizedSource}
resizeMode={Image.resizeMode.stretch}
/>
{children}
</View>
);
}
}
NinePatchView.propTypes = {
...View.propTypes,
source: Image.propTypes.source,
};
const RCTImageCapInset = requireNativeComponent('RCTImageCapInset', {
propTypes: NinePatchView.propTypes,
});
export default NinePatchView;