0.1.0 • Published 4 years ago

@rawewhat/react-native-picker v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

React Native Picker

Picker or Selector for React Native with zero dependency and cross-platform.

Changelog

Content

Install

using npm
npm install @rawewhat/react-native-paper

using yarn
yarn add @rawewhat/react-native-paper

Usage

  • just import Picker in any component you want to use it

import { Picker } from '@rawewhat/react-native-picker'
import Picker from '@rawewhat/react-native-picker'

  • then use it in your return function or render function

return <Picker />

API

NameTypeDefaultDescription
dataarray{ label: "None", value: "" }Array of object to generate picker items.
labelstringundefinedLabel that show above the picker text.
labelFieldstring"label"Set this to tell Picker which object property to genrate picker item label.
placeholderstring"Press to select"When there is no selected value, placeholder text will be show.
titlestring"Picker"Title of picker modal.
valuestringundefinedSet this to control picker selected value.
valueFieldstring"value"Set this to tell Picker which object property to use for getting selected value.
canTouchOutsidebooleantrueWhether user can click outside picker modal to close.
caretPng.pngundefinedCaret icon in png format.
caretSvgcomponentundefinedCaret icon in react-native-svg format.
disabledbooleanundefinedDisable picker onPress event.
errorbooleanfalseShow red border when there is error.
withLinebooleanundefinedShow line below picker and picker modal title.
heightnumber|string50Height of the picker button.
modalElevationnumber10Control picker modal drop shadow and zIndex on Android.
modalRadiusnumber10Control picker modal top-left and top-right border radius.
overlayOpacityfloat0.0Control opacity of backdrop outside picker modal.
pickerElevationnumber2Control picker button drop shadow and zIndex on Android.
pickerRadiusnumber5Control picker button border radius.
spacingnumber0Control picker button margin bottom.
widthnumber|string"auto"Width of the picker button.
listPropsobjectundefinedOverride picker modal FlatList props.
listItemPropsobjectundefinedOverride picker modal FlatList item TouchableOpacity props.
modalPropsobjectundefinedOverride picker modal container View props.
pickerPropsobjectundefinedOverride picker container TouchableOpacity props.
styleobjectundefinedOverride picker container TouchableOpacity style.
caretStyleobjectundefinedOverride picker caret png or svg component style.
itemTextStyleobjectundefinedOverride picker modal item text style.
labelStyleobjectundefinedOverride picker label text style.
lineStyleobjectundefinedOverride picker button and picker modal title line style.
listContentStyleobjectundefinedOverride picker modal FlatList contentContainer style.
listSeparatorStyleobjectundefinedOverride picker modal FlatList ItemSeparator component style.
listStyleobjectundefinedOverride picker modal FlatList style.
listTitleStyleobjectundefinedOverride picker modal title style.
modalStyleobjectundefinedOverride picker modal style.
overlayStyleobjectundefinedOverride picker modal overlay style.
textStyleobjectundefinedOverride picker text style.
onChangefunctionundefinedCallback function when picker modal item pressed. (item: object, index: number) => {}
onClosefunctionundefinedCallback function when picker modal closed.

Example

import React from "react";
import { StyleSheet, View } from "react-native";
import { Picker } from "@rawewhat/react-native-picker";

const data = [
  { id: "1", label: "Label 1", value: "value1" },
  { id: "2", label: "Label 2", value: "value2" },
];

const App = () => {
  const _handleChange = (item, index) => {
    console.log("_handleChange", item);
  };

  return (
    <View>
      <Picker data={data} onChange={_handleChange} />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "center",
    paddingHorizontal: 20,
  },
});

export default App;

License

MIT License
-----------

Copyright (c) 2019 Cheng Sokdara (https://rawewhat-team.com)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.