Code Monkey home page Code Monkey logo

react-native-progress's Introduction

react-native-progress

Progress indicators and spinners for React Native using React Native SVG.

progress-demo

Installation

$ npm install react-native-progress --save

React Native SVG based components

To use the Pie or Circle components, you need to install React Native SVG in your project.

Usage

Note: If you don't want the React Native SVG based components and it's dependencies, do a deep require instead: import ProgressBar from 'react-native-progress/Bar';.

import * as Progress from 'react-native-progress';

<Progress.Bar progress={0.3} width={200} />
<Progress.Pie progress={0.4} size={50} />
<Progress.Circle size={30} indeterminate={true} />
<Progress.CircleSnail color={['red', 'green', 'blue']} />

Properties for all progress components

Prop Description Default
animated Whether or not to animate changes to progress. true
indeterminate If set to true, the indicator will spin and progress prop will be ignored. false
indeterminateAnimationDuration Sets animation duration in milliseconds when indeterminate is set. 1000
progress Progress of whatever the indicator is indicating. A number between 0 and 1. 0
color Fill color of the indicator. rgba(0, 122, 255, 1)
unfilledColor Color of the remaining progress. None
borderWidth Width of outer border, set to 0 to remove. 1
borderColor Color of outer border. color

Progress.Bar

All of the props under Properties in addition to the following:

Prop Description Default
width Full width of the progress bar, set to null to use automatic flexbox sizing. 150
height Height of the progress bar. 6
borderRadius Rounding of corners, set to 0 to disable. 4
useNativeDriver Use native driver for the animations. false
animationConfig Config that is passed into the Animated function. { bounciness: 0 }
animationType Animation type to animate the progress, one of: decay, timing, spring. spring

Progress.Circle

All of the props under Properties in addition to the following:

Prop Description Default
size Diameter of the circle. 40
endAngle Determines the endAngle of the circle. A number between 0 and 1. The final endAngle would be the number multiplied by 2π 0.9
thickness Thickness of the inner circle. 3
showsText Whether or not to show a text representation of current progress. false
formatText(progress) A function returning a string to be displayed for the textual representation. See source
textStyle Styles for progress text, defaults to a same color as circle and fontSize proportional to size prop. None
allowFontScaling Whether or not to respect device font scale setting. true
direction Direction of the circle clockwise or counter-clockwise. clockwise
strokeCap Stroke Cap style for the circle butt, square or round. butt
fill Fill color of the inner circle. None (transparent)

Progress.Pie

All of the props under Properties in addition to the following:

Prop Description Default
size Diameter of the pie. 40

Progress.CircleSnail

Prop Description Default
animating If the circle should animate. true
hidesWhenStopped If the circle should be removed when not animating. false
size Diameter of the circle. 40
color Color of the circle, use an array of colors for rainbow effect. rgba(0, 122, 255, 1)
thickness Thickness of the circle. 3
duration Duration of animation. 1000
spinDuration Duration of spin (orbit) animation. 5000
strokeCap Stroke Cap style for the circle butt, square or round. round

Examples

Thanks

To Mandarin Drummond for giving me the NPM name.

License

MIT License. © Joel Arvidsson 2015-

react-native-progress's People

Contributors

adba avatar ajp8164 avatar aleksandrchernyavenko avatar budiadiono avatar byronhallett avatar cybercarrot avatar daniakash avatar danielwinkler avatar danleveille avatar developer239 avatar diego-antonelli avatar eslamelmeniawy avatar facuacostag avatar franksalad avatar frw avatar fstojanac avatar giladartzi avatar jastanton avatar jonkessler avatar jrichardlai avatar juan-cortes avatar mandhu avatar matinzd avatar mayconparanhos avatar mikehobi avatar nerdmed avatar oblador avatar russellsanborn avatar simek avatar tiendn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-progress's Issues

Wrong text in Circle when `animated` is true

Hello,

I have an issue where the text inside the circle is always at 0 if I don't setanimated={false}. After looking at the code, it seems like this code is responsible :

componentWillMount() {
    if (this.props.animated) {
      this.props.progress.addListener((event) => {
        this.progressValue = event.value;
        if (this.props.showsText || this.progressValue === 1) {
          this.forceUpdate();
        }
      });
    }
  }

It's never entering the listener (I put some logs), so the progressValue is always 0.

Thanks.

Android: Determinate circles disappear after screen display turned off until next update

On Android, when the screen display is turned off, any determinate circles disappear until they are next updated. For determinate circles that are static and never updated, this means they permanently disappear after the screen display is toggled.

See the gif below of the Example app for a visual, with the update timeouts slowed down a bit. Note that the circles disappear until the next timeout update; at the end, after the periodic updates are complete, the circles are permanently gone.

out

Tested on Android 7.1.1 Nexus 5X simulator, and also seen in external use on Samsung Galaxy S7 and Samsung Galaxy S7 Edge devices running Android 7+.

Any ideas on potential fixes? A hacky solution for now for external apps might be to listen for React Native AppState updates and force re-rendering of these circles when the app becomes foreground/screen is turned back on, but obviously this is sub-optimal.

Possible bug? Circle Clockwise not working

Hi good day,

I was testing out the code and I used the Progress.Circle component as per the sample code given.

Whenever I set the direction as clockwise or not set the props for direction, I will get a full circle, with no animation.

However, if i set the direction as counter-clockwise, it will work as expected.

May I know if I just came across a bug? Anyone who got the same error?

Cheers

BorderRadius issue on android

I am using Bar component and passing borderRadius value but it is setting borderRadius only of unfilled View while for filled view it is not setting .It is coming only in Android?
screen shot 2017-04-04 at 3 47 09 pm

Progress Bar is Empty

I am fetching data and getting a JSON response back that returns a number like this 7.5833 and because this progress bar can only handle 0 thru 1 I multiply my number by .1 which will return .7583300000000001

I am doing the following and it is just an empty bar with a border. This was working but not anymore.
<Progress.Bar progress={this.state.data.progress * .1} width={200} />

What could be wrong?

Pie color transparent

I'm trying to get the Pie to be transparent on the color property:
<Progress.Pie color={'rgba(255,255,255,0)'} unfilledColor={'rgba(255,255,255, 0.15)' progress={0.5} .../>

Seems like the color property can't handle complete transparency?

Progress might lead to the android.os.DeadObjectException in android

Hey there,

During I debug the react native application, I find out if the progress set there quite long, it will lead the some porblem as the follow shows. I don't have any enough technic to solve it. Can anyone help me?

W/WindowAnimator: Failed to dispatch window animation state change.
                                                 android.os.DeadObjectException
                                                     at android.os.BinderProxy.transactNative(Native Method)
                                                     at android.os.BinderProxy.transact(Binder.java:503)
                                                     at android.view.IWindow$Stub$Proxy.onAnimationStopped(IWindow.java:534)
                                                     at com.android.server.wm.WindowAnimator.updateWindowsLocked(WindowAnimator.java:286)
                                                     at com.android.server.wm.WindowAnimator.animateLocked(WindowAnimator.java:678)
                                                     at com.android.server.wm.WindowAnimator.-wrap0(WindowAnimator.java)
                                                     at com.android.server.wm.WindowAnimator$1.doFrame(WindowAnimator.java:123)
                                                     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:856)
                                                     at android.view.Choreographer.doCallbacks(Choreographer.java:670)
                                                     at android.view.Choreographer.doFrame(Choreographer.java:603)
                                                     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
                                                     at android.os.Handler.handleCallback(Handler.java:739)
                                                     at android.os.Handler.dispatchMessage(Handler.java:95)
                                                     at android.os.Looper.loop(Looper.java:148)
                                                     at android.os.HandlerThread.run(HandlerThread.java:61)
                                                     at com.android.server.ServiceThread.run(ServiceThread.java:46)

Vertical Bar

Hello
Would anyone be aware of any way to put the progress Bar vertically?
I could not find a way to do so..
Thank you!!
Fabrice

Warning: View.propTypes has been deprecated

Hey there, thanks for the lib.
I get a warning while running the debugger: Warning: View.propTypes has been deprecated and will be removed in a future version of ReactNative. Use ViewPropTypes instead. which I think is caused by these four files.

Would it be ok if I submit a PR to fix the warning? (I saw a PR about it but was closed, wondering if there was any particular reason for that)

NSInvalidArgumentException on iOS, React 0.40

Hi,
I'm getting this issue thrown. Is this occurring for anyone else?

Setup:
"react": "15.4.2",
"react-native": "^0.40.0",
"react-native-progress": "^3.2.0",

Error:

[__NSArrayI length]: unrecognized selector sent to instance 0x131a20af0
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI length]: unrecognized selector sent to instance 0x131a20af0'

Code;

- (instancetype) initWithPathString:(NSString *)d
{
    if (self = [super init]) {
        NSRegularExpression* decimalRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"(\\.\\d+)(?=\\-?\\.)" options:0 error:nil];
        _originD = d;

         // ERROR ON THE LINE BELOW //
        _d = [decimalRegularExpression stringByReplacingMatchesInString:d options:0 range:NSMakeRange(0, [d length]) withTemplate:@"$1\,"];
         // ERROR ON THE LINE ABOVE // 


        _pathRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"[a-df-z]|[\\-+]?(?:[\\d.]e[\\-+]?|[^\\s\\-+,a-z])+" options:NSRegularExpressionCaseInsensitive error:nil];
    }
    return self;
}

Complete Progress Bar when first running the app

Hi, i just used your progress Bar and it's working perfectly fine with iOS but not with Android device.
Actually, in the correspondent page it shows completed then it comes back to 0 and continue progressing. In the constructor i specified that progress= 0 .. Do you have any idea ? Thanks

Bug: two progress bars in one component

We updated our react native to version 0.44.3 and since then, we have strange problems on Android (iOS works fine).

In our component, we have a "time bar" and a "point bar".
There are two major problems:

  • we I give a default e.g. just to the time progress bar... both change accordingly to the time progress bar value...
  • With 0, the bar is completely full (0 should be empty), with a fixed value of 0.0001 it is empty...

default value 0:
27621951-3c8fd60e-5c0f-11e7-8152-28a002dbf74c

fixed value of 0.5 in the time bar:
screenshot_1498708989

Android crashed on React 0.35

Hi guys,
I have a problem with library, it is crashed after few minutes running.
This is code that I'm using:

<View style={styles.header}> <Image style={styles.mark} source={require('./res/ic_mark.png')}/> </View> <View style={styles.progressPos}> <Progress.CircleSnail size={160} indeterminate={true} colors={['#F44336', '#2196F3', '#009688']} thickness={5}/> </View>

Thanks and Best Regards!

PS: How can I get the crash log? I'm newbie with ReactNative

When does the animation for progress bar indeterminate start?

So my use case is that I present this in a loading indicator modal and I have noticed it not animating when I show/hide the loading indictor modal. To note, the modal could be displayed less than a second. The loading modal is mounted only once.

Circle with progress doesn't work on Android

When I test the following code onAndroid,

   let arr = [];
        for (var i=0; i<10; i++) {
            arr.push(<ProcessCircle
                animated
            borderWidth={0} progress={i/10}
             color="blue"
             unfilledColor="red"
             size={50}
              direction="counter-clockwise"/>);
        }

the first two works fine, but the follow seven don't draw the progress circle as expected.
img_0509

Set Progress.Bar width to 100%

Hello Joel and RNP community,

Thanks for creating and open sourcing such a helpful lib. I'm using it for all my react-native projects.

In one of those projects, I need to set the width of the progress bar to 100%. I did it by passing width={null} to progress bar. This sets the width to 100 %, but the progress animation is hindered (gif attached).

How to go about this ?

Thank you.

undefined is not an object evaluating '_reactNativeProgress2.default.Bar'

Hi,

I'm trying to use react-native-progress-image (with react-native-progress), i've add ART.xcodeproj to my libraries in xcode and link libART.a with libraries in buildphase but when i try with this exemple :

<Image 
    indicator={Progress.Bar}
    indicatorProps={{
         size: 80,
         borderWidth: 0,
         color: 'rgba(150, 150, 150, 1)',
         unfilledColor: 'rgba(200, 200, 200, 0.2)'
    }}
    source={{uri: this.props.url}} 
    style={{height: this.state.height, resizeMode: 'contain'}} 
/>

i get this error :

undefined is not an object (evaluating '_reactNativeProgress2.default.Bar')
2016-09-27 10:02:46.399 [fatal][tid:com.facebook.react.RCTExceptionsManagerQueue] Unhandled JS Exception: undefined is not an object (evaluating '_reactNativeProgress2.default.Bar')
2016-09-27 10:02:46.490 [warn][tid:com.facebook.react.JavaScript] Possible Unhandled Promise Rejection (id: 0):
undefined is not an object (evaluating '_reactNativeProgress2.default.Bar')

how can i fix that?

thank's

Progress Circle Show Text

Hello Guys,
Am I wrong or the progress circle text (current percentage) does not show when the current progress is 0?
Right now if I send progress={0} , no text at all will be shown.

No component found for view with name "ARTSurfaceView"

screen shot 2016-10-14 at 2 29 24 pm

I'm getting this screen when I try and add react-native-progress

I ran through the instructions for installation in Xcode, can't seem to get it working. Any suggestions?

My Versions:

"react": "15.3.2",
"react-native": "0.35.0",
"react-native-progress": "^3.1.0",

This is the code I'm using:

import React, { Component } from 'react'
import {
  StyleSheet,
  Text,
  View,
  TouchableOpacity,
  ActivityIndicator
} from 'react-native'
import * as Progress from 'react-native-progress'

export default class Loading extends Component {
  render() {
    return (
      <Progress.CircleSnail
        size={108}
        colors={['red', 'green', 'blue']}
        direction='clockwise'
        thickness={2}
        />
    )
  }
}

Android issue when progress is 0

There is an issue in android when progress value is 0, because of react-native issue when transform scaleX value is 0. The workaround would be to set progress to 0.001 value, it would be great if you put that in documentation.

CircleSnail causes unstable rendering component in android

Hi guys,

I am facing with rendering component problem whenever i try to add CircleSnail in some of my screens. It cause my app unstable rendering component on the screen, some component missing, unexpected behavior ... i tried to run it on debug and release, genymotion and real devices. All the results are same! I post the issue to ask for any solution. Thank in advance !

Here my code and environment

i update my code on gist

https://gist.github.com/nhuthuynh/009dee73675c1dbed41d34a86b359057

Genymotion: 2.9.0
Virtual Devices: Google Nexus 5X - 7.0.0 - API 24 - 1080x1920

Only working sometimes...

I have what I think is some really strange behavior happening.. I setup a Progress Pie and it was working wonderfully. Then it stopped appearing. Thinking I accidentally changed something, I played with every property - with no luck. Then I changed the progress pie, to a CircleSnail... voila, it was back... So I reverted back to the Pie, and it once again was working (even though according to Git, the file never changed).

Soon enough it disappeared again... Any ideas?

Cannot read property 'Surface' of undefined

Hi,

I am using RN 0.14.2 (probably why..but cannot change the version a the moment).

I get the red screen of death when launching the app saying "Cannot read property 'Surface' of undefined" from line 11:0 in Circle.js, even though I have added the .xcodeproject and linked the lib as indicated. Any help/insight is appreciate!
Thanks

Animation stops when using in footer of ListView

I love this library btw.
I have a <ListView> which loads more content when it reaches the bottom(end).


renderFooter() {
  if (noMore) return null
  return (
    <View style={{justifyContent: 'center', alignItems: 'center', height: 50}}>
      <Progress.Circle
        size={20}
        indeterminate={true}
        color={"#000"} />
    </View>
  )
}

render() {
  return (
  <ListView
    style={{flex: 1}}
    refreshControl={
      <RefreshControl
        ...
      />
    }
    onEndReached={this.loadMore.bind(this)}
    onEndReachedThreshold={10}
    scrollEventThrottle={150}
    dataSource={new ListView.DataSource({ rowHasChanged: (row1, row2) => row1 !== row2 }).cloneWithRows(articles)}
    ...     
    renderFooter={this.renderFooter.bind(this)} />
  )
}

When it reaches the bottom, the animation on it stops or goes to a crawl.
I've tested this on an iPhone 5S, iPhone 7 simulator, and Nexus 6P.

android 系统不支持 overflow

android 系统不支持 overflow 。
height borderRadius 设大点的值是 在android手机上会有显示问题

eg:
<Progress.Bar progress={0.3} width={200} borderRadius={20} height={40}/>

color: array *wish*

Would love to see possibility to add a color array for e.g. Progress.Circle as the Progress.CircleSnail

Import issue with react-native-progress after import statment

I am getting the following error:

/node_modules/react-native-progress/index.js: 'import' and 'export' may only appear at the top level (2:0)

I am using ES6 in my REACT component that I am developing. I have done the following import statement that is causing the error:

import * as Progress from 'react-native-progress';

Please let me know what I can do to resolve this issue.

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.