react-native-list-picker

0.0.5 • Public • Published

react-native-list-picker

The data Picker for React Native.

page 1 page 2

Installation

$ npm i react-native-list-picker --save

Example

import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  View,
  StatusBar,
  PixelRatio,
  TouchableOpacity,
  Platform
} from 'react-native';
import ListPicker from 'react-native-list-picker';
 
const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  welcome: {
    fontSize: 25,
    fontWeight: 'bold',
    textAlign: 'center',
    margin: 10,
    marginBottom: 25,
  },
  instructions: {
    fontSize: 20,
    textAlign: 'center',
    color: '#888',
    marginBottom: 7
  },
  link: {
    fontSize: 14,
    textAlign: 'center',
    color: '#888',
    textDecorationLine: 'underline'
  },
  data: {
    padding: 15,
    marginTop: 10,
    backgroundColor: '#ddd',
    borderColor: '#888',
    borderWidth: 1 / PixelRatio.get(),
    color: '#777'
  }
});
 
let dataList =  require('./data/dataList');
export default class Example extends Component {
  constructor(props){
    StatusBar.setHidden(true);
    super(props);
      this.state = {
        pickData:null
      }
  }
 
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to Picker!
        </Text>
        <ListPicker
          ref={(picker) => { this.picker = picker; }}
          onChange={(value)=> this.setState({pickData: value})}
          closeable = {true}
          isEmojiable = {false}
          dataList={dataList}
        />
        <TouchableOpacity onPress={()=> this.picker.openModal()}>
          <Text style={styles.link}>
             click here
          </Text>
        </TouchableOpacity>
        {this.state.pickData &&
          <Text style={styles.data}>
            {JSON.stringify(this.state.pickData, null, 2)}
          </Text>
        }
      </View>
    );
  }
}
 

Props

Key Type Default Description
onChange function *required The handler when a country is selected
closeable bool false If true, the ListPicker will have a close button
isEmojiable bool false If true, use emoji to render icon
dataList array *required {"letter":"","icon":"","name":""}

dataList

[ {
    "letter": "AFN",
    "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAeCAIAAADRv8uKAAAABGdBTUEAALGPC/xhBQAAAAFzUkd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V6dOn0aA6u5uPj2dHRhw1tdLDkcVY8bQUGFk2P/F0ZeTo0kwLicvpymNgCvMcSnU8Xj8ta6n+vsTuZxRVaU0NdUcObK6rc1tmvKLF8HW1tDBg3IwaFQF4pOTqftDf1iZZ1rcNtQ2lZ0xJoTo6u4+1d7u0HVfa6s+OGgND4OiQCCAhoHz80Qkbdni2r597tYtHgp9U3llYPYOk5gAscjONgWkJPq3+/fVEyc2hkLPbt7MFIv67dssHAafD2WZJ5OkaeVtbcqL5x99+VX/1OBwbBAksP2O7e8yCZETfVtb+8nhwxkhVgWDDNGIxRzT00KSnOvWOVta8pmM+TrnT2vXYj1nPs8wEwW+Xa1+I5oxnJyEK1cqjx+v2LdvLJWiTZv8FRUzmYzpcpUFAmGAuV+uix8u4AcZcDAwhK2iJdxOACAEMOaIx3OnTulPngQaG+c1LW9ZKgCWl69SVfPOHe3yjz6LyIFAYimWYMlGQAhCFLqe7ulBRFVRSNclRFCUWcMgImRAACCW6n6W4zKJANHBmExEmgaMEQBpmkzkYAyI3qHnAiLiHAAAEf56IADgfLlGeUX2Fv5maVfkbeF9/JP4E60nG6TGip3CAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDEzLTEwLTA3VDEzOjE0OjQwKzAyOjAwHXwFzwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxMy0xMC0wN1QxMzoxNDo0MCswMjowMGwhvXMAAAAASUVORK5CYII=",
    "name": "阿富汗"
  }]

Dependencies

  • lodash
  • react-native-emoji
  • world-countries

Contribution

Questions

Feel free to contact me or create an issue

made with ♥

Package Sidebar

Install

npm i react-native-list-picker

Weekly Downloads

2

Version

0.0.5

License

MIT

Unpacked Size

286 kB

Total Files

12

Last publish

Collaborators

  • liukefu