-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathroundImage.js
More file actions
79 lines (70 loc) · 1.88 KB
/
roundImage.js
File metadata and controls
79 lines (70 loc) · 1.88 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import { Image, StyleSheet, ViewPropTypes, View, ImageBackground } from 'react-native';
import Icon from './images/icon_default_logo.png'
class RoundImage extends Component{
constructor(props) {
super(props)
this.state = {
isLoadError: false
}
}
render() {
const {isLoadError} = this.state
const props = this.props;
return(
<View
style={[
styles,
{ height: props.size, width: props.size, backgroundColor: 'white' },
props.rounded && { borderRadius: props.size / 2, borderWidth: 0 },
props.style
]}
>
<Image
{...props}
style={[
// styles,
{ height: props.size, width: props.size },
props.rounded && { borderRadius: props.size / 2, borderWidth: 0 },
// props.style
]}
source={
props.source.uri
? props.source
: require('./images/icon_default_logo.png')
}
resizeMode={props.resizeMode}
defaultSource={Icon}
/>
</View>
)
}
}
// const Avatar = props => (
//
// );
RoundImage.defaultProps = {
size: 55,
rounded: false,
resizeMode: 'contain'
};
RoundImage.propTypes = {
size: PropTypes.number,
style: ViewPropTypes.style,
source: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),
rounded: PropTypes.bool,
resizeMode: PropTypes.string
};
const styles = {
borderRadius: 4,
borderWidth: StyleSheet.hairlineWidth,
borderColor: '#E0E0E0',
// alignSelf: 'flex-start',
// marginTop: 3,
justifyContent: 'center',
alignItems: 'center',
overlayColor: 'white',
overflow: 'hidden'
};
export default RoundImage