-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathIconBadge.js
52 lines (50 loc) · 1.14 KB
/
IconBadge.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, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {StyleSheet, View} from 'react-native';
const styles = StyleSheet.create({
IconBadge: {
position: 'absolute',
top: 1,
right: 1,
minWidth: 20,
height: 20,
borderRadius: 15,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#FF0000',
},
});
export default class IconBadge extends PureComponent {
static propTypes = {
MainElement: PropTypes.element.isRequired,
BadgeElement: PropTypes.element.isRequired,
MainViewStyle: PropTypes.object,
IconBadgeStyle: PropTypes.object,
Hidden: PropTypes.bool,
};
static defaultProps = {
MainViewStyle: {},
IconBadgeStyle: {},
Hidden: true,
};
state = {};
render() {
const {
MainViewStyle,
MainElement,
Hidden,
IconBadgeStyle,
BadgeElement,
} = this.props;
return (
<View style={[MainViewStyle || {}]}>
{MainElement}
{!Hidden && (
<View style={[styles.IconBadge, IconBadgeStyle || {}]}>
{BadgeElement}
</View>
)}
</View>
);
}
}