quick-picker
A plug and Play picker for React Native
Last updated 2 months ago by valium .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install quick-picker 
SYNC missed versions from official npm registry.

react-native-quickpicker

npm (scoped)

A picker built in JS for react-native/expo that works right out of the box.

iOS Appearance

pickerType="normal"

Alt Text

pickerType="date" && mode="datetime"

Alt Text

Android Appearance

pickerType="normal"

Alt Text

pickerType="date" && mode="datetime"

Alt Text

Why use this library?

The picker is one of the most common input component in mobile applications, but unfortunately most of the solutions require linking, meaning it won't be possible to use with Expo without ejecting. This one works perfectly in both Vanilla React Native and Expo.

Installation

npm i quick-picker --save

or

yarn add quick-picker

Usage Example

At the root of your app (preferably but not imperatively), you want to have <QuickPicker />

import React, { Component } from "react";
import { View } from "react-native";
import QuickPicker from "quick-picker";

class App extends Component {
  render() {
    const content = null;
    return (
      <View style={styles.fill}>
        <StatusBar />
        <SideMenu>
          <OtherFancyStuff />
          {content}
        </SideMenu>
        <QuickPicker />
      </View>
    );
  }
}

Now if you want to open the Picker (that could be anywhere in your app's navigation), you must call QuickPicker.open({...})

import Touchable from "@appandflow/touchable";
import QuickPicker from "quick-picker";

export default class AnotherRandomComponent extends React.Component {
  state = {
    selectedLetter: null,
  };

  _onPressText = () => {
    const { selectedLetter } = this.state;
    QuickPicker.open({
      items: ["a", "b", "c"],
      selectedValue: "b", // this could be this.state.selectedLetter as well.
      onValueChange: selectedValueFromPicker =>
        this.setState({ selectedLetter: selectedValueFromPicker }),
    });
  };

  render() {
    return (
      <View style={styles.container}>
        <Touchable
          feedback="opacity"
          native={false}
          onPress={this._onPressText}
        >
          <Text>
            Open up picker, selected letter: {this.state.selectedLetter}
          </Text>
        </Touchable>
      </View>
    );
  }
}

Now when the user will touch the button (<Touchable>) the Picker will open with the defined params in QuickPicker.open({...})

API

Static QuickPicker.open(config)

Opens the picker.

    config = {
        items: ?Array<string>,
        selectedValue: ?string | ?Date, // if pickerType is set to 'date', give a Date
        onValueChange: ?Function,
        backgroundColor: ?string,
        topRow: ?Component, // e.g <View> <Text> this will be displayed in the top section of the picker </Text>  </View>
        onPressDone: ?Function, // When user press done button, if you haven't redefined the topRow and kept the default one.
        onTapOut: ?Function, // will be triggered when user tap off the picker
        textStyle: ?Object, // change item text styling, only on IOS
        doneButtonText: ?string, // change the "done" button string. Default is "done".
        doneButtonTextStyle: ?Object, // change the styling of the done button's
        androidModalStyle: ?Object, // change the styling of the default picker's modal on Android
        itemStyleAndroid: ?Object, // change the styling of the default picker's items on Android. Applied also to selected item.
        selectedItemStyleAndroid: ?Object, // change the styling of the default picker's selected item on Android.
        // text, if you haven't redefined the topRow and kept the default one.
        useNativeDriver: boolean, // use Native Driver for animated or not. Default is false.

        // the following props can only be set if pickerType value is 'date'.
        // it use the same API as DatePickerIOS or DatePickerAndroid depending on the os.
        pickerType: ?enum('normal', 'date'), // default value is 'normal'
        mode: ?enum('date', 'time', 'datetime'), // only if pickerType === "date"
        minimumDate: ?Date,
        maximumDate: ?Date,

        disableTopRow: ?boolean, // only on iOS, default = false. Will completely hide the top bar where you would normally find the "done" button.

        locale: ?string, // see https://facebook.github.io/react-native/docs/datepickerios#locale
        timeZoneOffsetInMinutes: ?Number, // see https://facebook.github.io/react-native/docs/datepickerios#timeZoneOffsetInMinutes
        minuteInterval: ?Number, // see https://facebook.github.io/react-native/docs/datepickerios#minuteInterval

    }

Static QuickPicker.close()

Closes the picker.

Current Tags

  • 1.5.0                                ...           latest (2 months ago)

23 Versions

  • 1.5.0                                ...           2 months ago
  • 1.4.0                                ...           5 months ago
  • 1.3.0                                ...           5 months ago
  • 1.2.2                                ...           10 months ago
  • 1.2.1                                ...           10 months ago
  • 1.2.0                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 0.0.13                                ...           a year ago
  • 0.0.12                                ...           a year ago
  • 0.0.11                                ...           a year ago
  • 0.0.10                                ...           a year ago
  • 0.0.9                                ...           a year ago
  • 0.0.8                                ...           2 years ago
  • 0.0.7                                ...           2 years ago
  • 0.0.6                                ...           2 years ago
  • 0.0.5                                ...           2 years ago
  • 0.0.4                                ...           2 years ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 6
Last Day 0
Last Week 3
Last Month 4
Dependencies (1)
Dev Dependencies (3)

Copyright 2014 - 2016 © taobao.org |