-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathindex.android.js
52 lines (45 loc) · 986 Bytes
/
index.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
51
52
import React, { Component } from 'react';
import {
View,
Image,
StyleSheet,
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={styles.capInset}
source={normalizedSource}
/>
{children}
</View>
);
}
}
NinePatchView.propTypes = {
...View.propTypes,
source: Image.propTypes.source,
};
const RCTImageCapInset = requireNativeComponent('RCTImageCapInset', {
propTypes: NinePatchView.propTypes,
});
const styles = StyleSheet.create({
capInset: {
resizeMode: 'stretch',
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0
}
});
export default NinePatchView;