react-native-number-picker-library

A Native number picker for both Android & iOS


Keywords
react-native, android, ios, picker
License
MIT
Install
npm install react-native-number-picker-library@1.0.8

Documentation

react-native-number-picker-library

npm version dependency status

A Native number picker for both Android & iOS

Getting started

$ npm install react-native-number-picker-library --save

Mostly automatic installation

$ react-native link react-native-number-picker-library

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-number-picker-library and add RNNumberPickerLibrary.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNNumberPickerLibrary.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.reactlibrary.RNNumberPickerLibraryPackage; to the imports at the top of the file
  • Add new RNNumberPickerLibraryPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-number-picker-library'
    project(':react-native-number-picker-library').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-number-picker-library/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-number-picker-library')
    

Usage

import RNNumberPickerLibrary from 'react-native-number-picker-library';

//Method createDialog(objectForConfig, callBackForDoneClick, callbackForCancelClick)
RNNumberPickerLibrary.createDialog(
              {
                minValue: 0,
                maxValue: 100,
                selectedValue: 10,
                doneText: 'Done',                // only for Android
                doneTextColor: '#000000',        // only for Android
                cancelText: 'Cancel',            // only for Android
                cancelTextColor: '#000000'       // only for Android
              },
              (error, data) => {
                if (error) {
                  console.error(error);
                } else {
                  console.log(events);
                }
              },
              (error, data) => {
                if (error) {
                  console.error(error);
                } else {
                  console.log(events);
                }
              }
            );