Skip to content

Commit

Permalink
Accept number for size prop
Browse files Browse the repository at this point in the history
Previously, size can only accept either 'small' or 'large'.
And to obtain a custom size, scale transformation is used.
This is to let users to possibly pass number value to define
ActivityIndicator's size.
  • Loading branch information
fadils committed Jul 17, 2016
1 parent abe9f51 commit 1d4eeda
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions Libraries/Components/ActivityIndicator/ActivityIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ const ActivityIndicator = React.createClass({
color: ColorPropType,
/**
* Size of the indicator. Small has a height of 20, large has a height of 36.
* Other sizes can be obtained using a scale transform.
* Other sizes can be obtained by passing a number of by using a scale transform.
*/
size: PropTypes.oneOf([
'small',
'large',
size: PropTypes.oneOfType([
PropTypes.oneOf(['small','large',]),
PropTypes.number,
]),
/**
* Whether the indicator should hide when not animating (true by default).
Expand All @@ -67,14 +67,20 @@ const ActivityIndicator = React.createClass({
render() {
const {onLayout, style, ...props} = this.props;
let sizeStyle;
switch (props.size) {
case 'small':
sizeStyle = styles.sizeSmall;
break;
case 'large':
sizeStyle = styles.sizeLarge;
break;
if (isNaN(props.size)) {
switch (props.size) {
case 'small':
sizeStyle = styles.sizeSmall;
break;
case 'large':
sizeStyle = styles.sizeLarge;
break;
}

} else {
sizeStyle = {height: props.size, width: props.size};
}

return (
<View
onLayout={onLayout}
Expand All @@ -84,7 +90,7 @@ const ActivityIndicator = React.createClass({
style={sizeStyle}
styleAttr="Normal"
indeterminate
/>
/>
</View>
);
}
Expand Down

0 comments on commit 1d4eeda

Please sign in to comment.