1.0.4 • Published 12 months ago

rn-value-picker v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

rn-value-picker

React native value picker is a simple measurement's unit value picker with defined range .

Installation

Install rn-value-picker with npm

  npm install rn-value-picker

Usage

How to use ? :thinking:

import { View, Text, TouchableOpacity } from "react-native";
import React, { useState } from "react";
import ValuePicker from "rn-value-picker";

const App = () => {
  //states
  const [showPicker, setShowPicker] = useState(false);
  const [myHeight, setMyHeight] = useState("");
  //UI
  return (
    <View
      style={{
        flex: 1,
      }}
    >
      <View
        style={{
          flex: 1,
          justifyContent: "center",
          alignItems: "center",
        }}
      >
        <TouchableOpacity
          onPress={() => setShowPicker(true)}
          style={{
            height: 50,
            backgroundColor: "red",
            justifyContent: "center",
            alignItems: "center",
            width: "50%",
            borderRadius: 10,
          }}
        >
          <Text
            style={{
              color: "white",
              fontSize: 18,
              fontWeight: "bold",
            }}
          >
            App {myHeight}
          </Text>
        </TouchableOpacity>
      </View>
      {/* use here before last view end  */}
      <ValuePicker
        visible={showPicker}
        setVisibility={setShowPicker}
        Title="Your Weight"
        unit="kg"
        minValue={20}
        maxValue={150}
        setValue={setMyHeight}
      />
    </View>
  );
};

export default App;

Screenshots

screenshots

List of props that you can use :-

#PropsDescriptionRequiredExample
1visibleModal only: Boolean indicating if modal should be open.Yesstate value as true or false
2setVisibilityfor closing modalYessetVisibility={setState}
3setValuesetState in which you want to select valueYessetValue={yourState}
4unitUnit in which value measureOptional"kg","cm","m" whatever just pass as string
5TitleTitle of your modalOptionalpass as a String Title="Your Weight"
6minValueminimum value for measurementOptionaldefault 100 pass value Integer
7maxValueminimum value for measurementOptionaldefault 200 pass value Integer
8cancelButtonTexttext value if you want to change cancel textOptionaldefault "cancel" if you want to change cancelButtonText="Your String"
9cancelButtonStylestyle prop of cancel button viewOptionalcancelButtonStyle={{...your custom style}}
10cancelButtonTextStylestyle prop of cancel button textOptionalcancelButtonTextStyle={{...your custom style}}
11confirmButtonTexttext value if you want to change confirm textOptionaldefault "confirm" if you want to change confirmButtonText="Your String"
12confirmButtonStylestyle prop of confirm button viewOptionalconfirmButtonStyle={{...your custom style}}
13confirmButtonTextStylestyle prop of confirm button textOptionalconfirmButtonTextStyle={{...your custom style}}
14positionposition of modalOptional"center" and "bottom" default "center"

Authors