From b4dc4ed8e192c54717cab15606cadeaef7eb4154 Mon Sep 17 00:00:00 2001 From: Fadil Sutomo Date: Sun, 17 Jul 2016 14:38:59 +0700 Subject: [PATCH] Accept number for size prop 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. --- .../ActivityIndicator/ActivityIndicator.js | 47 ++++++++++++------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/Libraries/Components/ActivityIndicator/ActivityIndicator.js b/Libraries/Components/ActivityIndicator/ActivityIndicator.js index 282960556e3174..9dec74e456df76 100644 --- a/Libraries/Components/ActivityIndicator/ActivityIndicator.js +++ b/Libraries/Components/ActivityIndicator/ActivityIndicator.js @@ -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). @@ -67,24 +67,37 @@ 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; + let ReturnedActivityIndicator; + if (isNaN(props.size)) { + switch (props.size) { + case 'small': + sizeStyle = styles.sizeSmall; + break; + case 'large': + sizeStyle = styles.sizeLarge; + break; + } + + ReturnedActivityIndicator = ; + } else { + ReturnedActivityIndicator = ; } + return ( - + {ReturnedActivityIndicator} ); }