react-native-picker
TypeScript icon, indicating that this package has built-in type declarations

4.3.7 • Public • Published

react-native-picker

npm version dependency status

ui3 ui4

Documentation

Params

Key Type Default Support Description
isLoop Boolean false Android
pickerTextEllipsisLen number 6 Android
pickerConfirmBtnText string confirm iOS/Android
pickerCancelBtnText string cancel iOS/Android
pickerTitleText string pls select iOS/Android
pickerConfirmBtnColor array [1, 186, 245, 1] iOS/Android
pickerCancelBtnColor array [1, 186, 245, 1] iOS/Android
pickerTitleColor array [20, 20, 20, 1] iOS/Android
pickerToolBarBg array [232, 232, 232, 1] iOS/Android
pickerBg array [196, 199, 206, 1] iOS/Android
pickerToolBarFontSize number 16 iOS/Android
wheelFlex array [1, 1, 1] iOS/Android
pickerFontSize number 16 iOS/Android
pickerFontColor array [31, 31, 31, 1] iOS/Android
pickerFontFamily string iOS/Android
pickerRowHeight number 24 iOS
pickerData array iOS/Android
selectedValue array iOS/Android
onPickerConfirm function iOS/Android
onPickerCancel function iOS/Android
onPickerSelect function iOS/Android

Methods

Key Support Description
init iOS/Android init and pass parameters to picker
toggle iOS/Android show or hide picker
show iOS/Android show picker
hide iOS/Android hide picker
select iOS/Android select a row
isPickerShow iOS/Android get status of picker, return a boolean

Usage

Step 1 - install

    npm install react-native-picker --save

Step 2 - link

    react-native link

Step 3 - import and use in project

import Picker from 'react-native-picker';
let data = [];
for(var i=0;i<100;i++){
    data.push(i);
}
 
Picker.init({
    pickerData: data,
    selectedValue: [59],
    onPickerConfirm: data => {
        console.log(data);
    },
    onPickerCancel: data => {
        console.log(data);
    },
    onPickerSelect: data => {
        console.log(data);
    }
});
Picker.show();
    

Integration With Existing Apps (iOS)

The Podfile will like below:

platform :ios, '8.0'
target 'YourTarget' do
    pod 'React', :path => '../YOUR_REACT_NATIVE_PROJECT/node_modules/react-native', :subspecs => [
    'Core',
    ...
    ]
    pod 'Picker', :path => '../YOUR_REACT_NATIVE_PROJECT/node_modules/react-native-picker'
end

After you have updated the Podfile of the existing app, you can install react-native-picker like below:

$ pod install

Notice

support two modes:

1. parallel: such as time picker, wheels have no connection with each other

2. cascade: such as date picker, address picker .etc, when front wheel changed, the behind wheels will all be reset

parallel:

  • single wheel:
pickerData = [1,2,3,4];
selectedValue = 3;
  • two or more wheel:
pickerData = [
    [1,2,3,4],
    [5,6,7,8],
    ...
];
selectedValue = [1, 5];

cascade:

  • two wheel
pickerData = [
    {
        a: [1, 2, 3, 4]
    },
    {
        b: [5, 6, 7, 8]
    },
    ...
];
selectedValue = ['a', 2];
  • three wheel
pickerData = [
    {
        a: [
            {
                a1: [1, 2, 3, 4]
            },
            {
                a2: [5, 6, 7, 8]
            },
            {
                a3: [9, 10, 11, 12]
            }
        ]
    },
    {
        b: [
            {
                b1: [11, 22, 33, 44]
            },
            {
                b2: [55, 66, 77, 88]
            },
            {
                b3: [99, 1010, 1111, 1212]
            }
        ]
    },
    {
        c: [
            {
                c1: ['a', 'b', 'c']
            },
            {
                c2: ['aa', 'bb', 'cc']
            },
            {
                c3: ['aaa', 'bbb', 'ccc']
            }
        ]
    },
    ...
]

For pure javascript version -> v3.0.5

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
4.3.71,619latest

Version History

VersionDownloads (Last 7 Days)Published
4.3.71,619
4.3.62
4.3.56
4.3.41
4.3.21
4.3.12
4.3.01
4.2.03
4.1.21
4.1.11
4.1.01
4.0.191
4.0.181
4.0.172
4.0.162
4.0.151
4.0.141
4.0.131
4.0.122
4.0.111
4.0.101
4.0.91
4.0.83
4.0.71
4.0.62
4.0.51
4.0.41
4.0.33
4.0.21
4.0.11
3.0.53
3.0.41
3.0.33
3.0.21
3.0.11
3.0.03
2.0.52
2.0.41
2.0.32
2.0.21
2.0.11
2.0.01
1.1.13
1.1.03
1.0.02
0.4.11
0.4.02
0.3.51
0.3.42
0.3.32
0.3.21
0.3.11
0.3.01
0.2.111
0.2.102
0.2.91
0.2.81
0.2.71
0.2.61
0.2.51
0.2.41
0.2.32
0.2.22
0.2.11
0.2.01
0.1.21
0.1.02

Package Sidebar

Install

npm i react-native-picker

Weekly Downloads

1,722

Version

4.3.7

License

MIT

Unpacked Size

155 kB

Total Files

36

Last publish

Collaborators

  • zooble