From a0e29f419a8bc25642242489d7b34c4bd1d8dbb6 Mon Sep 17 00:00:00 2001 From: Teemu Tiilikainen Date: Wed, 29 Jun 2016 15:48:54 +0300 Subject: [PATCH 1/5] Implemented ActivityIndicator --- src/components/ActivityIndicator.js | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/components/ActivityIndicator.js diff --git a/src/components/ActivityIndicator.js b/src/components/ActivityIndicator.js new file mode 100644 index 0000000..09c2b20 --- /dev/null +++ b/src/components/ActivityIndicator.js @@ -0,0 +1,45 @@ +/** + * https://github.com/facebook/react-native/blob/master/Libraries/Components/ActivityIndicator/ActivityIndicator.js + */ +import React from 'react'; +import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; +import View from './View'; + +const { PropTypes } = React; + +const ActivityIndicator = React.createClass({ + mixins: [NativeMethodsMixin], + propTypes: { + ...View.propTypes, + /** + * Whether to show the indicator (true, the default) or hide it (false). + */ + animating: PropTypes.bool, + /** + * The foreground color of the spinner (default is gray). + */ + color: PropTypes.string, + /** + * Whether the indicator should hide when not animating (true by default). + */ + hidesWhenStopped: PropTypes.bool, + /** + * Size of the indicator. Small has a height of 20, large has a height of 36. + */ + size: PropTypes.oneOf([ + 'small', + 'large', + ]), + /** + * Invoked on mount and layout changes with + * + * {nativeEvent: { layout: {x, y, width, height}}}. + */ + onLayout: PropTypes.func, + }, + render() { + return null; + }, +}); + +module.exports = ActivityIndicator; From 02640b5fa7e41cf14d26f19a6bda7b9c892c9ee6 Mon Sep 17 00:00:00 2001 From: Teemu Tiilikainen Date: Wed, 29 Jun 2016 15:49:51 +0300 Subject: [PATCH 2/5] Update ActivityIndicatorIOS comment URL --- src/components/ActivityIndicatorIOS.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ActivityIndicatorIOS.js b/src/components/ActivityIndicatorIOS.js index 721682f..ad953c9 100644 --- a/src/components/ActivityIndicatorIOS.js +++ b/src/components/ActivityIndicatorIOS.js @@ -1,5 +1,5 @@ /** - * https://github.com/facebook/react-native/blob/master/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.js + * https://github.com/facebook/react-native/blob/master/Libraries/Components/ActivityIndicator/ActivityIndicatorIOS.ios.js */ import React from 'react'; import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; From ee59d44d9e9b7c6da6c6281ac8a42a1c15d0781e Mon Sep 17 00:00:00 2001 From: Teemu Tiilikainen Date: Wed, 29 Jun 2016 15:50:11 +0300 Subject: [PATCH 3/5] Include ActivityIndicator on React Native --- src/react-native.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/react-native.js b/src/react-native.js index 2493ed6..fed7e52 100644 --- a/src/react-native.js +++ b/src/react-native.js @@ -8,6 +8,7 @@ import createMockComponent from './components/createMockComponent'; // Export React, plus some native additions. const ReactNative = { // Components + ActivityIndicator: require('./components/ActivityIndicator'), ActivityIndicatorIOS: require('./components/ActivityIndicatorIOS'), ART: require('./components/ART'), DatePickerIOS: createMockComponent('DatePickerIOS'), From 347262c6e3cb3af0ce5037b44ef14cbd34a5dceb Mon Sep 17 00:00:00 2001 From: Teemu Tiilikainen Date: Wed, 29 Jun 2016 16:21:16 +0300 Subject: [PATCH 4/5] Place mixins after propTypes --- src/components/ActivityIndicator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ActivityIndicator.js b/src/components/ActivityIndicator.js index 09c2b20..995f52b 100644 --- a/src/components/ActivityIndicator.js +++ b/src/components/ActivityIndicator.js @@ -8,7 +8,6 @@ import View from './View'; const { PropTypes } = React; const ActivityIndicator = React.createClass({ - mixins: [NativeMethodsMixin], propTypes: { ...View.propTypes, /** @@ -37,6 +36,7 @@ const ActivityIndicator = React.createClass({ */ onLayout: PropTypes.func, }, + mixins: [NativeMethodsMixin], render() { return null; }, From afe12a9cda18ca8c7e25e73c76ce91a7dcb796be Mon Sep 17 00:00:00 2001 From: Teemu Tiilikainen Date: Thu, 30 Jun 2016 09:44:22 +0300 Subject: [PATCH 5/5] Use ColorPropType to validate color prop --- src/components/ActivityIndicator.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/ActivityIndicator.js b/src/components/ActivityIndicator.js index 995f52b..7d0f447 100644 --- a/src/components/ActivityIndicator.js +++ b/src/components/ActivityIndicator.js @@ -4,6 +4,7 @@ import React from 'react'; import NativeMethodsMixin from '../mixins/NativeMethodsMixin'; import View from './View'; +import ColorPropType from '../propTypes/ColorPropType'; const { PropTypes } = React; @@ -17,7 +18,7 @@ const ActivityIndicator = React.createClass({ /** * The foreground color of the spinner (default is gray). */ - color: PropTypes.string, + color: ColorPropType, /** * Whether the indicator should hide when not animating (true by default). */