diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/src/components/ball-indicator/index.js b/src/components/ball-indicator/index.js index ab520e9..e6aa8df 100644 --- a/src/components/ball-indicator/index.js +++ b/src/components/ball-indicator/index.js @@ -5,20 +5,7 @@ import { View, Animated } from 'react-native'; import Indicator from '../indicator'; import styles from './styles'; -export default class BallIndicator extends PureComponent { - static defaultProps = { - color: 'rgb(0, 0, 0)', - count: 8, - size: 40, - }; - - static propTypes = { - ...Indicator.propTypes, - - color: PropTypes.string, - size: PropTypes.number, - }; - +class BallIndicator extends PureComponent { constructor(props) { super(props); @@ -84,3 +71,18 @@ export default class BallIndicator extends PureComponent { ); } } + +BallIndicator.defaultProps = { + color: 'rgb(0, 0, 0)', + count: 8, + size: 40, +}; + +BallIndicator.propTypes = { + ...Indicator.propTypes, + + color: PropTypes.string, + size: PropTypes.number, +}; + +export default BallIndicator; \ No newline at end of file diff --git a/src/components/bar-indicator/index.js b/src/components/bar-indicator/index.js index 6135ffb..fcbe1b9 100644 --- a/src/components/bar-indicator/index.js +++ b/src/components/bar-indicator/index.js @@ -5,21 +5,7 @@ import { View, Animated } from 'react-native'; import Indicator from '../indicator'; import styles from './styles'; -export default class BarIndicator extends PureComponent { - static defaultProps = { - count: 3, - - color: 'rgb(0, 0, 0)', - size: 40, - }; - - static propTypes = { - ...Indicator.propTypes, - - color: PropTypes.string, - size: PropTypes.number, - }; - +class BarIndicator extends PureComponent { constructor(props) { super(props); @@ -112,3 +98,19 @@ export default class BarIndicator extends PureComponent { ); } } + +BarIndicator.defaultProps = { + count: 3, + + color: 'rgb(0, 0, 0)', + size: 40, +}; + +BarIndicator.propTypes = { + ...Indicator.propTypes, + + color: PropTypes.string, + size: PropTypes.number, +}; + +export default BarIndicator; \ No newline at end of file diff --git a/src/components/dot-indicator/index.js b/src/components/dot-indicator/index.js index b49cbfd..f07f87a 100644 --- a/src/components/dot-indicator/index.js +++ b/src/components/dot-indicator/index.js @@ -5,22 +5,7 @@ import { Animated, Easing } from 'react-native'; import Indicator from '../indicator'; import styles from './styles'; -export default class DotIndicator extends PureComponent { - static defaultProps = { - animationEasing: Easing.inOut(Easing.ease), - - color: 'rgb(0, 0, 0)', - count: 4, - size: 16, - }; - - static propTypes = { - ...Indicator.propTypes, - - color: PropTypes.string, - size: PropTypes.number, - }; - +class DotIndicator extends PureComponent { constructor(props) { super(props); @@ -73,3 +58,20 @@ export default class DotIndicator extends PureComponent { ); } } + +DotIndicator.defaultProps = { + animationEasing: Easing.inOut(Easing.ease), + + color: 'rgb(0, 0, 0)', + count: 4, + size: 16, +}; + +DotIndicator.propTypes = { + ...Indicator.propTypes, + + color: PropTypes.string, + size: PropTypes.number, +}; + +export default DotIndicator; \ No newline at end of file diff --git a/src/components/indicator/index.js b/src/components/indicator/index.js index 0031d0d..ba530db 100644 --- a/src/components/indicator/index.js +++ b/src/components/indicator/index.js @@ -6,28 +6,7 @@ import RN from 'react-native/package'; const [major, minor] = RN.version.split('.').map((item) => Number(item)); const hasLoopSupport = !major && minor >= 45; -export default class Indicator extends PureComponent { - static defaultProps = { - animationEasing: Easing.linear, - animationDuration: 1200, - - animating: true, - interaction: true, - - count: 1, - }; - - static propTypes = { - animationEasing: PropTypes.func, - animationDuration: PropTypes.number, - - animating: PropTypes.bool, - interaction: PropTypes.bool, - - renderComponent: PropTypes.func, - count: PropTypes.number, - }; - +class Indicator extends PureComponent { constructor(props) { super(props); @@ -134,3 +113,27 @@ export default class Indicator extends PureComponent { ); } } + + +Indicator.defaultProps = { + animationEasing: Easing.linear, + animationDuration: 1200, + + animating: true, + interaction: true, + + count: 1, +}; + +Indicator.propTypes = { + animationEasing: PropTypes.func, + animationDuration: PropTypes.number, + + animating: PropTypes.bool, + interaction: PropTypes.bool, + + renderComponent: PropTypes.func, + count: PropTypes.number, +}; + +export default Indicator; \ No newline at end of file diff --git a/src/components/material-indicator/index.js b/src/components/material-indicator/index.js index 396b669..b59c9a1 100644 --- a/src/components/material-indicator/index.js +++ b/src/components/material-indicator/index.js @@ -5,21 +5,7 @@ import { View, Animated, Easing } from 'react-native'; import Indicator from '../indicator'; import styles from './styles'; -export default class MaterialIndicator extends PureComponent { - static defaultProps = { - animationDuration: 2400, - - color: 'rgb(0, 0, 0)', - size: 40, - }; - - static propTypes = { - ...Indicator.propTypes, - - color: PropTypes.string, - size: PropTypes.number, - }; - +class MaterialIndicator extends PureComponent { constructor(props) { super(props); @@ -122,3 +108,20 @@ export default class MaterialIndicator extends PureComponent { ); } } + + +MaterialIndicator.defaultProps = { + animationDuration: 2400, + + color: 'rgb(0, 0, 0)', + size: 40, +}; + +MaterialIndicator.propTypes = { + ...Indicator.propTypes, + + color: PropTypes.string, + size: PropTypes.number, +}; + +export default MaterialIndicator; \ No newline at end of file diff --git a/src/components/pacman-indicator/index.js b/src/components/pacman-indicator/index.js index 2fa373a..a875ad6 100644 --- a/src/components/pacman-indicator/index.js +++ b/src/components/pacman-indicator/index.js @@ -5,21 +5,7 @@ import { View, Animated, I18nManager } from 'react-native'; import Indicator from '../indicator'; import styles from './styles'; -export default class PacmanIndicator extends PureComponent { - static defaultProps = { - animationDuration: 600, - - color: 'rgb(0, 0, 0)', - size: 48, - }; - - static propTypes = { - ...Indicator.propTypes, - - color: PropTypes.string, - size: PropTypes.number, - }; - +class PacmanIndicator extends PureComponent { constructor(props) { super(props); @@ -131,3 +117,19 @@ export default class PacmanIndicator extends PureComponent { ); } } + +PacmanIndicator.defaultProps = { + animationDuration: 600, + + color: 'rgb(0, 0, 0)', + size: 48, +}; + +PacmanIndicator.propTypes = { + ...Indicator.propTypes, + + color: PropTypes.string, + size: PropTypes.number, +}; + +export default PacmanIndicator; \ No newline at end of file diff --git a/src/components/pulse-indicator/index.js b/src/components/pulse-indicator/index.js index 53bcf92..e8212b7 100644 --- a/src/components/pulse-indicator/index.js +++ b/src/components/pulse-indicator/index.js @@ -5,27 +5,7 @@ import { View, Animated, Easing } from 'react-native'; import Indicator from '../indicator'; import styles from './styles'; -export default class PulseIndicator extends PureComponent { - static defaultProps = { - animationEasing: Easing.out(Easing.ease), - - color: 'rgb(0, 0, 0)', - size: 40, - }; - - static propTypes = { - ...Indicator.propTypes, - - color: PropTypes.string, - size: PropTypes.number, - }; - - constructor(props) { - super(props); - - this.renderComponent = this.renderComponent.bind(this); - } - +class PulseIndicator extends PureComponent { renderComponent({ index, count, progress }) { let { size, color } = this.props; @@ -72,3 +52,19 @@ export default class PulseIndicator extends PureComponent { ); } } + +PulseIndicator.defaultProps = { + animationEasing: Easing.out(Easing.ease), + + color: "rgb(0, 0, 0)", + size: 40 +}; + +PulseIndicator.propTypes = { + ...Indicator.propTypes, + + color: PropTypes.string, + size: PropTypes.number +}; + +export default PulseIndicator; \ No newline at end of file diff --git a/src/components/skype-indicator/index.js b/src/components/skype-indicator/index.js index cfec80e..0a60d5c 100644 --- a/src/components/skype-indicator/index.js +++ b/src/components/skype-indicator/index.js @@ -5,28 +5,7 @@ import { View, Animated, Easing } from 'react-native'; import Indicator from '../indicator'; import styles from './styles'; -export default class SkypeIndicator extends PureComponent { - static defaultProps = { - animationDuration: 1600, - - color: 'rgb(0, 0, 0)', - count: 5, - size: 40, - - minScale: 0.2, - maxScale: 1.0, - }; - - static propTypes = { - ...Indicator.propTypes, - - color: PropTypes.string, - size: PropTypes.number, - - minScale: PropTypes.number, - maxScale: PropTypes.number, - }; - +class SkypeIndicator extends PureComponent { constructor(props) { super(props); @@ -88,3 +67,27 @@ export default class SkypeIndicator extends PureComponent { ); } } + + +SkypeIndicator.defaultProps = { + animationDuration: 1600, + + color: "rgb(0, 0, 0)", + count: 5, + size: 40, + + minScale: 0.2, + maxScale: 1.0 +}; + +SkypeIndicator.propTypes = { + ...Indicator.propTypes, + + color: PropTypes.string, + size: PropTypes.number, + + minScale: PropTypes.number, + maxScale: PropTypes.number +}; + +export default SkypeIndicator; diff --git a/src/components/ui-activity-indicator/index.js b/src/components/ui-activity-indicator/index.js index 84d4135..53ee3d6 100644 --- a/src/components/ui-activity-indicator/index.js +++ b/src/components/ui-activity-indicator/index.js @@ -1,24 +1,11 @@ -import PropTypes from 'prop-types'; -import React, { PureComponent } from 'react'; -import { View, Animated } from 'react-native'; +import PropTypes from "prop-types"; +import React, { PureComponent } from "react"; +import { View, Animated } from "react-native"; -import Indicator from '../indicator'; -import styles from './styles'; - -export default class UIActivityIndicator extends PureComponent { - static defaultProps = { - color: 'rgb(0, 0, 0)', - count: 12, - size: 40, - }; - - static propTypes = { - ...Indicator.propTypes, - - color: PropTypes.string, - size: PropTypes.number, - }; +import Indicator from "../indicator"; +import styles from "./styles"; +class UIActivityIndicator extends PureComponent { constructor(props) { super(props); @@ -27,23 +14,24 @@ export default class UIActivityIndicator extends PureComponent { renderComponent({ index, count, progress }) { let { size, color: backgroundColor } = this.props; - let angle = index * 360 / count; + let angle = (index * 360) / count; let layerStyle = { - transform: [{ - rotate: angle + 'deg', - }], + transform: [ + { + rotate: angle + "deg" + } + ] }; - let inputRange = Array - .from(new Array(count + 1), (undefined, index) => - index / count - ); + let inputRange = Array.from( + new Array(count + 1), + (undefined, index) => index / count + ); - let outputRange = Array - .from(new Array(count), (undefined, index) => - Math.max(1.0 - index * (1 / (count - 1)), 0) - ); + let outputRange = Array.from(new Array(count), (undefined, index) => + Math.max(1.0 - index * (1 / (count - 1)), 0) + ); for (let j = 0; j < index; j++) { outputRange.unshift(outputRange.pop()); @@ -56,8 +44,7 @@ export default class UIActivityIndicator extends PureComponent { height: size / 4, borderRadius: size / 20, backgroundColor, - opacity: progress - .interpolate({ inputRange, outputRange }), + opacity: progress.interpolate({ inputRange, outputRange }) }; return ( @@ -81,3 +68,18 @@ export default class UIActivityIndicator extends PureComponent { ); } } + +UIActivityIndicator.defaultProps = { + color: "rgb(0, 0, 0)", + count: 12, + size: 40 +}; + +UIActivityIndicator.propTypes = { + ...Indicator.propTypes, + + color: PropTypes.string, + size: PropTypes.number +}; + +export default UIActivityIndicator; diff --git a/src/components/wave-indicator/index.js b/src/components/wave-indicator/index.js index 4ea7ceb..2beb061 100644 --- a/src/components/wave-indicator/index.js +++ b/src/components/wave-indicator/index.js @@ -1,33 +1,11 @@ -import PropTypes from 'prop-types'; -import React, { PureComponent } from 'react'; -import { View, Animated, Easing } from 'react-native'; +import PropTypes from "prop-types"; +import React, { PureComponent } from "react"; +import { View, Animated, Easing } from "react-native"; -import Indicator from '../indicator'; -import styles from './styles'; - -export default class WaveIndicator extends PureComponent { - static defaultProps = { - animationEasing: Easing.out(Easing.ease), - animationDuration: 1600, - - waveFactor: 0.54, - waveMode: 'fill', - - color: 'rgb(0, 0, 0)', - count: 4, - size: 40, - }; - - static propTypes = { - ...Indicator.propTypes, - - waveFactor: PropTypes.number, - waveMode: PropTypes.oneOf(['fill', 'outline']), - - color: PropTypes.string, - size: PropTypes.number, - }; +import Indicator from "../indicator"; +import styles from "./styles"; +class WaveIndicator extends PureComponent { constructor(props) { super(props); @@ -36,24 +14,26 @@ export default class WaveIndicator extends PureComponent { renderComponent({ index, count, progress }) { let { size, color, waveFactor, waveMode } = this.props; - let fill = 'fill' === waveMode; + let fill = "fill" === waveMode; let waveStyle = { height: size, width: size, borderRadius: size / 2, - borderWidth: fill? 0 : Math.floor(size / 20), - [fill? 'backgroundColor' : 'borderColor']: color, - transform: [{ - scale: progress.interpolate({ - inputRange: [0, 1 - Math.pow(waveFactor, index), 1], - outputRange: [0, 0, 1], - }), - }], + borderWidth: fill ? 0 : Math.floor(size / 20), + [fill ? "backgroundColor" : "borderColor"]: color, + transform: [ + { + scale: progress.interpolate({ + inputRange: [0, 1 - Math.pow(waveFactor, index), 1], + outputRange: [0, 0, 1] + }) + } + ], opacity: progress.interpolate({ inputRange: [0, 1 - Math.pow(waveFactor, index), 1], - outputRange: [1, 1, 0], - }), + outputRange: [1, 1, 0] + }) }; return ( @@ -77,3 +57,27 @@ export default class WaveIndicator extends PureComponent { ); } } + +WaveIndicator.defaultProps = { + animationEasing: Easing.out(Easing.ease), + animationDuration: 1600, + + waveFactor: 0.54, + waveMode: "fill", + + color: "rgb(0, 0, 0)", + count: 4, + size: 40 +}; + +WaveIndicator.propTypes = { + ...Indicator.propTypes, + + waveFactor: PropTypes.number, + waveMode: PropTypes.oneOf(["fill", "outline"]), + + color: PropTypes.string, + size: PropTypes.number +}; + +export default WaveIndicator;