react-native-progress

repository·master·Indexed 25 days ago

https://github.com/oblador/react-native-progress

A library providing progress indicators and spinners for React Native applications, including Bar, Circle, Pie, and CircleSnail components. It utilizes SVG for high-quality rendering and offers support for animated progress, indeterminate states, and customizable styling for each component type.

Tokens
1.4K
Snippets
2
Records
10
Agent score
37%

What's inside react-native-progress

  1. Reload the Example application

    master

    After modifying code in App.tsx, use the following commands to reload the application and see changes:

    • Android: Press the <kbd>R</kbd> key twice or select "Reload" from the Developer Menu (<kbd>Ctrl</kbd> + <kbd>M</kbd> on Windows/Linux or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> on macOS).
    • iOS: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in the iOS Simulator.
  2. Run the Example project

    master

    To run the included example project, you must first ensure your React Native environment is set up. Follow these steps from the root of the Example directory:

    1. Start the Metro Server

    Open a terminal and start the Metro bundler:

    # using npm
    npm start
    
    # OR using Yarn
    yarn start

    2. Start the Application

    Open a new terminal and run the command for your target platform:

    For Android:

    # using npm
    npm run android
    
    # OR using Yarn
    yarn android

    For iOS:

    # using npm
    npm run ios
    
    # OR using Yarn
    yarn ios
  3. Import and use react-native-progress components

    master

    You can import all components as a single namespace or use deep requires to avoid including SVG dependencies if you only need the Bar component.

    Standard Import (includes all components):

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

    Deep Import (avoids SVG dependencies):

    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']} />
  4. Configure Progress.Circle

    master

    The Progress.Circle component supports all common properties plus these specific props:

    PropDescriptionDefault
    sizeDiameter of the circle.40
    endAngleDetermines the endAngle of the circle. A number between 0 and 1. The final endAngle would be the number multiplied by 2π0.9
    thicknessThickness of the inner circle.3
    showsTextWhether 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
    textStyleStyles for progress text, defaults to a same color as circle and fontSize proportional to size prop.None
    allowFontScalingWhether or not to respect device font scale setting.true
    directionDirection of the circle clockwise or counter-clockwise.clockwise
    strokeCapStroke Cap style for the circle butt, square or round.butt
    fillFill color of the inner circle.None (transparent)
  5. Configure Progress.CircleSnail

    master

    The Progress.CircleSnail component supports all common properties plus:

    PropDescriptionDefault
    animatingIf the circle should animate.true
    hidesWhenStoppedIf the circle should be removed when not animating.false
    sizeDiameter of the circle.40
    colorColor of the circle, use an array of colors for rainbow effect.rgba(0, 122, 255, 1)
    thicknessThickness of the circle.3
    durationDuration of animation.1000
    spinDurationDuration of spin (orbit) animation.5000
    strokeCapStroke Cap style for the circle butt, square or round.round
  6. Configure Progress.Bar

    master

    The Progress.Bar component supports all common properties plus these specific props:

    PropDescriptionDefault
    widthFull width of the progress bar, set to null to use automatic flexbox sizing.150
    heightHeight of the progress bar.6
    borderRadiusRounding of corners, set to 0 to disable.4
    useNativeDriverUse native driver for the animations.false
    animationConfigConfig that is passed into the Animated function.{ bounciness: 0 }
    animationTypeAnimation type to animate the progress, one of: decay, timing, spring.spring
  7. Common properties for all progress components

    master

    The following props are available on all progress components (Bar, Circle, Pie, CircleSnail):

    PropDescriptionDefault
    animatedWhether or not to animate changes to progress.true
    indeterminateIf set to true, the indicator will spin and progress prop will be ignored.false
    indeterminateAnimationDurationSets animation duration in milliseconds when indeterminate is set.1000
    progressProgress of whatever the indicator is indicating. A number between 0 and 1.0
    colorFill color of the indicator.rgba(0, 122, 255, 1)
    unfilledColorColor of the remaining progress.None
    borderWidthWidth of outer border, set to 0 to remove.1
    borderColorColor of outer border.color