0.2.1 • Published 4 years ago

react-native-radio-trimmer v0.2.1

Weekly downloads
4
License
ISC
Repository
github
Last release
4 years ago

React Native Radio Trimmer

Installation

package installation

yarn add react-native-radio-trimmer

or

npm install react-native-radio-trimmer

install dependencies

you need to install additional libs in your project locally

yarn add react-native-svg@9.13.3
yarn add react-native-safe-area-view@0.14.8

install pods in your project folder

cd ios && pod install && cd ../

Working examples

ticksColor

ticksCount

dotColor

ticksCountHover

ticksLength

ticksWidth

dotIsShadow

pathColor

Usage

It is necessary to use onMount method, otherwise app will crash

import React, { Component } from 'react';
import { SafeAreaView, View, Text } from 'react-native';
import RadioTrimmer from 'react-native-radio-trimmer';


export class ExampleComponent extends Component {
  constructor(props) {
    super(props);
    this.state = {
      textValue: null,
    };
  }
  setValue = value => {
    this.setState({
      textValue: value,
    });
  };

  render() {
    return (
      <SafeAreaView>
        <Header />
        <RadioTrimmer
          boxSize={150}
          marginTop={50}
          onChangeValue={this.setValue}
          onMount={this.setValue}
        >
          <View>
            <Text>{this.state.textValue}</Text>
          </View>
        </RadioTrimmer>
      </SafeAreaView>
    );
  }
}

export default ExampleComponent;

Few trimmers in one row:

   <View style={{ flexDirection: 'row' }}>
          <RadioTrimmer
            boxSize={150}
            marginTop={50}
            onChangeValue={this.setValue}
            onMount={this.setValue}
          >
            <View>
              <Text>{this.state.textValue}</Text>
            </View>
          </RadioTrimmer>
          <RadioTrimmer
            boxSize={150}
            marginTop={50}
            onChangeValue={this.setValue}
            onMount={this.setValue}
          >
            <View>
              <Text>{this.state.textValue}</Text>
            </View>
          </RadioTrimmer>

          <RadioTrimmer
            boxSize={150}
            marginTop={50}
            onChangeValue={this.setValue}
            onMount={this.setValue}
          >
            <View>
              <Text>{this.state.textValue}</Text>
            </View>
          </RadioTrimmer>
        </View>

Configuration

props:

PropertyTypeDefaultDescription
accuracynumber10accuracy of result. 10 will result with 0.1, 0.5, etc
allowTapbooleantruewhen tapped on a trimmer it changes value to the tapped place
backgroundColorstringtransparentbackground color of box with Radio Trimmer
boxSizenumber200size of box containing the Radio Trimmer
dotColorstringgraycolor of radio dot
dotIsShadowbooleanfalsemakes the dot background blurred
dotSizenumber24width and height of the dot
innerDotColorstringwhitecolor of another dot inside the radio dot
innerDotSizenumber10default inner dot size
marginTopnumber0margin that allows us to position the box fro top
maxValuenumber108maximum scope value
minValuenumber87.5minimal scope value
onChangeValuefunctionnullfunction that is invoked on every radio text change. it return value of current text. Look at example
onMountfunctionnullcallback function that sets initial value on parent component
pathColorstringlightgraycolor of the path under the radio dot
pathIsShadowbooleanfalsemakes the background of radio trimmer blurred
pathWidthnumber10width of the path under the radio dot
stepnumber0.1value that will be added to each iteriationof calculating text value
textAfterNumberstringMHzthe text that will be added to calculated text value
textBackgroundColorstringtransparentthe color under the inside calculated text
tickMarginnumber0the distance between radio path and ticks
ticksActiveColorstringblackcolor of active (hovered) tick
ticksColorstringgraycolor of inactive (unhovered) tick
ticksCountnumber25how many ticks will be generated
ticksCountHovernumber5how many ticks will be hovered when the radio dot is near
ticksLengthnumber15the height of single tick
ticksWidthnumber2the width of single tick

onChangeValue, onMount:

  setValue = value => {
    this.setState({
      textValue: value,
    });
  };

<RadioTrimmer
          boxSize={150}
          marginTop={50}
          onChangeValue={this.setValue}
          onMount={this.setValue}
        >
0.2.1

4 years ago

0.2.0

4 years ago

0.1.25

4 years ago

0.1.24

4 years ago

0.1.23

4 years ago

0.1.22

4 years ago

0.1.20

4 years ago

0.1.19

4 years ago

0.1.18

4 years ago

0.1.17

4 years ago

0.1.16

4 years ago

0.1.15

4 years ago

0.1.14

4 years ago

0.1.12

4 years ago

0.1.11

4 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago