🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

react-native-dynamic-picker

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-dynamic-picker

dynamic picker,datetime picker

1.0.6
latest
Source
npm
Version published
Weekly downloads
8
Maintainers
1
Weekly downloads
 
Created
Source

react-native-dynamic-picker

I am sorry that my English is not very good.But I will try.

The README.md may be out of date in npmjs.com. Please view README.md in github.

点击可查看简体中文版

Introduction

Based on Picker of react-native.Support multi-level linkage,like Province-City-District. The package includes DateTimePicker Component,the Component Extended from react-native-dynamic-picker,it can be used to pick “year-month-day-hour-minute-second”.

note:the Picker represents react-native-dynamic-picker in the following,unless otherwise stated.

IOS Demo Screenshot: click to view

Android Demo Screenshot: click to view click to view

Install

lastest version: 1.0.6

npm install --save react-native-dynamic-picker

Example

import * as React from 'react';
import { StyleSheet, View } from 'react-native';
import { Picker, DateTimePicker } from 'react-native-dynamic-picker';

export default class Example extends React.Component {
	componentDidMount(){
		this.refs['Picker'].showPicker(true);
		this.refs['DynamicPicker'].showPicker(true);
		this.refs['DateTimePicker'].showPicker(true);		
	}
    render() {
        return (
            <View style={styles.container}>
                <Picker ref='Picker' data={this.props.list} title='Picker' branchTitles={['Options']} />
                <Picker ref='DynamicPicker' isDynamic={true}  data={this.props.areaList} title='Pick Area' branchTitles={['Country', 'City', 'District']} />
                <DateTimePicker ref='DateTimePicker' title='Pick Date' type={DateTimePicker.type.date} />
            </View >
        )
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        flexDirection: 'column'
    }
	})

Show And Hide

		this.refs['Picker'].showPicker(true);//Show
		this.refs['Picker'].showPicker(false);//Hide

data Description:

when isDynamic is true
data is a "item List"(like [item,item,item...]) ,the List‘lable will display on first column of Picker ,
		
the data structure of item :
    {
        value: string, //value
        lable: string,  //display text
        children: item[]  //children item
        mustGetNewChildrenEveryTime: boolean //Whether to update children every time when you set "getChildrenFuns" (see Picker Parameters).defaultValue is false                                                           
	}

data example:
[
	{
		value:'100',
		lable:'China',
		children:[
					{
						value:'110',
						lable:'Beijing',
						children:[
									{
										value:'111',
										lable:'Chaoyang',
										children:undefined 
									},
									{
										value:'112',
										lable:'Haidian',
										children:undefined 
									}
								]
					},
					 {
						value:'120',
						lable:'Shanghai',
						children:...
					}
				]
	},
	{
		value: '200',
		lable: 'USA',
		children: ...
  	},
	...
]
when isDynamic is false
data is a Two-dimensional array (like [[item,item...],[item,item...],[item,item...],...]),
one column bind one [item,item...]

the data structure of item:
			 {
                    value: string, //value
                    lable: string,  //display text
			}

data example:
		[
			[
			     {
				 	value:'00',
					lable:'00 hour'
				 },
				 {
				 	value:'01',
					lable:'01 hour'
				 },
				 {
				 	value:'02',
					lable:'02 hour'
				 },
				 ...
			],
			[
			     {
				 	value:'00',
					lable:'00 minute'
				 },
				 {
				 	value:'01',
					lable:'01 minute'
				 },
				 {
				 	value:'02',
					lable:'02 minute'
				 },
				 ...
			]
		]

how to use DateTimePicker

The package includes 'DateTimePicker' Component,the Component Extended from 'react-native-dynamic-picker'.
It can be used to pick “year-month-day-hour-minute-second”.
Set the 'type' to change the mode of DateTimePicker. 

type can set from one of 'DateTimePicker.type' 

DateTimePicker.type=
 {
    datetime,
    date,
    year_month,
    month_day_time,
    month_day,
    day_time,
    time
}

Picker Parameters

note: only data is Required.

Parameter NameIntroductionTypeDetails
isDynamicis dynamicbooleandefault:false.The advice is always explicit set isDynamic.
datadata[item,item,...] or [[item,item...],[item,item...],...]The structure of the data depends on isDynamic.Please see Example
titletitlestring
titleStylestyle of the titleTextStyle
branchTitlesevery column's titlestring Listlike ['Country', 'City', 'District']
branchTitleStylestyle of branchTitlesTextStyle List or TextStyleIncoming List to control every branchTitle,or incoming one TextStyle to control all branchTitles
branchPickersStylesstyle of react-native's PickerViewStyle List or ViewStyleIncoming List to control every react-native's Picker,or incoming one ViewStyle to control all react-native's Pickers.See details from react-native document
branchPickersItemStyles(only IOS)style of react-native's 'Picker.Item'TextStyle List or TextStyleonly IOS
topInfoStylestyle of top promptTextStyle
topInfoCreateFuna function to create top promptfunctionwhen selected item has changed,the function will be called. The function can get a parameter, selectItems,it's the all of selected items now.The function must return a string like:Now Date:2011-1-1.
buttonStylestyle of bottom's buttonTextStyle
okButtonTexttext of okButtonstringdefault:'确定'
cancelButtonTexttext of cancelButtonstringdefault:'取消'
okCallBackokCallBackfunctiontow Parameters: selectValues and selectItems
cancelCallBackcancelCallBackfunctiontow Parameters: selectValues and selectItems
colunmMaxmax colunm of one rownumberdefault:3 Max react-native's Picker of one row
defaultSelectValuesdefaultSelectValuesstring ListSet selected values when Picker init
defaultValueButtonShowshow 'DefaultValue' buttonbooleanif you set the getDefaultSelectValuesFun,when you tap 'DefaultValue' button,there will call getDefaultSelectValuesFun and the selected items will change to the return values,else,the selected items will change to defaultSelectValues
defaultValueButtonTexttext of 'DefaultValue' buttonstringdefault:'默认值'
getDefaultSelectValuesFuncallback function of DefaultValue buttonfunctionthe getDefaultSelectValuesFun must return a Values List
pressMaskLayerToHidepress MaskLayer to hide Pickerbooleandefault:false
getChildrenFunsa function List to dynamic get childrenfunction ListThis is a function List ,like [fun,fun,fun...].When a selected item has changed,there will call one of the getChildrenFuns to get children.One column bind one of the getChildrenFuns.Every function will get two parameters,selectItems and columnIndex.And all of them must return a item List.when the 'item.mustGetNewChildrenEveryTime' is true,there will always call getChildrenFun every times.When the 'item.mustGetNewChildrenEveryTime' is false,there will call getChildrenFun only when 'item.children' is undefined or null

DateTimePicker Parameters

support all Picker Parameters

note:no DateTimePicker Parameters is Required

Parameter NameIntroductionTypeDetails
typetype of modeDateTimePicker.typeDateTimePicker.type : { datetime, date, year_month, month_day_time, month_day, day_time, time}
minYearmin yearnumber
maxYearmax yearnumber
showNowDayshow 'NowDay' buttonboolean
showSecondshow secondboolean
unitTextsunit list(like['year', 'month', 'day', 'hour', 'minute', 'second'] )string Listdefault:['年', '月', '日', '时', '分', '秒']
showWeekshow “week”boolean
weekTextTypetype of week'textDateTimePicker.weekTextTypeDateTimePicker.weekTextType:{ en, en_simple, cn_zhou, cn_xingQi }

Last

The first release of open source components, many deficiencies, I will step up to improve. Do a lot of their own little things, have long wanted to think they can also share some things for everyone. But the work has been very busy, the quality of open source components to control and documentation (especially the English documentation, think of the headache) maintenance is indeed a very troublesome thing, so dragged on. Recently I finally made up my mind, can no longer own behind closed doors, and to start for our open source community building blocks, so this typecript written before I react-native components released. When I developed the first "react-native" project, I encountered the problem of "provincial-municipal-district" three-level linkage. I did not have a suitable component in the community for a day. So I decided to code myself out. I think it's okay to use them, I released some improvements. I hope you like it.

Please give me a message,if you have any question or find any bug.

The last of the final:Enjoy It

Keywords

react

FAQs

Package last updated on 13 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts