Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Examples/UIExplorer/js/ActivityIndicatorExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ exports.examples = [
return (
<ActivityIndicator
style={[styles.centering, styles.gray]}
color="white"
size="large"
color="white"
/>
);
}
Expand Down Expand Up @@ -161,8 +161,21 @@ exports.examples = [
);
}
},
{
platform: 'android',
title: 'Custom size (size: 75)',
render() {
return (
<ActivityIndicator
style={styles.centering}
size={75}
/>
);
}
},
];


const styles = StyleSheet.create({
centering: {
alignItems: 'center',
Expand Down
26 changes: 20 additions & 6 deletions Libraries/Components/ActivityIndicator/ActivityIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ const requireNativeComponent = require('requireNativeComponent');

const GRAY = '#999999';

type IndicatorSize = number | 'small' | 'large';

type DefaultProps = {
animating: boolean;
color: any;
hidesWhenStopped: boolean;
size: IndicatorSize;
}

/**
* Displays a circular loading indicator.
*/
Expand All @@ -40,12 +49,12 @@ 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.
* Size of the indicator (default is 'small').
* Passing a number to the size prop is only supported on Android.
*/
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 @@ -55,7 +64,7 @@ const ActivityIndicator = React.createClass({
hidesWhenStopped: PropTypes.bool,
},

getDefaultProps() {
getDefaultProps(): DefaultProps {
return {
animating: true,
color: Platform.OS === 'ios' ? GRAY : undefined,
Expand All @@ -67,14 +76,19 @@ 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;
default:
sizeStyle = {height: props.size, width: props.size};
break;
}

return (
<View
onLayout={onLayout}
Expand Down