🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

react-native-segmented-arc

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

react-native-segmented-arc

React native progress bar

1.1.16
unpublished
latest
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

React Native Arc ProgressBar

Arc ProgressBar for React Native, works on both iOS and Android Check out our documentation below to learn how to get started.

Demo and Docs

Idea & base code adapted from https://github.com/shipt/segmented-arc-for-react-native

Example Image

example

Contents

🚀 Installation

  • Install react-native-svg library for Dependency

  • Install react-native-arc-progress-bar:

yarn add react-native-arc-progress-bar
npm install react-native-arc-progress-bar

🎉 Usage

Here is a basic example of how to use this component. It covers all the main features.

import React, { useState } from 'react';
import { View, Text, Pressable } from 'react-native';
import { ArcProgressBar } from 'react-native-arc-progress-bar';

const App = () => {
  const [showArcRanges, setShowArcRanges] = useState(false);

  const segments = [
    {
      scale: 0.25,
      filledColor: '#C70039',
      emptyColor: '#F2F3F5',
      data: { label: 'Not bad!' }
    },
    {
      scale: 0.25,
      filledColor: '#404FCD',
      emptyColor: '#F2F3F5',
      data: { label: 'Good!' }
    },
    {
      scale: 0.25,
      filledColor: '#EBD22F',
      emptyColor: '#F2F3F5',
      data: { label: 'Very Good!' }
    },
    {
      scale: 0.25,
      filledColor: '#44CD40',
      emptyColor: '#F2F3F5',
      data: { label: 'Excellent!' }
    }
  ];

  const ranges = ['10%', '20%', '30%', '40%', '50%'];

  const _handlePress = () => {
    setShowArcRanges(!showArcRanges);
  };

  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <ArcProgressBar
        segments={segments}
        fillValue={70}
        isAnimated={true}
        animationDelay={1000}
        showArcRanges={showArcRanges}
        ranges={ranges}
      >
        {data => (
          <Pressable onPress={_handlePress} style={{ alignItems: 'center' }}>
            <Text style={{ fontSize: 16, paddingTop: 16 }}>{data.lastFilledSegment.data.label}</Text>
            <Text style={{ lineHeight: 80, fontSize: 24 }}>More info</Text>
          </Pressable>
        )}
      </ArcProgressBar>
    </View>
  );
};

export default App;

📖 Props

NameTypeDefaultDescription
fillValuenumber (0-100)0Current progress value
segmentsArray of { scale: number, filledColor: string, emptyColor: string, data: object }[]Segments of the arc. Here, scale is a percentage value out of 100%, filledColor for filled part of a segment, and emptyColor is background color for an empty segment, data could be any object that you'd want to receive back for a segment. See example above.
filledArcWidthnumber8Thickness of progress line
emptyArcWidthnumber8Thickness of background line
spaceBetweenSegmentsnumber2Space between segments
arcDegreenumber180Degree of arc
radiusnumber100Arc radius
isAnimatedbooltrueEnable/disable progress animation
animationDurationnumber1000Progress animation duration
animationDelaynumber0Progress animation delay
rangesArray of strings[]Arc ranges (segments) display values
rangesTextColorstring'#000000'Color of ranges text
rangesTextStyleobject{ fontSize: 12 }Ranges text styling
showArcRangesboolfalseShow/hide arc ranges
middleContentContainerStyleobject{}Extra styling for the middle content container
capInnerColorstring'#28E037'Cap's inner color
capOuterColorstring'#FFFFFF'Cap's outer color
childrenfunctionPass a function as a child. It receives metaData with the last filled segment's data as an argument. From there you can extract data object. See example above.

📄 License

MIT

Keywords

react

FAQs

Package last updated on 09 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts