Catalog npm
Back to packageRELEASE DETAILS

1.0.2

npm

23mofang-react-native-picker

cross platform picker for Ios and Android

pickerreact-native
Published26 Dec 2017
Direct dependencies1
Transitive dependenciesNot calculated

README

Current package documentation

react-native-picker

travis status npm version npm license npm download npm download

Cross platform picker for IOS and Android. It is based on PickerIOS for IOS while react-native-wheel for android.

Image Image

Guide

npm install

$ npm i mkp-react-native-picker --save

Update Gradle Settings

// file: android/settings.gradle
...
include ':react-native-wheel'
project(':react-native-wheel').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-wheel/android')

Update app Gradle Build

// file: android/app/build.gradle
...

dependencies {
  ...
  compile project(':react-native-wheel')
}

Register React Package

// file: android/src/main/java/com.xx/MainApplication.java
...

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
        protected boolean getUseDeveloperSupport() {
            return BuildConfig.DEBUG;
        }

        @Override
        protected List<ReactPackage> getPackages() {
            return Arrays.<ReactPackage>asList(
                new MainReactPackage(),
                new WheelPackage()          // Added there
            );
        }
    };

Usage

import React ,{Component}from 'react';
import {
    StyleSheet,
    Text,
    View,
    TouchableOpacity,
    Platform
} from 'react-native';

import BaseComponent from './baseComponent';
import SinglePicker from 'mkp-react-native-picker';

import {viewStyles} from '../themes/default';

const options = [{
    key: 1,
    value: "Option1"
}, {
    key: 2,
    value: "Option2"
}, {
    key: 3,
    value: "Option3"
}]

const another_options = [{
    key: 1,
    value: "OptionA"
}, {
    key: 2,
    value: "OptionB"
}, {
    key: 3,
    value: "OptionC"
}];

const optionsGroup = [options, another_options]

export default class Picker extends BaseComponent {
    constructor(props) {
        super(props);
        this.state = {
            selected: ''
        }
        this.optionsGroupIndex = 0
    }

    render() {
        return <View style={viewStyles.main}>
            <TouchableOpacity
                style={{height:30,flexDirection:'row',justifyContent:'center',alignItems:'center',backgroundColor:'red'}}
                onPress={()=>{
                    this.singlePicker.show();
                }}>
                <Text style={{fontSize:18,color:'white',fontWeight:'bold'}}>Single Picker(Click Me!)</Text>
            </TouchableOpacity>

            <View style={{height:50,justifyContent:'center'}}><Text>You have
                selected {this.state.selected}</Text></View>

            <TouchableOpacity
                style={{height:30,flexDirection:'row',justifyContent:'center',alignItems:'center',backgroundColor:'red'}}
                onPress={()=>{
                    this.optionsGroupIndex = Math.abs(this.optionsGroupIndex - 1)
                    this.singlePicker.setOption(optionsGroup[this.optionsGroupIndex]);
                }}>
                <Text>Switch Options</Text>
            </TouchableOpacity>

            <SinglePicker
                lang="en-US"
                ref={ref=>this.singlePicker=ref}
                onConfirm={(option)=>{
                    //this.setState({selected:option.value})
                }}
                onSelect={(option)=>{
                    this.setState({selected:option.value})
                }}
                options={options}
            >

            </SinglePicker>
        </View>
    }
}

Documentation

Properties

KeyTypeRequiredDefaultDescription
optionsarrayyesmust be an array of key-value pairs,like {key:1,value:'option'}
langstringno'zh-CN'enums:'zh-CN','en-US','es-AR',indicate the language of the text in buttons
styleobjectno{backgroundColor: "white"}
defaultSelectedValueanynokey of each option,if undefined, the first option will be selected
onConfirmfunctionnooption that be selected as the parameter
onSelectfunctionnooption that be selected as the parameter
onCancelfunctionno

Methods

NameDescription
showshow the Picker
hidehide the Picker
setOption(options,defaultSelectedValue)change options of the Picker

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 1

Native requirements
1 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
react-native-wheel
Environment
{
  "local_name": "react-native-wheel",
  "alias": false,
  "peer_metadata": null
}
^1.1.3runtime

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "73832eabc882f1df05ef8c9968d6bd9015230438",
  "tarball": "https://registry.npmjs.org/23mofang-react-native-picker/-/23mofang-react-native-picker-1.0.2.tgz",
  "integrity": "sha512-Y5YNP1qGPoDx80t5GwCT287Zgl1jKctqlsciqtFkGlPv7bfAk88//vlnyzSrsHoB+4i3b1WzUXfu02SAbQWEBw==",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEQCIFAg2r6CyTkUqIGJrLlNdMqCj+s4HX7eyFktO2MEqET6AiAjkCZ6lqk+YgMJrXNyBSXwoO5Im2MXGm/0fz5Hg23c0Q=="
    }
  ]
}

Repository

PENDING
monkeykingplus/react-native-picker

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:02 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:2efff1d49e1f4cfb293301d421e7c30cd97c0aae6e7b7d1e189e0c751b81d3b9

Other collected versions

1.0.116 Oct1.0.016 OctView all collected versions →