0.1.0 • Published 2 years ago

react-native-semicircle-slider-color-picker v0.1.0

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

react-native-semicircle-slider-color-picker

This component is actually a semi circle slider but it is designed in this way that you can use it as color picker too.

Install

npm i react-native-semicircle-slider-color-picker

Usage

import React, { useState } from 'react';
import {
  SafeAreaView,
  Text, 
  StyleSheet,
} from 'react-native';
import ColorPickerSlider from 'react-native-semicircle-slider-color-picker';

const App = () => {

  const [colorValue, setColorValue] = useState<number>()
  const [color, setColor] = useState()

  const colorChanged = (value: number) => {
    //console.log('here is value', value)
    setColorValue(value)
  };

  return (
    <SafeAreaView style={styles.mainContainer}>
      <ColorPickerSlider
            thumbColor={color?.hexColor?? 'grey'}
            trackStrokeWidth={20}
            gestureDisabled={false}
            trackRadius={150}
            circleType={"Top"}
            value={colorValue}
            onValueChange={value => colorChanged(value)}
            onChangeColor={color => setColor(color)}
          />
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  mainContainer: {
    width: '100%', 
    height: '100%', 
    alignItems: 'center',
    justifyContent: 'center'
  }
});

export default App;

Props

PropTypeOptionalDefaultDescription
valuenumberYes0Initial value of the slider
gestureDisabledboolYesfalseIf true the user won't be able to move the slider
minimumValuenumberYes0Initial minimum value of the slider
maximumValuenumberYes1Initial maximum value of the slider
trackStrokeWidthnumberYes22This is the width of slider
trackRadiusnumberYes150This is the Radius of Circular Slider
thumbRadiusnumberYes15This is the Size of Thumb
thumbColorstringYes#fffThis is the Color of Thumb
onValueChangeCallbackYesnoneOnChange Handler which returns current slider value
onChangeColorCallbackYesnoneThis callback returns color on change of slider
circleTypestringYesTopRequired property to draw bottom or top circle (use "Bottom" for bottom circle and "Top" for top circle)
paddingVerticalnumberYes20This is the vertical padding
linearGradientanyYeslinearGradient arrayGradient to fill in the half circle
paddingVerticalnumberYes20This is the vertical padding
brightnessnumberYes100This is the brightness of color, you can also set the brightness based on different slider of brightness.

MIT Licensed