0.1.0 • Published 2 years ago

@zaradev/react-native-circular-slider v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Circular Gauge

3 types Circular Slider Component for React Native.

Support type

  • Amount: amount of the total amount
  • Percent: percentages of total amount
  • Duration: start and end in total amount

Installation

npm install --save @zaradev/react-native-circular-slider

or

yarn add @zaradev/react-native-circular-slider

Peer Dependencies

  • react-natie-reanimated(v2)
  • react-native-gesture-handler

Example

Screen Shot 2022-07-28 at 04 25 07 AM

Anatomy

The name refers to Material UI.

Screen Shot 2022-07-28 at 04 19 56 AM

Usage

const [size, setSize] = useState(200);
const [amount, setAmount] = useState(25);
const [percents, setPercents] = useState([40, 30, 20, 10]);
const [duration, setDuration] = useState({
  start: 10,
  end: 50,
});
const [clockwise, setClockwise] = useState(true);

return (
  <>
    <AmountSlider
      size={size}
      amount={amount}
      onChange={setAmount}
      clockwise={clockwise}
    />
    <PercentSlider
      percents={percents}
      size={size}
      onChange={setPercents}
      clockwise={clockwise}
    />
    <DurationSlider
      size={size}
      duration={duration}
      onChange={setDuration}
      clockwise={clockwise}
    />
  </>
);

Properties

Amount

NameDescriptionTypeRequiredDefault
amountnumber
thumbColorcolor of thumbstring#FFA500
thumbIconIcon component to be displayed in the center of the thumbReactNode
filledColorcolor of filled gaugestring#FFE5B4
onChangecalled when the amount value is changedfunction(amount: number)

Percent

NameDescriptionTypeRequiredDefault
percentsnumber[]
thumbColorcolor of thumbstring[]#FFA500
thumbIconIcon component to be displayed in the center of the thumbReactNode[]
filledColorcolor of filled gaugestring[]#FFE5B4
onChangeCalled when the percents value is changedfunction(percents: number[])

Duration

NameDescriptionTypeRequiredDefault
duration{start: number; end: number;}
thumbColorcolor of thumbstring#FFA500
thumbIconIcon component to be displayed in the center of the thumb{start: ReactNode, end: ReactNode}
filledColorcolor of filled gaugestring#FFE5B4
onChangeCalled when the duration value is changedfunction(duration: {start: number; end: number;})

Common

NameDescriptionTypeRequiredDefault
sizesize of slidernumber
clockwiserotation directionbooleantrue

Track Options

NameDescriptionTypeRequiredDefault
widthwidth of tracknumber10% of size
colorcolor of trackstring#7F8487

Tick Mark Options

NameDescriptionTypeRequiredDefaultAmountPercentDuration
showIf you need to render Tick MarkBooleanfalse
totalmaximum value of sliderNumber100
unitTick Mark division unitNumber5
colorcolor of Tick MarkString#7F8487
lengthlegnth of Tick MarkNumber10
thicknessthickness of Tick MarkBoolean2
showTextIf you need to render Tick Mark unitsStringshow option value
textSizesize of textNumber10
textColorcolor of textNumber#191919

Reference

YouTuber William Candillon's "can-it-be-done-in-react-native" lecture was very helpful.

License

MIT

0.1.0

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago