2.0.6 • Published 2 years ago

quick-picker v2.0.6

Weekly downloads
59
License
MIT
Repository
github
Last release
2 years ago

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="time" && mode="datetime"

Alt Text

Android Appearance

pickerType="normal"

Alt Text

pickerType="time" && mode="datetime"

Alt Text

About Quickpicker

This picker is offering an out of the box solution. It allows you to handle iOS and Android using the same API. It supports regular picker and date/time picker. It combines https://facebook.github.io/react-native/docs/picker and https://github.com/react-native-community/react-native-datetimepicker#react-native-datetimepicker into a single API.

Installation

npm i quick-picker

if you are using RN < 60 make sure to use 1.x.x

Usage Example

At the top level 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() {
    return (
      <View style={styles.fill}>
        <StatusBar />
        <SideMenu>
          <OtherFancyStuff />
        </SideMenu>
        <QuickPicker />
      </View>
    );
  }
}

To open the Picker (that could be anywhere deeper in your app), you must call QuickPicker.open({...})

import QuickPicker from 'quick-picker';

export default class AnotherRandomComponent extends React.Component {
  state = {
    item: {
      value: '1',
      label: 'salut',
    },
  };

  _onPressButton = () => {
    QuickPicker.open({
      onChange: item => this.setState({ item }),
      items: [
        {
          value: '1',
          label: 'salut',
        },
        {
          value: '2',
          label: 'salut2',
        },
      ],
      item: this.state.item,
    });
  };

  render() {
    return (
      <View style={styles.container}>
        <TouchableOpacity onPress={this._onPressButton}>
          <Text>Open up picker, selected value: {this.state.item.label}</Text>
        </TouchableOpacity>
      </View>
    );
  }
}

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

API

Methods

Static QuickPicker.open(pickerOptions)

Opens the picker.

Static QuickPicker.close()

Closes the picker.

PickerOptions

fieldtypedefaultValuePlatformdescription
itemItemundefinedBothPicker's selected item
itemsItem[][]BothPicker's items
onChange(Item | Date) => voidundefinedBothCallback function when an item is selected
onPressDone(Item | Date) => voidundefinedBothCallback function when Done/Ok button is pressed
onTapOut() => voidundefinedBothCallback function when Cancel button is pressed or when user taps Out
disableTopRowbooleanfalseiOSDisable the picker top bar
topRowReactNodeundefinediOSIf you want to create your own custom top bar
doneButtonTextstring"Done" (iOS) "Ok" (Android)BothDone button text
cancelButtonTextstring"Cancel"AndroidCancel button text
doneButtonTextStyleTextStyleundefinedBothDone (and Cancel on Android) button text style
androidModalStyleViewStyleundefinedAndroidAndroid's modal view style
androidItemStyleViewStyleundefinedAndroidAndroid's modal items style
androidItemTextStyleTextStyleundefinedAndroidAndroid's modal items text style
androidSelectedItemStyleTextStyleundefinedAndroidAndroid's modal selected item text style
pickerType"normal" | "time""normal"Bothsets the picker to his normal mode or to time mode
mode"date" | "time" | "datetime" | "countdown"undefinedBothmode if pickerType is set to "time"
display"default" | "spinner" | "calendar" | "clock"undefinedAndroidDefines the visual display of the picker for Android
dateDatenew Date()bothCurrent selected date
maximumDateDateundefinedbothMaximum date
minimumDateDateundefinedbothMinimum date
timeZoneOffsetInMinutesnumberundefinediOSAllows changing of the timeZone of the date picker. By default it uses the device's time zone.
localestringundefinediOSAllows changing of the locale of the component. By default it uses the device's locale.
is24HourbooleanundefinedAndroidAllows changing of the time picker to a 24 hour format.
minuteInterval1 | 2 | 6 | 5 | 4 | 3 | 10 | 12 | 15 | 20 | 30undefinediOSThe interval at which minutes can be selected.
useNativeDriverbooleantruebothUse native driver

Item

fieldtypedescription
valuestring or numberitem's value
labelstringitem's label
2.0.6

2 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

2.0.0-beta.1

4 years ago

2.0.0-beta.0

4 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago