Socket
Book a DemoInstallSign in
Socket

@aguycalled/react-native-segmented-round-display

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aguycalled/react-native-segmented-round-display

react-native-segmented-round-display provides a simple ARC component, drawn with react-native-svg, it can have one or more segments and its easy configurable.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

react-native-segmented-round-display

Version NPM STARS

react-native-segmented-round-display provides a simple ARC component, drawn with react-native-svg, it can have one or more segments and its easy configurable.

Example

Features

  • One segment
  • Multiple segments
  • Fill animation
  • Control of fill animation duration
  • Animated tag with value
  • Custom value formater
  • Configurable colors
  • Configurable ARC radius and total size in degrees
  • Configurable space between arc segments
  • React Web version

Installation

first

This package uses react-native-svg to draw SVG`s, so please install it following this installation manual.

then

yarn add react-native-segmented-round-display

or

npm install react-native-segmented-round-display --save

Usage

Here's a simple example. To render output like this:

Usage example ios Usage example android

import React from 'react';
import {SafeAreaView, ScrollView, StatusBar} from 'react-native';

import SegmentedRoundDisplay from 'react-native-segmented-round-display';

const App = () => {
  const examples = [
    {
      displayValue: true,
      formatValue: (value) => `R$ ${value.toFixed(2)}`,
      segments: [
        {
          total: 80,
          filled: 40,
        },
      ],
    },
    {
      displayValue: true,
      formatValue: (value) => `R$ ${value.toFixed(2)}`,
      segments: [
        {
          total: 80,
          filled: 80,
        },
        {
          total: 30,
          filled: 15,
        },
      ],
    },
    {
      displayValue: true,
      formatValue: (value) => `R$ ${value.toFixed(2)}`,
      segments: [
        {
          total: 80,
          filled: 80,
        },
        {
          total: 30,
          filled: 30,
        },
        {
          total: 100,
          filled: 40,
        },
      ],
    }
  ];

  return (
    <>
      <StatusBar barStyle="dark-content" />
      <SafeAreaView>
        <ScrollView contentInsetAdjustmentBehavior="automatic">
          {examples.map((example, i) => (
            <SegmentedRoundDisplay key={i} {...example} />
          ))}
        </ScrollView>
      </SafeAreaView>
    </>
  );
};

export default App;

Common props

NameTypeDefaultDescription
segmentsArray of { total: int, filled: int }[]segments to be rendered
filledArcWidthint7thickness of filled arc
emptyArcWidthint7thickness of empty arc
arcSpacingint7space between segments
totalArcSizeint280total arc size in degrees
radiusint150radius of the arc
emptyArcColorstring#ADB1CCcolor of empty arc
filledArcColorstring#5ECCAAcolor of filled arc
incompleteArcColorstring#23318Ccolor of incomplete arc
animatedbooltrueenable/disable segments fill animation
animationDurationint1000duration of fill animation in MS
displayValueboolfalseenable/disable the value display
formatValuefunction{}function to formar the value
valueBoxColorstring#23318Ccolor of box that holds the value if displayValue = true
valueFontColorstring#FFFFFFcolor of text of value if displayValue = true
stylesStyles object{}styles to be applied to container

Run example

git clone https://github.com/ricardovcorrea/react-native-segmented-round-display.git
cd react-native-segmented-round-display/example
yarn

cd ios && pod install
cd .. 

yarn start
react-native run-ios

Contributors

Ricardo Vaz Corrêa

Keywords

react

FAQs

Package last updated on 14 Jan 2022

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