Coder Social home page Coder Social logo

real-alexei / react-native-multi-picker-ios Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 19 KB

Multiple choice picker for React Native

Home Page: https://npmjs.com/react-native-multi-picker-ios

JavaScript 45.08% Objective-C 24.95% Swift 19.68% Ruby 10.29%
react-native ios pickerview multiple-choice

react-native-multi-picker-ios's Introduction

This is simply a React Native bridge to UIMultiPicker iOS library.

UIMultiPicker

Usage

API is very similar to React Native Picker:

import React from 'react'
import {
  AppRegistry, 
  StyleSheet, 
  SafeAreaView,
  Text
} from 'react-native'
import MultiPicker from 'react-native-ui-multi-picker'

class App extends React.Component {

  static TASTES = [
    'Sweet',
    'Sour',
    'Bitter',
    'Salty',
    'Umami'
  ];

  state = {
    selected: ['Sweet', 'Bitter']
  }

  render() {
    return (
      <SafeAreaView style={styles.container}>
        <MultiPicker
          style={styles.picker}
          onChange={({ selectedValues }) => this.setState({ selected: selectedValues })}
          selectedValues={this.state.selected}
        >{App.TASTES.map(taste => 
          <MultiPicker.Item key={taste} value={taste} label={taste} />)}
        </MultiPicker>
        <Text style={styles.caption}>Selected: {this.state.selected.join(', ')}</Text>
      </SafeAreaView>
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1
  },
  picker: {
    backgroundColor: '#DDD'
  },
  caption: {
    padding: 20
  }
})

AppRegistry.registerComponent('App', () => App)

Installation

โš ๏ธ This library relies on CocoaPods for proper dependency management, since it pulls native Swift library UIMultiPicker.

First:

npm install --save react-native-multi-picker-ios

Then add the following to your ios/Podfile:

pod 'RNMultiPicker', :path => '../node_modules/react-native-multi-picker-ios'

Finally run pod install.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.