-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIconButton.js
45 lines (41 loc) · 1.19 KB
/
IconButton.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
import React from 'react'
import PropTypes from 'prop-types'
import Button from './Button'
import { Metrics, Colors } from './Themes'
import styles from './Styles/ButtonStyles'
const IconButton = ({ icon, size, active, disabled, activityIndicatorColor, backgroundColor, borderColor, round, onPress }) => {
let borderRadius = 0
if (round) {
borderRadius = size / 2
}
const customStyle = { width: size, height: size, backgroundColor, borderColor, borderRadius }
return (
<Button
active={active}
disabled={disabled}
onPress={onPress}
style={[ styles.IconButton, customStyle ]}
activityIndicatorColor={activityIndicatorColor}
>
{icon}
</Button>
)
}
IconButton.defaultProps = {
activityIndicatorColor: Colors.snow,
backgroundColor: Colors.transparent,
borderColor: Colors.transparent,
size: Metrics.baseSize
}
IconButton.propTypes = {
round: PropTypes.bool,
active: PropTypes.bool,
disabled: PropTypes.bool,
size: PropTypes.number,
icon: PropTypes.element,
borderColor: PropTypes.string,
backgroundColor: PropTypes.string,
activityIndicatorColor: PropTypes.string,
onPress: PropTypes.func.isRequired
}
export default IconButton