Repository: wangdicoder/react-native-indicator
Branch: master
Commit: 666e616e40a2
Files: 32
Total size: 50.3 KB
Directory structure:
gitextract_oiiy0_mm/
├── .gitignore
├── .npmignore
├── .prettierrc
├── LICENSE
├── README.md
├── index.js
├── lib/
│ ├── animated/
│ │ ├── AnimatedBar.js
│ │ └── AnimatedCircle.js
│ ├── const/
│ │ └── index.js
│ ├── loader/
│ │ ├── BreathingLoader.js
│ │ ├── BubblesLoader.js
│ │ ├── CirclesLoader.js
│ │ ├── CirclesRotationScaleLoader.js
│ │ ├── ColorDotsLoader.js
│ │ ├── DotsLoader.js
│ │ ├── DoubleCircleLoader.js
│ │ ├── EatBeanLoader.js
│ │ ├── LineDotsLoader.js
│ │ ├── LinesLoader.js
│ │ ├── MusicLoader.js
│ │ ├── NineCubesLoader.js
│ │ ├── OpacityDotsLoader.js
│ │ ├── PulseLoader.js
│ │ ├── RippleLoader.js
│ │ ├── RotationCircleLoader.js
│ │ ├── RotationHoleLoader.js
│ │ └── TextLoader.js
│ └── shape/
│ ├── Bar.js
│ ├── Bar2.js
│ ├── Bar3.js
│ └── Circle.js
└── package.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
/.idea
/node_modules
================================================
FILE: .npmignore
================================================
/screenshot
/.idea
/node_modules
.prettierrc
README.md
================================================
FILE: .prettierrc
================================================
{
"printWidth": 100,
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"bracketSpacing": true,
"arrowParens": "always"
}
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2016 Di Wang
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# react-native-indicator
  [](https://www.npmjs.com/package/react-native-indicator)
A useful indicator component for React Native
<img src="https://raw.githubusercontent.com/wangdicoder/react-native-indicator/master/screenshot/ss1.gif" width="372" height="666" />
<img src="https://raw.githubusercontent.com/wangdicoder/react-native-indicator/master/screenshot/ss2.gif" width="372" height="666" />
<img src="https://raw.githubusercontent.com/wangdicoder/react-native-indicator/master/screenshot/ss3.gif" width="372" height="666" />
<img src="https://raw.githubusercontent.com/wangdicoder/react-native-indicator/master/screenshot/ss4.gif" width="372" height="666" />
## Installation
Make sure that you are in your React Native project directory and run:
```
$ npm install react-native-indicator --save
$ npm install @react-native-community/art --save
```
For react-native >= 0.60 ReactNativeART should be auto-linked and no additional action is required.
For react-native < 0.60 you need to link ReactNative ART:
```
$ react-native link @react-native-community/art
```
More info, following the [Art module](https://github.com/react-native-community/art) instruction to configure.
## Usage
Import react-native-indicator as a JavaScript module:
```
import { CirclesLoader, PulseLoader, TextLoader, DotsLoader, ... } from 'react-native-indicator';
```
Here is currently available types:
- [PulseLoader](#PulseLoader)
- [DotsLoader](#DotsLoader)
- [TextLoader](#TextLoader)
- [BubblesLoader](#BubblesLoader)
- [CirclesLoader](#CirclesLoader)
- [BreathingLoader](#BreathingLoader)
- [RippleLoader](#RippleLoader)
- [LinesLoader](#LinesLoader)
- [MusicBarLoader](#MusicBarLoader)
- [EatBeanLoader](#EatBeanLoader)
- [DoubleCircleLoader](#DoubleCircleLoader)
- [RotationCircleLoader](#RotationCircleLoader)
- [RotationHoleLoader](#RotationHoleLoader)
- [CirclesRotationScaleLoader](#CirclesRotationScaleLoader)
- [NineCubesLoader](#NineCubesLoader)
- [LineDotsLoader](#LineDotsLoader)
- [ColorDotsLoader](#ColorDotsLoader)
- [OpacityDotsLoader](#OpacityDotsLoader)
```
render(){
return(
<View>
<CirclesLoader />
<TextLoader text="Loading" />
</View>
);
}
```
## Props
<a name="PulseLoader" />
##### PulseLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| size | number | 30 | circle's size |
| color | string | '#1e90ff' | indicator's color |
| frequency | number | 1000 | scale's frequency |
<a name="DotsLoader" />
##### DotsLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| size | number | 10 | dot's size |
| color | string | '#1e90ff' | indicator's color |
| betweenSpace | number | 5 | distance between two dots |
<a name="TextLoader" />
##### TextLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| text | string | 'Loading' | contents |
| textStyle | style | inherited | text's style |
<a name="BubblesLoader" />
##### BubblesLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| size | number | 40 | circle's size |
| color | string | '#1e90ff' | indicator's color |
| dotRadius | number | 10 | each dot's size |
<a name="CirclesLoader" />
##### CirclesLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| size | number | 40 | circle's size |
| color | string | '#1e90ff' | indicator's color |
| dotRadius | number | 8 | each dot's size |
<a name="BreathingLoader" />
##### BreathingLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| size | number | 10 | circle's size |
| color | string | '#1e90ff' | indicator's color |
| strokeWidth | number | 3 | outline width |
| frequency | number | 800 | scale's frequency |
<a name="RippleLoader" />
##### RippleLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| size | number | 10 | circle's size |
| frequency | number | 1600 | scale's frequency |
| color | string | '#1e90ff' | indicator's color |
| strokeWidth | number | 3 | outline width |
<a name="LinesLoader" />
##### LinesLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| color | string | '#1e90ff' | indicator's color |
| barWidth | number | 5 | each bar's width |
| barHeight | number | 40 | each bar's height |
| barNumber | number | 5 | the number of bar |
| betweenSpace | number | 2 | distance between two bars |
<a name="MusicBarLoader" />
##### MusicBarLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| color | string | '#1e90ff' | indicator's color |
| barWidth | number | 3 | each bar's width |
| barHeight | number | 30 | each bar's height |
| betweenSpace | number | 5 | distance between two bars |
<a name="EatBeanLoader" />
##### EatBeanLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| color | string | '#1e90ff' | indicator's color |
| size | number | 30 | indicator's size |
<a name="DoubleCircleLoader" />
##### DoubleCircleLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| size | number | 30 | circle's size |
| color | string | '#1e90ff' | indicator's color |
<a name="RotationCircleLoader" />
##### RotationCircleLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| size | number | 30 | indicator's size |
| color | string | '#1e90ff' | indicator's color |
| rotationSpeed | number | 800 | rotation speed |
<a name="RotationHoleLoader" />
##### RotationHoleLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| size | number | 40 | indicator's size |
| color | string | '#1e90ff' | indicator's color |
| rotationSpeed | number | 800 | rotation speed |
| strokeWidth | number | 8 | circle outline's width |
<a name="CirclesRotationScaleLoader" />
##### CirclesRotationScaleLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| size | number | 50 | indicator's size |
| color | string | '#1e90ff' | indicator's color |
<a name="NineCubesLoader" />
##### NineCubesLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| size | number | 20 | each cube's size |
| color | string | '#1e90ff' | indicator's color |
<a name="LineDotsLoader" />
##### LineDotsLoader
**warning:** *this indicator will occupy a whole horizontal space automatically, which means you don't need to set any center props. Just keeping the direction of its parent View is vertical.*
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| size | number | 10 | dot's size |
| color | string | '#1e90ff' | indicator's color |
| dotsNumber | number | 5 | the number of dots |
| betweenSpace | number | 5 | distance between two dots |
<a name="ColorDotsLoader" />
##### ColorDotsLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| size | number | 15 | each cube's size |
| betweenSpace | number | 7 | distance between two dots |
| color1 | string | '#ff4500'(red) | 1st color |
| color2 | string | '#ffd700'(yellow) | 2nd color |
| color3 | string | '#9acd32'(green) | 3rd color |
##### OpacityDotsLoader
| prop | type | default | description |
| ---- | ---- | ---- | ---- |
| size | number | 10 | dot's size |
| color | string | '#1e90ff' | indicator's color |
| betweenSpace | number | 5 | distance between two dots |
| speed | number | 200 | change speed |
## License
MIT
================================================
FILE: index.js
================================================
import Breathing from './lib/loader/BreathingLoader';
import Bubbles from './lib/loader/BubblesLoader';
import Circles from './lib/loader/CirclesLoader';
import CirclesRotationScale from './lib/loader/CirclesRotationScaleLoader';
import ColorDots from './lib/loader/ColorDotsLoader';
import Dots from './lib/loader/DotsLoader';
import DoubleCircle from './lib/loader/DoubleCircleLoader';
import EatBean from './lib/loader/EatBeanLoader';
import Lines from './lib/loader/LinesLoader';
import LineDots from './lib/loader/LineDotsLoader';
import Music from './lib/loader/MusicLoader';
import NineCubes from './lib/loader/NineCubesLoader';
import OpacityDots from './lib/loader/OpacityDotsLoader';
import Pulse from './lib/loader/PulseLoader';
import Ripple from './lib/loader/RippleLoader';
import RotationCircle from './lib/loader/RotationCircleLoader';
import RotationHole from './lib/loader/RotationHoleLoader';
import Text from './lib/loader/TextLoader';
export const BreathingLoader = Breathing;
export const BubblesLoader = Bubbles;
export const CirclesLoader = Circles;
export const CirclesRotationScaleLoader = CirclesRotationScale;
export const ColorDotsLoader = ColorDots;
export const DotsLoader = Dots;
export const DoubleCircleLoader = DoubleCircle;
export const EatBeanLoader = EatBean;
export const LinesLoader = Lines;
export const LineDotsLoader = LineDots;
export const MusicBarLoader = Music;
export const NineCubesLoader = NineCubes;
export const OpacityDotsLoader = OpacityDots;
export const PulseLoader = Pulse;
export const RippleLoader = Ripple;
export const RotationCircleLoader = RotationCircle;
export const RotationHoleLoader = RotationHole;
export const TextLoader = Text;
================================================
FILE: lib/animated/AnimatedBar.js
================================================
import Bar from '../shape/Bar';
import { Animated } from 'react-native';
export default Animated.createAnimatedComponent(Bar);
================================================
FILE: lib/animated/AnimatedCircle.js
================================================
import Circle from '../shape/Circle';
import { Animated } from 'react-native';
export default Animated.createAnimatedComponent(Circle);
================================================
FILE: lib/const/index.js
================================================
export const color = '#1e90ff';
================================================
FILE: lib/loader/BreathingLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Animated } from 'react-native';
import { Surface } from '@react-native-community/art';
import AnimatedCircle from '../animated/AnimatedCircle';
import { color } from '../const';
export default class BreathingLoader extends React.PureComponent {
static propTypes = {
color: PropTypes.string,
size: PropTypes.number,
strokeWidth: PropTypes.number,
frequency: PropTypes.number,
};
static defaultProps = {
color,
size: 30,
strokeWidth: 3,
frequency: 800,
};
constructor(props) {
super(props);
this.state = {
scale: new Animated.Value(0.1),
};
}
componentDidMount() {
this._animation();
}
componentWillUnmount() {
this.unmounted = true;
}
_animation = () => {
Animated.sequence([
Animated.timing(this.state.scale, {
toValue: 1,
duration: this.props.frequency,
useNativeDriver: false,
}),
Animated.timing(this.state.scale, {
toValue: 0.1,
duration: this.props.frequency,
useNativeDriver: false,
}),
]).start(() => {
!this.unmounted && this._animation();
});
};
render() {
const { color, size, strokeWidth } = this.props;
return (
<Surface width={size + strokeWidth} height={size + strokeWidth}>
<AnimatedCircle
radius={size}
stroke={color}
strokeWidth={strokeWidth}
scale={this.state.scale}
x={(size + strokeWidth) / 2}
y={(size + strokeWidth) / 2}
/>
</Surface>
);
}
}
================================================
FILE: lib/loader/BubblesLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Animated } from 'react-native';
import { Surface } from '@react-native-community/art';
import AnimatedCircle from '../animated/AnimatedCircle';
import { color } from '../const';
export default class BubblesLoader extends React.PureComponent {
static propTypes = {
color: PropTypes.string,
dotRadius: PropTypes.number,
size: PropTypes.number,
};
static defaultProps = {
color,
dotRadius: 10,
size: 40,
};
state = {
opacities: [
new Animated.Value(1),
new Animated.Value(1),
new Animated.Value(1),
new Animated.Value(1),
new Animated.Value(1),
new Animated.Value(1),
new Animated.Value(1),
new Animated.Value(1),
],
};
eachDegree = 360 / this.state.opacities.length;
timers = [];
componentDidMount() {
this.state.opacities.forEach((item, i) => {
const id = setTimeout(() => {
this._animation(i);
}, i * 150);
this.timers.push(id);
});
}
componentWillUnmount() {
this.unmounted = true;
this.timers.forEach((id) => {
clearTimeout(id);
});
}
_animation = (i) => {
Animated.sequence([
Animated.timing(this.state.opacities[i], {
toValue: 0.2,
duration: 600,
useNativeDriver: false,
}),
Animated.timing(this.state.opacities[i], {
toValue: 1,
duration: 600,
useNativeDriver: false,
}),
]).start(() => {
!this.unmounted && this._animation(i);
});
};
render() {
const { size, dotRadius, color } = this.props;
const { opacities } = this.state;
return (
<Surface width={size + dotRadius} height={size + dotRadius}>
{opacities.map((item, i) => {
let radian = (i * this.eachDegree * Math.PI) / 180;
let x = Math.round((size / 2) * Math.cos(radian)) + size / 2 + dotRadius / 2;
let y = Math.round((size / 2) * Math.sin(radian)) + size / 2 + dotRadius / 2;
return (
<AnimatedCircle
key={i}
radius={dotRadius}
fill={color}
x={x}
y={y}
scale={opacities[i]}
/>
);
})}
</Surface>
);
}
}
================================================
FILE: lib/loader/CirclesLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Animated } from 'react-native';
import { Surface } from '@react-native-community/art';
import AnimatedCircle from '../animated/AnimatedCircle';
import { color } from '../const';
export default class CirclesLoader extends React.PureComponent {
static propTypes = {
color: PropTypes.string,
dotRadius: PropTypes.number,
size: PropTypes.number,
};
static defaultProps = {
color,
dotRadius: 8,
size: 40,
};
state = {
opacities: [
new Animated.Value(1),
new Animated.Value(1),
new Animated.Value(1),
new Animated.Value(1),
new Animated.Value(1),
new Animated.Value(1),
new Animated.Value(1),
new Animated.Value(1),
],
};
eachDegree = 360 / this.state.opacities.length;
timers = [];
componentDidMount() {
this.state.opacities.forEach((item, i) => {
const id = setTimeout(() => {
this._animation(i);
}, i * 150);
this.timers.push(id);
});
}
componentWillUnmount() {
this.unmounted = true;
this.timers.forEach((id) => {
clearTimeout(id);
});
}
_animation = (i) => {
Animated.sequence([
Animated.timing(this.state.opacities[i], {
toValue: 0.1,
duration: 600,
useNativeDriver: false,
}),
Animated.timing(this.state.opacities[i], {
toValue: 1,
duration: 600,
useNativeDriver: false,
}),
]).start(() => {
!this.unmounted && this._animation(i);
});
};
render() {
const { size, dotRadius, color } = this.props;
const { opacities } = this.state;
return (
<Surface width={size + dotRadius} height={size + dotRadius}>
{opacities.map((item, i) => {
let radian = (i * this.eachDegree * Math.PI) / 180;
let x = Math.round((size / 2) * Math.cos(radian)) + size / 2 + dotRadius / 2;
let y = Math.round((size / 2) * Math.sin(radian)) + size / 2 + dotRadius / 2;
return (
<AnimatedCircle
key={i}
radius={dotRadius}
fill={color}
x={x}
y={y}
opacity={opacities[i]}
/>
);
})}
</Surface>
);
}
}
================================================
FILE: lib/loader/CirclesRotationScaleLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Animated, Easing } from 'react-native';
import { Surface, Group } from '@react-native-community/art';
import AnimatedCircle from '../animated/AnimatedCircle';
import { color } from '../const';
export default class RotationCircleLoader extends React.PureComponent {
static propTypes = {
size: PropTypes.number,
color: PropTypes.string,
};
static defaultProps = {
size: 50,
color,
};
state = {
degree: new Animated.Value(0),
scales: [new Animated.Value(0), new Animated.Value(0)]
};
timers = [];
componentDidMount() {
this._animation();
this.state.scales.forEach((item, i) => {
const id = setTimeout(() => {
this._animationCircles(i)
}, i * 500);
this.timers.push(id);
});
}
componentWillUnmount() {
this.unmounted = true;
this.timers.forEach((id) => {
clearTimeout(id);
});
}
_animation = () => {
Animated.sequence([
Animated.timing(this.state.degree, {
toValue: 360,
duration: 2000,
easing: Easing.linear,
useNativeDriver: false
})
]).start(() => {
if (!this.unmounted) {
this.state.degree.setValue(0);
this._animation();
}
});
};
_animationCircles = (i) => {
Animated.sequence([
Animated.timing(this.state.scales[i], { toValue: 1, duration: 1000, useNativeDriver: false }),
Animated.timing(this.state.scales[i], {
toValue: 0.05,
duration: 1000,
useNativeDriver: false
}),
]).start(() => {
!this.unmounted && this._animationCircles(i);
});
};
render() {
const { size, color } = this.props;
const degree = this.state.degree.interpolate({
inputRange: [0, 360],
outputRange: ['0deg', '360deg']
});
return (
<Animated.View
style={{
transform: [{ rotate: degree }],
backgroundColor: 'rgba(0,0,0,0)',
width: size,
height: size
}}>
<Surface width={size} height={size}>
<Group>
<AnimatedCircle
fill={color}
radius={size / 2}
x={size / 2}
y={size / 4}
scale={this.state.scales[0]}
/>
<AnimatedCircle
fill={color}
radius={size / 2}
x={size / 2}
y={size / 4 * 3}
scale={this.state.scales[1]}
/>
</Group>
</Surface>
</Animated.View>
);
}
}
================================================
FILE: lib/loader/ColorDotsLoader.js
================================================
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Animated, Easing } from 'react-native';
import { Surface, Group } from '@react-native-community/art';
import AnimatedCircle from '../animated/AnimatedCircle';
export default class ColorDotsLoader extends Component {
static propTypes = {
size: PropTypes.number,
betweenSpace: PropTypes.number,
color1: PropTypes.string,
color2: PropTypes.string,
color3: PropTypes.string,
};
static defaultProps = {
size: 15,
betweenSpace: 7,
color1: '#ff4500',
color2: '#ffd700',
color3: '#9acd32',
};
constructor(props) {
super(props);
const red = this.props.color1;
const yellow = this.props.color2;
const green = this.props.color3;
this.state = {
colors: [red, red, red],
color: yellow,
x: new Animated.Value(-this.props.size / 2),
};
this.patterns = [
[yellow, red, red],
[yellow, yellow, red],
[yellow, yellow, yellow],
[green, yellow, yellow],
[green, green, yellow],
[green, green, green],
[red, green, green],
[red, red, green],
[red, red, red],
];
this.timers = [];
}
componentDidMount() {
this._animation();
}
componentWillUnmount() {
this.unmounted = true;
this.timers.forEach((id) => {
clearTimeout(id);
});
}
_animation = () => {
const { size, betweenSpace, color1, color2, color3 } = this.props;
const id1 = setTimeout(() => {
this.setState({ color: color3 });
}, 600);
const id2 = setTimeout(() => {
this.setState({ color: color1 });
}, 1200);
this.timers.push(id1);
this.timers.push(id2);
this.patterns.forEach((item, i) => {
const id = setTimeout(() => {
this.setState({ colors: this.patterns[i] });
}, i * 200 + 100);
this.timers.push(id);
});
Animated.sequence([
Animated.timing(this.state.x, {
toValue: size * 3 + betweenSpace * 2 + size / 2,
duration: 600,
easing: Easing.linear,
useNativeDriver: false,
}),
Animated.timing(this.state.x, {
toValue: -size / 2,
duration: 0,
useNativeDriver: false,
}),
Animated.timing(this.state.x, {
toValue: size * 3 + betweenSpace * 2 + size / 2,
duration: 600,
easing: Easing.linear,
useNativeDriver: false,
}),
Animated.timing(this.state.x, {
toValue: -size / 2,
duration: 0,
useNativeDriver: false,
}),
Animated.timing(this.state.x, {
toValue: size * 3 + betweenSpace * 2 + size / 2,
duration: 600,
easing: Easing.linear,
useNativeDriver: false,
}),
]).start(() => {
if (!this.unmounted) {
this.state.x.setValue(-size / 2);
this.setState({ color: color2 });
this._animation();
}
});
};
render() {
const { size, betweenSpace } = this.props;
const { color, colors } = this.state;
return (
<Surface width={size * 3 + betweenSpace * 2} height={size}>
<Group>
{colors.map((item, i) => (
<AnimatedCircle
key={i}
fill={item}
radius={size}
x={size / 2 + i * (size + betweenSpace)}
y={size / 2}
/>
))}
<AnimatedCircle fill={color} radius={size} x={this.state.x} y={size / 2} />
</Group>
</Surface>
);
}
}
================================================
FILE: lib/loader/DotsLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Animated } from 'react-native';
import { Surface } from '@react-native-community/art';
import AnimatedCircle from '../animated/AnimatedCircle';
import { color } from '../const';
export default class DotsLoader extends React.PureComponent {
static propTypes = {
color: PropTypes.string,
size: PropTypes.number,
betweenSpace: PropTypes.number,
};
static defaultProps = {
color,
size: 10,
betweenSpace: 5,
};
state = {
scales: [new Animated.Value(0), new Animated.Value(0), new Animated.Value(0)],
};
componentDidMount() {
this._animation();
}
componentWillUnmount() {
this.unmounted = true;
}
_animation = () => {
function seq(self, i) {
return Animated.sequence([
Animated.timing(self.state.scales[i], {
toValue: 1,
duration: 300,
delay: (i + 1) * 200,
useNativeDriver: false,
}),
Animated.timing(self.state.scales[i], {
toValue: 0,
duration: 300,
delay: 50,
useNativeDriver: false,
}),
]);
}
Animated.parallel([seq(this, 0), seq(this, 1), seq(this, 2)]).start(() => {
if (!this.unmounted) this._animation();
});
};
_renderCircle = (i) => {
const { color, size, betweenSpace } = this.props;
return (
<AnimatedCircle
radius={size}
fill={color}
x={size / 2 + i * (size + betweenSpace)}
y={size / 2}
scale={this.state.scales[i]}
/>
);
};
render() {
const { size, betweenSpace } = this.props;
return (
<Surface width={size * 3 + betweenSpace * 2} height={size}>
{this._renderCircle(0)}
{this._renderCircle(1)}
{this._renderCircle(2)}
</Surface>
);
}
}
================================================
FILE: lib/loader/DoubleCircleLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Animated } from 'react-native';
import { Surface } from '@react-native-community/art';
import AnimatedCircle from '../animated/AnimatedCircle';
import { color } from '../const';
export default class DoubleCircleLoader extends React.PureComponent {
static propTypes = {
color: PropTypes.string,
size: PropTypes.number,
};
static defaultProps = {
color,
size: 30,
};
state = {
scales: [new Animated.Value(0), new Animated.Value(0)],
};
timers = [];
componentDidMount() {
this.state.scales.forEach((item, i) => {
const id = setTimeout(() => {
this._animation(i);
}, i * 1000);
this.timers.push(id);
});
}
componentWillUnmount() {
this.unmounted = true;
this.timers.forEach((id) => {
clearTimeout(id);
});
}
_animation = (i) => {
Animated.sequence([
Animated.timing(this.state.scales[i], { toValue: 1, duration: 1000, useNativeDriver: false }),
Animated.timing(this.state.scales[i], { toValue: 0, duration: 1000, useNativeDriver: false }),
]).start(() => {
!this.unmounted && this._animation(i);
});
};
render() {
const { color, size } = this.props;
const { scales } = this.state;
return (
<Surface width={size} height={size}>
<AnimatedCircle
radius={size}
fill={color}
opacity={0.5}
scale={scales[0]}
x={size / 2}
y={size / 2}
/>
<AnimatedCircle
radius={size}
fill={color}
opacity={0.5}
scale={scales[1]}
x={size / 2}
y={size / 2}
/>
</Surface>
);
}
}
================================================
FILE: lib/loader/EatBeanLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Animated } from 'react-native';
import { Surface, Shape } from '@react-native-community/art';
import AnimatedCircle from '../animated/AnimatedCircle';
import { color } from '../const';
export default class EatBeanLoader extends React.PureComponent {
static propTypes = {
size: PropTypes.number,
color: PropTypes.string,
};
static defaultProps = {
size: 30,
color,
};
state = {
dotsY: [
new Animated.Value(this.props.size * 2.2),
new Animated.Value(this.props.size * 2.2),
new Animated.Value(this.props.size * 2.2),
new Animated.Value(this.props.size * 2.2),
],
};
timers = [];
componentDidMount() {
this.state.dotsY.forEach((item, i) => {
const id = setTimeout(() => {
this._animation(i);
}, i * 300);
this.timers.push(id);
});
}
componentWillUnmount() {
this.unmounted = true;
this.timers.forEach((id) => {
clearTimeout(id);
});
}
_animation = (i) => {
Animated.timing(this.state.dotsY[i], {
toValue: this.props.size / 2,
duration: 1200,
useNativeDriver: false,
}).start(() => {
if (!this.unmounted) {
this.state.dotsY[i].setValue(this.props.size * 2.2);
this._animation(i);
}
});
};
render() {
const { size, color } = this.props;
const sinValue = Math.sqrt(2) / 2;
const x = Math.floor((size / 2) * sinValue) + size / 2;
const startY = Math.floor((size / 2) * sinValue) + size / 2;
const endY = size / 2 - Math.floor((size / 2) * sinValue);
const d = `M${x} ${startY} A ${size / 2} ${size / 2}, 0, 1, 1, ${x} ${endY} L ${size /
2} ${size / 2} Z`;
return (
<Surface width={size * 2} height={size}>
<Shape d={d} fill={color} x={size / 5} />
{this.state.dotsY.map((item, i) => (
<AnimatedCircle key={i} radius={size / 5} fill={color} x={item} y={size / 2} />
))}
</Surface>
);
}
}
================================================
FILE: lib/loader/LineDotsLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Animated, Dimensions } from 'react-native';
import { Surface } from '@react-native-community/art';
import AnimatedCircle from '../animated/AnimatedCircle';
import { color } from '../const';
export default class LineDotsLoader extends React.PureComponent {
static propTypes = {
color: PropTypes.string,
size: PropTypes.number,
dotsNumber: PropTypes.number,
betweenSpace: PropTypes.number,
};
static defaultProps = {
color,
size: 10,
dotsNumber: 5,
betweenSpace: 5,
};
constructor(props) {
super(props);
this.screenWidth = Dimensions.get('window').width;
const { size, dotsNumber, betweenSpace } = this.props;
const midX =
this.screenWidth / 2 + (size * dotsNumber + betweenSpace * (dotsNumber - 1)) / 2 - size / 2;
let circlesX = [];
this.beginX = [];
this.centerX = [];
this.destX = [];
for (let i = 0; i < dotsNumber; i++) {
let beginX = -size / 2 - (size + betweenSpace) * i;
circlesX.push(new Animated.Value(beginX));
this.beginX.push(beginX);
this.centerX.push(midX - i * (size + betweenSpace));
this.destX.push(this.screenWidth + size / 2 + i * (size + betweenSpace));
}
this.state = {
x: circlesX,
};
}
render() {
const { color, size } = this.props;
return (
<Surface width={this.screenWidth} height={size}>
{this.state.x.map((item, i) => (
<AnimatedCircle key={i} radius={size} fill={color} x={item} y={size / 2} />
))}
</Surface>
);
}
componentDidMount() {
this._animation();
}
componentWillUnmount() {
this.unmounted = true;
}
_animation = () => {
this.state.x.forEach((item, i) => {
Animated.sequence([
Animated.timing(this.state.x[i], {
toValue: this.centerX[i],
duration: 600,
delay: i * 50,
useNativeDriver: false,
}),
Animated.timing(this.state.x[i], {
toValue: this.centerX[i],
duration: 600,
delay: 300,
useNativeDriver: false,
}),
Animated.timing(this.state.x[i], {
toValue: this.destX[i],
duration: 600,
delay: i * 50,
useNativeDriver: false,
}),
]).start(() => {
if (i === this.props.dotsNumber - 1) {
for (let idx in this.state.x) {
this.state.x[idx].setValue(this.beginX[idx]);
}
!this.unmounted && this._animation();
}
});
});
};
}
================================================
FILE: lib/loader/LinesLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Animated } from 'react-native';
import { Surface } from '@react-native-community/art';
import AnimatedBar from '../animated/AnimatedBar';
import { color } from '../const';
export default class LinesLoader extends React.PureComponent {
static propTypes = {
color: PropTypes.string,
barWidth: PropTypes.number,
barHeight: PropTypes.number,
betweenSpace: PropTypes.number,
barNumber: PropTypes.number,
};
static defaultProps = {
color,
betweenSpace: 2,
barNumber: 5,
barWidth: 5,
barHeight: 40,
};
constructor(props) {
super(props);
const heights = [];
for (let i = 0; i < this.props.barNumber; i++) {
heights.push(new Animated.Value(this.props.barHeight / 3));
}
this.state = {
heights,
};
}
componentDidMount() {
this._animation();
}
componentWillUnmount() {
this.unmounted = true;
}
_animation = () => {
function seq(self, i) {
return Animated.sequence([
Animated.timing(self.state.heights[i], {
toValue: self.props.barHeight,
duration: 400,
delay: i * 200,
useNativeDriver: false,
}),
Animated.timing(self.state.heights[i], {
toValue: self.props.barHeight / 3,
duration: 400,
useNativeDriver: false,
}),
]);
}
const anim = [];
for (let i = 0; i < this.props.barNumber; i++) anim.push(seq(this, i));
Animated.parallel(anim).start(() => {
!this.unmounted && this._animation();
});
};
render() {
const { color, betweenSpace, barWidth, barHeight, barNumber } = this.props;
return (
<Surface width={barWidth * barNumber + betweenSpace * (barNumber - 1)} height={barHeight}>
{this.state.heights.map((item, i) => (
<AnimatedBar
key={i}
fill={color}
width={barWidth}
height={this.state.heights[i]}
x={i * (betweenSpace + barWidth)}
y={barHeight / 2}
/>
))}
</Surface>
);
}
}
================================================
FILE: lib/loader/MusicLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Animated } from 'react-native';
import { Surface } from '@react-native-community/art';
import Bar from '../shape/Bar2';
import { color } from '../const';
const AnimatedBar = Animated.createAnimatedComponent(Bar);
export default class LinesLoader extends React.PureComponent {
static propTypes = {
color: PropTypes.string,
barWidth: PropTypes.number,
barHeight: PropTypes.number,
betweenSpace: PropTypes.number,
};
static defaultProps = {
color,
betweenSpace: 5,
barWidth: 3,
barHeight: 30,
};
constructor(props) {
super(props);
this.fixedMaxValue = [
this.props.barHeight * 0.8,
this.props.barHeight * 0.4,
this.props.barHeight,
this.props.barHeight * 0.2,
];
this.fixedMinValue = [
this.props.barHeight * 0.3,
this.props.barHeight,
this.props.barHeight * 0.5,
this.props.barHeight * 0.8,
];
this.state = {
heights: [
new Animated.Value(this.fixedMinValue[0]),
new Animated.Value(this.fixedMinValue[1]),
new Animated.Value(this.fixedMinValue[2]),
new Animated.Value(this.fixedMinValue[3]),
],
};
}
componentDidMount() {
this.state.heights.forEach((item, i) => {
this._animation(i);
});
}
componentWillUnmount() {
this.unmounted = true;
}
_animation = (i) => {
Animated.sequence([
Animated.timing(this.state.heights[i], {
toValue: this.fixedMaxValue[i],
duration: 500,
useNativeDriver: false,
}),
Animated.timing(this.state.heights[i], {
toValue: this.fixedMinValue[i],
duration: 500,
useNativeDriver: false,
}),
]).start(() => {
!this.unmounted && this._animation(i);
});
};
render() {
const { color, betweenSpace, barWidth, barHeight, barNumber } = this.props;
return (
<Surface width={barWidth * 4 + betweenSpace * 3} height={barHeight}>
{this.state.heights.map((item, i) => {
return (
<AnimatedBar
key={i}
fill={color}
width={barWidth}
height={this.state.heights[i]}
x={i * (betweenSpace + barWidth)}
y={barHeight}
/>
);
})}
</Surface>
);
}
}
================================================
FILE: lib/loader/NineCubesLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Animated } from 'react-native';
import { Surface } from '@react-native-community/art';
import Bar3 from '../shape/Bar3';
import { color } from '../const';
const AnimatedBar = Animated.createAnimatedComponent(Bar3);
export default class NineCubesLoader extends React.PureComponent {
state = {
scales: [
new Animated.Value(0),
new Animated.Value(0),
new Animated.Value(0),
new Animated.Value(0),
new Animated.Value(0),
],
};
static propTypes = {
size: PropTypes.number,
color: PropTypes.string,
};
static defaultProps = {
size: 20,
color,
};
_renderCube(i, j, scaleID) {
const { size, color } = this.props;
return (
<AnimatedBar
fill={color}
width={size}
height={size}
x={(size / 2) * (i * 2 + 1)}
y={(size / 2) * (j * 2 + 1)}
scale={this.state.scales[scaleID]}
/>
);
}
render() {
const { size, color } = this.props;
return (
<Surface width={size * 3} height={size * 3}>
{this._renderCube(0, 0, 2)}
{this._renderCube(0, 1, 1)}
{this._renderCube(0, 2, 0)}
{this._renderCube(1, 0, 3)}
{this._renderCube(1, 1, 2)}
{this._renderCube(1, 2, 1)}
{this._renderCube(2, 0, 4)}
{this._renderCube(2, 1, 3)}
{this._renderCube(2, 2, 2)}
</Surface>
);
}
componentDidMount() {
this._animation();
}
componentWillUnmount() {
this.unmounted = true;
}
_animation = () => {
function seq(self, i) {
return Animated.sequence([
Animated.timing(self.state.scales[i], {
toValue: 1,
duration: 300,
delay: (i + 1) * 100,
useNativeDriver: false,
}),
Animated.timing(self.state.scales[i], {
toValue: 0,
duration: 300,
delay: 200,
useNativeDriver: false,
}),
]);
}
Animated.parallel([seq(this, 0), seq(this, 1), seq(this, 2), seq(this, 3), seq(this, 4)]).start(
() => {
!this.unmounted && this._animation();
},
);
};
}
================================================
FILE: lib/loader/OpacityDotsLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Animated } from 'react-native';
import { Surface } from '@react-native-community/art';
import AnimatedCircle from '../animated/AnimatedCircle';
import { color } from '../const';
export default class OpacityDotsLoader extends React.PureComponent {
static propTypes = {
color: PropTypes.string,
size: PropTypes.number,
betweenSpace: PropTypes.number,
speed: PropTypes.number,
};
static defaultProps = {
color,
size: 10,
betweenSpace: 5,
speed: 200,
};
state = {
opacity: [new Animated.Value(0.5), new Animated.Value(0.5), new Animated.Value(0.5)],
};
_renderCircle(i) {
const { color, size, betweenSpace } = this.props;
return (
<AnimatedCircle
radius={size}
fill={color}
x={size / 2 + i * (size + betweenSpace)}
y={size / 2}
opacity={this.state.opacity[i]}
scale={1}
/>
);
}
componentDidMount() {
this._animation();
}
componentWillUnmount() {
this.unmounted = true;
}
_animation = () => {
const { speed } = this.props;
function seq(self, i) {
return Animated.sequence([
Animated.timing(self.state.opacity[i], {
toValue: 1,
duration: speed,
delay: i * speed,
useNativeDriver: false,
}),
Animated.timing(self.state.opacity[i], {
toValue: 0.3,
duration: speed,
delay: speed,
useNativeDriver: false,
}),
]);
}
Animated.parallel([seq(this, 0), seq(this, 1), seq(this, 2)]).start(() => {
!this.unmounted && this._animation();
});
};
render() {
const { size, betweenSpace } = this.props;
return (
<Surface width={size * 3 + betweenSpace * 2} height={size}>
{this._renderCircle(0)}
{this._renderCircle(1)}
{this._renderCircle(2)}
</Surface>
);
}
}
================================================
FILE: lib/loader/PulseLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Animated } from 'react-native';
import { Surface } from '@react-native-community/art';
import AnimatedCircle from '../animated/AnimatedCircle';
import { color } from '../const';
export default class PulseLoader extends React.PureComponent {
static propTypes = {
color: PropTypes.string,
size: PropTypes.number,
frequency: PropTypes.number,
};
static defaultProps = {
color,
size: 30,
frequency: 1000,
};
state = {
effect: new Animated.ValueXY({ x: 0, y: 1 }),
};
componentDidMount() {
this._animation();
}
componentWillUnmount() {
this.unmounted = true;
}
_animation = () => {
Animated.parallel([
Animated.timing(this.state.effect.x, {
toValue: 1,
duration: this.props.frequency,
useNativeDriver: false,
}),
Animated.timing(this.state.effect.y, {
toValue: 0.05,
duration: this.props.frequency,
useNativeDriver: false,
}),
]).start(() => {
if (!this.unmounted) {
this.state.effect.setValue({ x: 0, y: 1 });
this._animation();
}
});
};
render() {
const { color, size } = this.props;
return (
<Surface width={size} height={size}>
<AnimatedCircle
radius={size}
fill={color}
scale={this.state.effect.x}
opacity={this.state.effect.y}
x={size / 2}
y={size / 2}
/>
</Surface>
);
}
}
================================================
FILE: lib/loader/RippleLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Animated } from 'react-native';
import { Surface } from '@react-native-community/art';
import AnimatedCircle from '../animated/AnimatedCircle';
import { color } from '../const';
export default class RippleLoader extends React.PureComponent {
static propTypes = {
color: PropTypes.string,
size: PropTypes.number,
strokeWidth: PropTypes.number,
frequency: PropTypes.number,
};
static defaultProps = {
color,
size: 40,
strokeWidth: 3,
frequency: 1600,
};
state = {
scales: [new Animated.Value(0.1), new Animated.Value(0.1)],
opacities: [new Animated.Value(1), new Animated.Value(1)],
};
timers = [];
componentDidMount() {
this.state.scales.forEach((item, i) => {
const id = setTimeout(() => {
this._animation(i);
}, i * this.props.frequency * 0.75);
this.timers.push(id);
});
}
componentWillUnmount() {
this.unmounted = true;
this.timers.forEach((id) => {
clearTimeout(id);
});
}
_animation = (i) => {
const { frequency } = this.props;
Animated.parallel([
Animated.timing(this.state.scales[i], {
toValue: 1,
duration: frequency,
useNativeDriver: false,
}),
Animated.timing(this.state.opacities[i], {
toValue: 0,
duration: frequency,
delay: frequency / 2,
useNativeDriver: false,
}),
]).start(() => {
if (!this.unmounted) {
this.state.scales[i].setValue(0.1);
this.state.opacities[i].setValue(1);
this._animation(i);
}
});
};
render() {
const { color, size, strokeWidth } = this.props;
const { scales, opacities } = this.state;
return (
<Surface width={size + strokeWidth} height={size + strokeWidth}>
{scales.map((item, i) => (
<AnimatedCircle
key={i}
radius={size}
stroke={color}
strokeWidth={strokeWidth}
scale={scales[i]}
opacity={opacities[i]}
x={(size + strokeWidth) / 2}
y={(size + strokeWidth) / 2}
/>
))}
</Surface>
);
}
}
================================================
FILE: lib/loader/RotationCircleLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Animated, Easing } from 'react-native';
import { Surface, Group } from '@react-native-community/art';
import AnimatedCircle from '../animated/AnimatedCircle';
import { color } from '../const';
export default class RotationCircleLoader extends React.PureComponent {
static propTypes = {
size: PropTypes.number,
color: PropTypes.string,
rotationSpeed: PropTypes.number
};
static defaultProps = {
size: 40,
color,
rotationSpeed: 800
};
state = {
degree: new Animated.Value(0)
};
componentDidMount() {
this._animation();
}
componentWillUnmount() {
this.unmounted = true;
}
_animation = () => {
Animated.sequence([
Animated.timing(this.state.degree, {
toValue: 360,
duration: this.props.rotationSpeed,
easing: Easing.linear,
useNativeDriver: false
})
]).start(() => {
if (!this.unmounted) {
this.state.degree.setValue(0);
this._animation();
}
});
};
render() {
const { size, color } = this.props;
const degree = this.state.degree.interpolate({
inputRange: [0, 360],
outputRange: ['0deg', '360deg']
});
return (
<Animated.View
style={{
transform: [{ rotate: degree }],
backgroundColor: 'rgba(0,0,0,0)',
width: size,
height: size
}}>
<Surface width={size} height={size}>
<Group>
<AnimatedCircle fill={color} radius={size} x={size / 2} y={size / 2}/>
<AnimatedCircle fill="#fff" radius={size / 4} x={size / 2} y={size / 8}/>
</Group>
</Surface>
</Animated.View>
);
}
}
================================================
FILE: lib/loader/RotationHoleLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Animated, Easing } from 'react-native';
import { Surface, Group } from '@react-native-community/art';
import AnimatedCircle from '../animated/AnimatedCircle';
import { color } from '../const';
export default class RotationHoleLoader extends React.PureComponent {
static propTypes = {
size: PropTypes.number,
color: PropTypes.string,
strokeWith: PropTypes.number,
rotationSpeed: PropTypes.number
};
static defaultProps = {
size: 40,
color,
rotationSpeed: 800,
strokeWith: 8
};
state = {
degree: new Animated.Value(0)
};
componentDidMount() {
this._animation();
}
componentWillUnmount() {
this.unmounted = true;
}
_animation = () => {
Animated.sequence([
Animated.timing(this.state.degree, {
toValue: 360,
duration: this.props.rotationSpeed,
easing: Easing.linear,
useNativeDriver: false
})
]).start(() => {
if (!this.unmounted) {
this.state.degree.setValue(0);
this._animation();
}
});
};
render() {
const { size, color, strokeWith } = this.props;
const degree = this.state.degree.interpolate({
inputRange: [0, 360],
outputRange: ['0deg', '360deg']
});
return (
<Animated.View
style={{
transform: [{ rotate: degree }],
backgroundColor: 'rgba(0,0,0,0)',
width: size + strokeWith * 2,
height: size + strokeWith * 2
}}>
<Surface width={size + strokeWith * 2} height={size + strokeWith * 2}>
<Group>
<AnimatedCircle
stroke={color}
opacity={0.3}
strokeWidth={strokeWith}
radius={size}
x={size / 2 + strokeWith}
y={size / 2 + strokeWith}
/>
<AnimatedCircle
fill={color}
radius={strokeWith}
x={size / 2 + strokeWith}
y={strokeWith}
/>
</Group>
</Surface>
</Animated.View>
);
}
}
================================================
FILE: lib/loader/TextLoader.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Text, View } from 'react-native';
export default class TextLoader extends React.PureComponent {
static propTypes = {
text: PropTypes.string,
textStyle: Text.propTypes.style,
};
static defaultProps = {
text: 'Loading',
};
state = {
opacities: [0, 0, 0],
};
patterns = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [1, 1, 1]];
timers = [];
componentDidMount() {
this._animation(1);
}
componentWillUnmount() {
this.unmounted = true;
this.timers.forEach((id) => {
clearTimeout(id);
});
}
_animation = (index) => {
if (!this.unmounted) {
const id = setTimeout(() => {
this.setState({ opacities: this.patterns[index] });
index++;
if (index >= this.patterns.length) index = 0;
this._animation(index);
}, 500);
this.timers.push(id);
}
};
render() {
const { text, textStyle } = this.props;
return (
<View style={{ flexDirection: 'row' }}>
<Text style={textStyle}>{text}</Text>
{this.state.opacities.map((item, i) => (
<Text key={i} style={[{ opacity: item }, textStyle]}>
.
</Text>
))}
</View>
);
}
}
================================================
FILE: lib/shape/Bar.js
================================================
/**
* The scale center of this bar is left-center
*/
import React from 'react';
import PropTypes from 'prop-types';
import { Shape, Path } from '@react-native-community/art';
export default class Bar extends React.PureComponent {
static propTypes = {
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
};
render() {
const { width, height } = this.props;
const path = Path()
.moveTo(width, height / 2)
.lineTo(0, height / 2)
.lineTo(0, -height / 2)
.lineTo(width, -height / 2)
.close();
return <Shape {...this.props} d={path} />;
}
}
================================================
FILE: lib/shape/Bar2.js
================================================
/**
* The scale center of this bar is bottom-center
*/
import React from 'react';
import PropTypes from 'prop-types';
import { Shape, Path } from '@react-native-community/art';
export default class Bar2 extends React.PureComponent {
static propTypes = {
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
};
render() {
const { width, height } = this.props;
const path = Path()
.moveTo(0, 0)
.lineTo(0, -height)
.lineTo(width, -height)
.lineTo(width, 0)
.close();
return <Shape {...this.props} d={path} />;
}
}
================================================
FILE: lib/shape/Bar3.js
================================================
/**
* The scale center of this bar is center
*/
import React from 'react';
import PropTypes from 'prop-types';
import { Shape, Path } from '@react-native-community/art';
export default class Bar3 extends React.PureComponent {
static propTypes = {
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
};
render() {
const { width, height } = this.props;
const path = Path()
.moveTo(width / 2, height / 2)
.lineTo(-width / 2, height / 2)
.lineTo(-width / 2, -height / 2)
.lineTo(width / 2, -height / 2)
.close();
return <Shape {...this.props} d={path} />;
}
}
================================================
FILE: lib/shape/Circle.js
================================================
import React from 'react';
import PropTypes from 'prop-types';
import { Shape, Path } from '@react-native-community/art';
export default class Circle extends React.PureComponent {
static propTypes = {
radius: PropTypes.number.isRequired,
opacity: PropTypes.number,
};
render() {
const { radius } = this.props;
const path = Path()
.moveTo(0, -radius / 2)
.arc(0, radius, 1)
.arc(0, -radius, 1)
.close();
return <Shape {...this.props} d={path} />;
}
}
================================================
FILE: package.json
================================================
{
"name": "react-native-indicator",
"version": "1.2.2",
"description": "React Native Indicator Component",
"main": "index.js",
"scripts": {
"lint": "./node_modules/.bin/prettier --config .prettierrc --write lib/**/*.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/wangdicoder/react-native-indicator.git"
},
"keywords": [
"react-native",
"indicator",
"loader",
"progress"
],
"author": "Di Wang <wangdicoder@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/wangdicoder/react-native-indicator/issues"
},
"homepage": "https://github.com/wangdicoder/react-native-indicator#readme",
"dependencies": {
"prop-types": "^15.6.0"
},
"devDependencies": {
"prettier": "^1.19.1"
}
}
gitextract_oiiy0_mm/ ├── .gitignore ├── .npmignore ├── .prettierrc ├── LICENSE ├── README.md ├── index.js ├── lib/ │ ├── animated/ │ │ ├── AnimatedBar.js │ │ └── AnimatedCircle.js │ ├── const/ │ │ └── index.js │ ├── loader/ │ │ ├── BreathingLoader.js │ │ ├── BubblesLoader.js │ │ ├── CirclesLoader.js │ │ ├── CirclesRotationScaleLoader.js │ │ ├── ColorDotsLoader.js │ │ ├── DotsLoader.js │ │ ├── DoubleCircleLoader.js │ │ ├── EatBeanLoader.js │ │ ├── LineDotsLoader.js │ │ ├── LinesLoader.js │ │ ├── MusicLoader.js │ │ ├── NineCubesLoader.js │ │ ├── OpacityDotsLoader.js │ │ ├── PulseLoader.js │ │ ├── RippleLoader.js │ │ ├── RotationCircleLoader.js │ │ ├── RotationHoleLoader.js │ │ └── TextLoader.js │ └── shape/ │ ├── Bar.js │ ├── Bar2.js │ ├── Bar3.js │ └── Circle.js └── package.json
SYMBOL INDEX (91 symbols across 22 files)
FILE: lib/loader/BreathingLoader.js
class BreathingLoader (line 8) | class BreathingLoader extends React.PureComponent {
method constructor (line 23) | constructor(props) {
method componentDidMount (line 30) | componentDidMount() {
method componentWillUnmount (line 34) | componentWillUnmount() {
method render (line 55) | render() {
FILE: lib/loader/BubblesLoader.js
class BubblesLoader (line 8) | class BubblesLoader extends React.PureComponent {
method componentDidMount (line 36) | componentDidMount() {
method componentWillUnmount (line 45) | componentWillUnmount() {
method render (line 69) | render() {
FILE: lib/loader/CirclesLoader.js
class CirclesLoader (line 8) | class CirclesLoader extends React.PureComponent {
method componentDidMount (line 36) | componentDidMount() {
method componentWillUnmount (line 45) | componentWillUnmount() {
method render (line 69) | render() {
FILE: lib/loader/CirclesRotationScaleLoader.js
class RotationCircleLoader (line 8) | class RotationCircleLoader extends React.PureComponent {
method componentDidMount (line 25) | componentDidMount() {
method componentWillUnmount (line 36) | componentWillUnmount() {
method render (line 72) | render() {
FILE: lib/loader/ColorDotsLoader.js
class ColorDotsLoader (line 7) | class ColorDotsLoader extends Component {
method constructor (line 24) | constructor(props) {
method componentDidMount (line 48) | componentDidMount() {
method componentWillUnmount (line 52) | componentWillUnmount() {
method render (line 114) | render() {
FILE: lib/loader/DotsLoader.js
class DotsLoader (line 8) | class DotsLoader extends React.PureComponent {
method componentDidMount (line 25) | componentDidMount() {
method componentWillUnmount (line 29) | componentWillUnmount() {
method seq (line 34) | function seq(self, i) {
method render (line 69) | render() {
FILE: lib/loader/DoubleCircleLoader.js
class DoubleCircleLoader (line 8) | class DoubleCircleLoader extends React.PureComponent {
method componentDidMount (line 24) | componentDidMount() {
method componentWillUnmount (line 33) | componentWillUnmount() {
method render (line 49) | render() {
FILE: lib/loader/EatBeanLoader.js
class EatBeanLoader (line 8) | class EatBeanLoader extends React.PureComponent {
method componentDidMount (line 29) | componentDidMount() {
method componentWillUnmount (line 38) | componentWillUnmount() {
method render (line 58) | render() {
FILE: lib/loader/LineDotsLoader.js
class LineDotsLoader (line 8) | class LineDotsLoader extends React.PureComponent {
method constructor (line 23) | constructor(props) {
method render (line 46) | render() {
method componentDidMount (line 57) | componentDidMount() {
method componentWillUnmount (line 61) | componentWillUnmount() {
FILE: lib/loader/LinesLoader.js
class LinesLoader (line 8) | class LinesLoader extends React.PureComponent {
method constructor (line 25) | constructor(props) {
method componentDidMount (line 37) | componentDidMount() {
method componentWillUnmount (line 41) | componentWillUnmount() {
method seq (line 46) | function seq(self, i) {
method render (line 70) | render() {
FILE: lib/loader/MusicLoader.js
class LinesLoader (line 10) | class LinesLoader extends React.PureComponent {
method constructor (line 25) | constructor(props) {
method componentDidMount (line 50) | componentDidMount() {
method componentWillUnmount (line 56) | componentWillUnmount() {
method render (line 77) | render() {
FILE: lib/loader/NineCubesLoader.js
class NineCubesLoader (line 10) | class NineCubesLoader extends React.PureComponent {
method _renderCube (line 31) | _renderCube(i, j, scaleID) {
method render (line 45) | render() {
method componentDidMount (line 62) | componentDidMount() {
method componentWillUnmount (line 66) | componentWillUnmount() {
method seq (line 71) | function seq(self, i) {
FILE: lib/loader/OpacityDotsLoader.js
class OpacityDotsLoader (line 8) | class OpacityDotsLoader extends React.PureComponent {
method _renderCircle (line 27) | _renderCircle(i) {
method componentDidMount (line 41) | componentDidMount() {
method componentWillUnmount (line 45) | componentWillUnmount() {
method seq (line 52) | function seq(self, i) {
method render (line 74) | render() {
FILE: lib/loader/PulseLoader.js
class PulseLoader (line 8) | class PulseLoader extends React.PureComponent {
method componentDidMount (line 25) | componentDidMount() {
method componentWillUnmount (line 29) | componentWillUnmount() {
method render (line 53) | render() {
FILE: lib/loader/RippleLoader.js
class RippleLoader (line 8) | class RippleLoader extends React.PureComponent {
method componentDidMount (line 29) | componentDidMount() {
method componentWillUnmount (line 38) | componentWillUnmount() {
method render (line 68) | render() {
FILE: lib/loader/RotationCircleLoader.js
class RotationCircleLoader (line 8) | class RotationCircleLoader extends React.PureComponent {
method componentDidMount (line 25) | componentDidMount() {
method componentWillUnmount (line 29) | componentWillUnmount() {
method render (line 49) | render() {
FILE: lib/loader/RotationHoleLoader.js
class RotationHoleLoader (line 8) | class RotationHoleLoader extends React.PureComponent {
method componentDidMount (line 27) | componentDidMount() {
method componentWillUnmount (line 31) | componentWillUnmount() {
method render (line 51) | render() {
FILE: lib/loader/TextLoader.js
class TextLoader (line 5) | class TextLoader extends React.PureComponent {
method componentDidMount (line 21) | componentDidMount() {
method componentWillUnmount (line 25) | componentWillUnmount() {
method render (line 44) | render() {
FILE: lib/shape/Bar.js
class Bar (line 8) | class Bar extends React.PureComponent {
method render (line 14) | render() {
FILE: lib/shape/Bar2.js
class Bar2 (line 8) | class Bar2 extends React.PureComponent {
method render (line 14) | render() {
FILE: lib/shape/Bar3.js
class Bar3 (line 8) | class Bar3 extends React.PureComponent {
method render (line 14) | render() {
FILE: lib/shape/Circle.js
class Circle (line 5) | class Circle extends React.PureComponent {
method render (line 11) | render() {
Condensed preview — 32 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (56K chars).
[
{
"path": ".gitignore",
"chars": 20,
"preview": "/.idea\n/node_modules"
},
{
"path": ".npmignore",
"chars": 55,
"preview": "/screenshot\n/.idea\n/node_modules\n.prettierrc\nREADME.md\n"
},
{
"path": ".prettierrc",
"chars": 159,
"preview": "{\n \"printWidth\": 100,\n \"trailingComma\": \"all\",\n \"tabWidth\": 2,\n \"semi\": true,\n \"singleQuote\": true,\n \"bracketSpaci"
},
{
"path": "LICENSE",
"chars": 1064,
"preview": "\nMIT License\n\nCopyright (c) 2016 Di Wang\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\no"
},
{
"path": "README.md",
"chars": 7600,
"preview": "# react-native-indicator\n\n . The extraction includes 32 files (50.3 KB), approximately 14.4k tokens, and a symbol index with 91 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.