1.0.3 • Published 6 years ago

react-native-circle-size-selector v1.0.3

Weekly downloads
7
License
MIT
Repository
github
Last release
6 years ago

react-native-circle-size-selector

React Native component to select number (size) with circle dragging (100% Pure JS)

Preview

----
npm.ionpm.io

install

npm install --save react-native-circle-size-selector

Basic Usage

import CircleSizeSelector from 'react-native-circle-size-selector'

export default class App extends Component {
  state = {
    value: 3,
  }

  onChange = (value) => {
    this.setState({ value })
  }

  render () {
    return (
      <View style={styles.container}>
        <CircleSizeSelector
          minValue={1}
          maxValue={7}
          initialValue={3}
          onChange={this.onChange}
        />
      </View>
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
});

Advanced Usage

Arbitrary Numbers

You can use arbitrary numbers at selectable values.

<CircleSizeSelector
  manualValues={[1, 2, 3, 5, 7, 11, 13]}
  ...
/>

Show children in the circle

You can render elements in the circle by adding children.

<CircleSizeSelector
  ...
>
  <View>
    <Text>
      {this.state.value}
    </Text>
  </View>
</CircleSizeSelector>

Properties

PropTypeDefault ValueDescription
minValuenumberThe minimum value of the range. This is required when manualValues is not set.
maxValuenumberThe maximum value of the range. This is required when manualValues is not set.
manualValuesnumberThe values that user can select. If you use this, you don't need to set minValue and maxValue.
initialValuenumberfirst value
showGraduationLinesOnResizingbooleantruea boolean that defines if we show graduation lines on resizing
onChange(value) => voidfunction called when value is changed during resizing
onSelected(value) => voidfunction called when value is selected after resizing
outermostCircleStyleStyleObj{ borderWidth: 2, borderColor: 'rgb(240, 240, 240)', backgroundColor: 'rgb(247, 247, 247)' }The style of the outermost circle
graduationLineCircleStyleStyleObj{ borderWidth: 1, borderColor: 'rgb(230, 230, 230)' }The style of graduation line circles showed on resizing
currentValueCircleStyleStyleObj{ borderWidth: 1, borderColor: 'rgb(200, 240, 240)', backgroundColor: 'rgba(201, 250, 245, 0.8)' }The style of current value circle
resizingCurrentValueCircleStyleStyleObj{ backgroundColor: 'rgba(187, 232, 227, 0.6)' }The style of current value circle on resizing

Example

Check App.js in Example folder.