2.1.0 • Published 6 months ago

react-native-progress-wheel v2.1.0

Weekly downloads
1,652
License
ISC
Repository
github
Last release
6 months ago

react-native-progress-wheel

npm

React Native component for creating natively animated, circular progress wheel.

Example app

image

Installation

yarn add react-native-progress-wheel

Usage

import AnimatedProgressWheel from 'react-native-progress-wheel';

<AnimatedProgressWheel 
    size={120}
    width={20} 
    color={'yellow'}
    progress={45}
    backgroundColor={'orange'}
/>

You can define a progress value, and a value from which to animate when the component is mounted. The following example will animate from 0% to 45% at a duration of 3 seconds.

<AnimatedProgressWheel
    progress={45}
    animateFromValue={0}
    duration={3000}
/>

The progress wheel can display progess as titles in the center of the circle.

image

<AnimatedProgressWheel
        max={40}
        showProgressLabel={true}
        rotation={'-90deg'}
        labelStyle={styles.progressLabel}
        subtitle={'Questions out of 40'}
        subtitleStyle={styles.subtitle}
        {...{color, backgroundColor, size, width, duration, progress, rounded}}
      />

The progress wheel can be updated using state variables.

<AnimatedProgressWheel
    progress={this.state.sliderProgress}
/>

image

Configuration

You can configure the component using these props:

NameTypeDefault valueDescription
sizenumber200Width and height of circle
widthnumber25Thickness of the progress line
colorstringwhiteColor of the progress line
backgroundColorstringgrayColor of the background progress line
progressnumber0Angle from which the progress starts from
maxnumber100Max value for the progress wheel
rotationstring0degSet starting angle of progress
durationnumber600Duration at which to animate the progress
roundedbooleanfalseRounds edges
animateFromValuenumber-1Starting value to animate to progres when component is mounted
containerColorstringnullContainer color
delaynumber0Delay for animation
easingEasingFunctionnullEasing for animation
showProgressLabelbooleanfalseShow the progress as text in the circle
labelStyleTextStyle{}Style object for progress label
subtitlestringnullText displayed directly below progress label
subtitleStyleTextStyle{}Style object for subtitle
showPercentageSymbolbooleanfalseShow the progress as a percentage
onAnimationCompletefunctionnullCalled when animation finishes

Why use this component

This implementation is 100% base react-native, meaning you do not need to use any additional libraries such as 'react-native-svg' or 'react-native-reanimated'. This component also sets useNativeDriver: true, meaning that all animation is done smoothly on the native side.💖

This package is also SUPER-LIGHTWEIGHT.

Let's compare:

react-native-progress-wheel: Unpacked size: 8.74 kB (this library)

react-native-circular-progress: Unpacked size: 3.38 MB (other popular library)

image

FAQ

Q: Does it work in Expo? A: Yes it does.

Q: Does it support Typescript? A: From version 2.0.0 onwards, Typescript is fully supported.

Q: How can I get round edges? A: Pass rounded={true} in the components props. (v2 and up.)

Enjoy making smooth animated designs that use the native driver and DON'T require any additional dependencies. If you like this library please give it a star on GitHub! ⭐️