Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-picker-modal-view

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-picker-modal-view

React Native Picker Modal View

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
707
increased by0.28%
Maintainers
1
Weekly downloads
 
Created
Source


React Native Picker Modal View

React Native Module to select item picker modal.

npm version npm downloads per month dependencies Status dev-dependencies Status Build Status


Created by Pankod

An alternative to Picker and PickerIOS components with an unified API and consistent look & feel on both plaforms. It's fully configurable and includes built-in support for text search and alphabetical index. Ideal for longer lists not suitable for "wheel-pickers".

Stores Supported:

Apple App StoreGoogle Play

Getting started

$ npm install react-native-picker-modal-view --save

or

$ yarn add react-native-picker-modal-view

Example

import React, { Component } from 'react';
import PickerModal from 'react-native-picker-modal-view';

const items = [ { "Name": "United States", "Value": "United States", "Code": "US", "Id": 1 }, { "Name": "China", "Value": "China", "Code": "CN", "Id": 2 }, { "Name": "Japan", "Value": "Japan", "Code": "JP", "Id": 3 }, { "Name": "Germany", "Value": "Germany", "Code": "DE", "Id": 4 }, { "Name": "Turkey", "Value": "Turkey", "Code": "TR", "Id": 5 } ];

export default class example extends Component {

	constructor(props) {
		super(props);
		this.state = {
			selectedItem: {},
		};
	}

	render() {
		return (
			<PickerModal
				renderSelectView={(disabled, selected, showModal) =>
					<Button disabled={disabled} title={"Show me!"} onPress={showModal} />
				}
				onSelected={(selected) => this.selected(selected)}	
				onClosed={this.close.bind(this)}
				onBackButtonPressed={this.onBackRequest.bind(this)}
				items={items}
				sortingLanguage={'tr'}
				showToTopButton={true}
				selected={this.state.selectedItem}
				autoGenerateAlphabeticalIndex={true}
				selectPlaceholderText={'Choose one...'}
				onEndReached={() => console.log('list ended...')}
				searchPlaceholderText={'Search...'}
				requireSelection={false}
				autoSort={false}
			/>
		)
	}

	close() {
		console.log("close key pressed");
	}

	selected(selected) {
		this.setState({
			selectedItem: selected
		})
	}

	onBackRequest() {
		console.log("back key pressed");
	}
}


Options


PropertiesTypeDescriptionDefault
modalAnimationTypestringThe RN Modal show/hide animation type"slide"
showAlphabeticalIndexstringHides alphabetical index"true"
onClosedFunctionFired when the modal is closed
onBackButtonPressedFunctionFired when the back key is pressed
onSelected
*required
FunctionReturns selected item object"{Id, Name, Value, [key: string]: any}"
items
*required
arrayArray of list items"[{Id, Name, Value, [key: string]: any}]"
renderSelectViewElementRender Select Component<SelectBoxComponent (built-in)>
renderListItemElementRender List item<ListItemComponent (built-in)/>
alphabeticalIndexCharsarrayChracters array for the alphabetical index<Turkish alphabet chracters>
searchInputTextColorstringSearch input placeholder text color"#252525"
keyExtractorFunctionFlatlist defined {key} function<Predefined return map index>
autoGenerateAlphabeticalIndexbooleanAuto-generates alphabetical index from list items data"false"
sortingLanguagestringCountry ISO (Alpha 2) Code for localeCompare"tr"
showToTopButtonbooleanButton for scroll to offset 0"true"
onEndReachedFunctionFired when the list reaches the end
selectPlaceholderTextstringSelect box placeholder text"Choose one..."
searchPlaceholderTextstringSearch input placeholder text"Search..."
selectedobjectDefault selected item
autoSortbooleanAuto-sort data list"false"
disabledbooleanDisable Select box
requireSelectionbooleanRequire at least one list item is selected"false"

Core Props of React Native


PropertiesTypeDescriptionDefault
ModalPropsobjectReact Native Modal Props
FlatListPropsobjectReact Native Flatlist Props
SearchInputPropsobjectReact Native TextInput Props


Running example project

You should have React Native CLI to be installed in order to run example.

Follow this instructions if you need to install React Native CLI

To run the demo app, go to ExampleApp directory then run the following commands:

npm install

Once the installation is done, you can run the following command:

react-native run-ios
react-native run-android

Notes
  • Auto-alphabetical index supported for Turkish and English languages.
Releases
  • 1.0.0 - Initial release

Keywords

FAQs

Package last updated on 10 May 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc