项目作者: rimiti

项目描述 :
:iphone: React Native cross-plateform (iOS / Android) modal picker/selector highly customizable.
高级语言: JavaScript
项目地址: git://github.com/rimiti/react-native-pickerise.git
创建时间: 2017-10-25T18:53:16Z
项目社区:https://github.com/rimiti/react-native-pickerise

开源协议:MIT License

下载


react-native-pickerise

Dependencies
Dependencies
Code Climate score
Coveralls
Code Climate coverage
![Node.js version][nodejs-badge]
![NPM version][npm-badge]
Build Status
Security version
MIT License
PRs Welcome

Description

React Native cross-plateform (iOS/Android) modal picker/selector highly customizable.

Install

  1. $ npm install @rimiti/react-native-pickerise --save

Demo

react-native-pickerise

Examples

  1. import React, {Component} from 'react';
  2. import {StyleSheet} from 'react-native';
  3. import Pickerise from '@rimiti/react-native-pickerise';
  4. export default class Example extends Component {
  5. constructor(props) {
  6. super(props);
  7. }
  8. render() {
  9. const items = [
  10. { section: true, label: 'Cars' }, { label: 'Audi' }, { label: 'Dodge' }, { label: 'Ford' }, { label: 'Renault' },
  11. { section: true, label: 'Bikes' }, { label: 'Kawasaki' }, { label: 'Suzuki' }, { label: 'Triumph' }
  12. ];
  13. return (
  14. <Pickerise
  15. itemsContainerStyle={styles.itemsContainerStyle}
  16. itemsChildStyle={styles.itemsChildStyle}
  17. itemStyle={styles.itemStyle}
  18. itemTextStyle={styles.itemTextStyle}
  19. selectTextStyle={styles.selectTextStyle}
  20. selectStyle={styles.selectStyle}
  21. sectionStyle={styles.sectionStyle}
  22. sectionTextStyle={styles.sectionTextStyle}
  23. cancelStyle={styles.cancelStyle}
  24. cancelTextStyle={styles.cancelTextStyle}
  25. items={items}
  26. initValue="Select"
  27. cancelText="Cancel"
  28. onChange={(item) => console.log(`You chose ${item.label}`)} />
  29. )
  30. }
  31. }
  32. const styles = StyleSheet.create({
  33. itemsContainerStyle: {
  34. borderRadius: 0,
  35. backgroundColor: 'transparent',
  36. marginBottom: 30,
  37. padding: 0,
  38. },
  39. itemsChildStyle: {
  40. paddingHorizontal: 0
  41. },
  42. itemStyle: {
  43. marginTop: 10,
  44. backgroundColor: '#919191',
  45. borderBottomColor: 'transparent',
  46. },
  47. itemTextStyle: {
  48. color: '#fff',
  49. fontSize: 18,
  50. },
  51. selectTextStyle: {
  52. color: '#000',
  53. fontSize: 20,
  54. },
  55. selectStyle: {
  56. borderWidth: 0,
  57. paddingTop: 21,
  58. paddingLeft: 0,
  59. },
  60. sectionStyle: {
  61. borderRadius: 0,
  62. },
  63. sectionTextStyle: {
  64. fontSize: 20,
  65. color: '#fff',
  66. },
  67. cancelStyle: {
  68. backgroundColor: '#22A7F0',
  69. paddingVertical: 20,
  70. alignItems: 'center',
  71. justifyContent: 'center',
  72. marginBottom: 15,
  73. borderRadius: 0,
  74. },
  75. cancelTextStyle: {
  76. color: "#FFF",
  77. fontSize: 18,
  78. },
  79. });

Documentation

  1. Props Type Description Usage
  2. ----------------------------------------------------------------------------------------------------------------------
  3. items {array of objects} With a unique key and label
  4. onChange {function} Callback function, when the users has selected an item (optional)
  5. initValue {string} Text that is initially shown on the button (optional)
  6. cancelText {string} Text of the cancel button (optional)
  7. style {object} Style definitions for the global element (optional)
  8. itemsContainerStyle {object} Style definitions for the items container element (optional)
  9. itemsContainerChildStyle {object} Style definitions for the itemsChild element (optional)
  10. selectStyle {object} Style definitions for the select element (optional)
  11. itemStyle {object} Style definitions for the item element (optional)
  12. cancelStyle {object} Style definitions for the cancel element (optional)
  13. sectionStyle {object} Style definitions for the section element (optional)
  14. overlayStyle {object} Style definitions for the overlay element (optional)
  15. itemTextStyle {object} Style definitions for the item text element (optional)
  16. sectionTextStyle {object} Style definitions for the section text element (optional)
  17. cancelTextStyle {object} Style definitions for the cancel text element (optional)
  18. selectTextStyle {object} Style definitions for the select text element (optional)
  19. modalAnimationType {none, slide, fade} Modal animation type (optional)
  20. modalTransparent {bool} If true render the modal with transparent background (optional)

Scripts

Run using npm run