All Projects β†’ ugglr β†’ react-native-value-picker

ugglr / react-native-value-picker

Licence: MIT License
Cross-Platform iOS(ish) style picker for react native.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-native-value-picker

react-daterange-picker
A react date range picker to using @material-ui. Live Demo: https://flippingbitss.github.io/react-daterange-picker/
Stars: ✭ 85 (+372.22%)
Mutual labels:  react-component, npm-package, picker, react-hooks
react-circle-flags
πŸš€ A React component with a collection of 300+ minimal circular SVG country flags. Wrapper of HatScripts/circle-flags
Stars: ✭ 29 (+61.11%)
Mutual labels:  react-component, react-components, npm-package
fluent-windows
🌈 React components that inspired by Microsoft's Fluent Design System.
Stars: ✭ 122 (+577.78%)
Mutual labels:  react-component, react-components, react-hooks
Registration-and-Login-using-MERN-stack
Simple Registration and Login component with MERN stack
Stars: ✭ 210 (+1066.67%)
Mutual labels:  yarn, react-component, react-components
awesome-web-react
πŸš€ Awesome Web Based React πŸš€ Develop online with React!
Stars: ✭ 31 (+72.22%)
Mutual labels:  react-component, react-components, react-hooks
tiny-ui
βš›οΈ A friendly UI component set for React.js
Stars: ✭ 202 (+1022.22%)
Mutual labels:  react-component, react-components, react-hooks
react-crud-icons
57 SVG icons for CRUD applications, packaged as a React component with light & dark themes and tooltip.
Stars: ✭ 19 (+5.56%)
Mutual labels:  react-component, react-components
animation-wrapper-view
Declarative animations with imperative controls for RN/RNW.
Stars: ✭ 53 (+194.44%)
Mutual labels:  react-component, react-components
delete-react-zombies
CLI to search and delete unimported 🧟components in your react βš›οΈ files
Stars: ✭ 70 (+288.89%)
Mutual labels:  react-component, react-components
imrc-datetime-picker
(Improved) React component datetime picker by momentjs πŸ“†
Stars: ✭ 21 (+16.67%)
Mutual labels:  npm-package, picker
Nectus
A boilerplate Flask API for a Fullstack Project with some additional packages and configuration prebuilt. βš™
Stars: ✭ 32 (+77.78%)
Mutual labels:  react-components, react-hooks
react-guidebook
πŸ“š React ηŸ₯θ―†ε›Ύθ°± ε…³δΊŽζ¦‚εΏ΅γ€ζŠ€ε·§γ€η”Ÿζ€γ€ε‰ζ²Ώγ€ζΊη ζ ΈεΏƒ
Stars: ✭ 22 (+22.22%)
Mutual labels:  react-components, react-hooks
react-windows-ui
Build Windows fluent UI apps using ReactJS. Provides a set of accessible, reusable, and composable React components that make it super easy to create websites and apps.
Stars: ✭ 383 (+2027.78%)
Mutual labels:  react-component, npm-package
MinifyAllCli
πŸ“¦ A lightweight, simple and easy npm tool to π—Ίπ—Άπ—»π—Άπ—³π˜† JSON/C, HTML and CSS! Also known as MinifyAll core! ⭐ Usable as π‘ͺ𝑳𝑰 tool or π’Šπ’Žπ’‘π’π’“π’•π’‚π’ƒπ’π’† in TS/JS as a 𝑴𝑢𝑫𝑼𝑳𝑬 πŸ₯°
Stars: ✭ 21 (+16.67%)
Mutual labels:  npm-package, npmjs
react-native-select-pro
React Native dropdown (select) component developed by Mobile Reality
Stars: ✭ 79 (+338.89%)
Mutual labels:  picker, react-native-component
react-native-multi-selectbox
Platform independent (Android / iOS) Selectbox | Picker | Multi-select | Multi-picker. The idea is to bring out the common user interface & user experience on both platforms.
Stars: ✭ 169 (+838.89%)
Mutual labels:  picker, react-native-component
iconic-input
Beautiful Input components for React Native... <IconicTextbox/> and much more!
Stars: ✭ 22 (+22.22%)
Mutual labels:  npm-package, react-native-component
furl
Functional react.js components.
Stars: ✭ 33 (+83.33%)
Mutual labels:  react-components, react-hooks
react-multi-context
Manage multiple React 16 contexts with a single component.
Stars: ✭ 19 (+5.56%)
Mutual labels:  npm-package, npmjs
js-stack-from-scratch
🌺 Russian translation of "JavaScript Stack from Scratch" from the React-Theming developers https://github.com/sm-react/react-theming
Stars: ✭ 394 (+2088.89%)
Mutual labels:  yarn, npm-package

react-native-value-picker

weekly-downloads-badge monthly-downloads-badge yearly-downloads-badge total-downloads-badge version-badge

Cross-Platform iOS style picker for react native.

Small, Performant

The Native picker on Android is a modal / dropdown design which is vastly different from the native iOS picker. In my current project we wanted a design more similar to the iOS native picker, and thus I created this Scroll Picker as a replacement on Android, but it works equally well on iOS for instance as an alternative to @react-native-community/picker native iOS picker module.

Examples

Basic Example Bottom Sheet Example
basic example Bottom Sheet Example

Install into project

yarn add react-native-value-picker

import and usage

import {ScrollPicker} from 'react-native-value-picker';

        ...

        <ScrollPicker
          // We need to tell the picker the current picked value
          currentValue={pickedValue}
          // The picker is a pure component so we need to tell it
          // what data it needs to subscribe to, otherwise it won't
          // re-render
          extraData={pickedValue}
          // The array of objects which makes up the list
          list={MOCK_DATA}
          // Callback function to update the picked value
          onItemPress={setPickedValue}
          // Changes the text color in the list
          labelColor="blue"
          // Changes color of the row separator in the list
          separatorColor="purple"
          // Changes color of the text of the picked item in the list
          selectedColor="red"
        />

        ...

Picker List Data Structure

the list prop requires an array of Objects according to the below structure.

  • value: the API value
  • label: the text rendered into the picker list.
export const MOCK_DATA = [
  {
    value: 1,
    label: 'Number 1',
  },
  {
    value: 2,
    label: 'Number 2',
  },
  {
    value: 15,
    label: 'Number 15',
  },
  {
    value: 16,
    label: 'Number 16',
  },
];

Run the examples Locally

Clone project

git clone https://github.com/ugglr/react-native-value-picker.git

move into the examples folder.

cd react-native-value-picker && cd examples

in examples root

yarn

iOS Install pods and go back to examples root

cd ios && pod install && cd ..

Run react native

yarn run ios

Android run react native in examples root

yarn run android

ScrollPicker Props

Prop Description
currentValue Tells the picker the current picked value
extraData The underlying RN component which creates the list is FlatList. Which means, as a FlatList it is a pure component and won't re-render, unless it subscribes to a piece of data that will trigger a re-render.
list The array of objects which makes up the list. Each Object in the Array needs to have a value-field, and a label-field. Value is the API value which the developer needs to user to pick. Label is the verbose friendly String which is displayed to the user.
onItemPress Callback which get's executed when user presses an Item in the picker list.
labelColor Changes the un-picked text color of the Items in the list
separatorColor Changes color of the separator lines between the Items in the list.
selectedColor Changes the picked Item text color

Example Code

BasicExample.js

import React, {useState} from 'react';
import {View, Text, StyleSheet} from 'react-native';

import {ScrollPicker} from 'react-native-value-picker';

import {MOCK_DATA} from './mockData';

function BasicExample() {
  const [pickedValue, setPickedValue] = useState(7);

  return (
    <View style={styles.Container}>
      <Text style={styles.Title}>Basic Example</Text>
      <Text>Current Value Picked: {pickedValue}</Text>

      <View style={styles.PickerContainer}>
        <ScrollPicker
          currentValue={pickedValue}
          extraData={pickedValue}
          list={MOCK_DATA}
          onItemPress={setPickedValue}
        />
      </View>
      <Text style={{fontSize: 22, textAlign: 'center'}}>
        We can customize the look by setting the labelColor, separatorColor and
        selectedColor props
      </Text>
      <View style={styles.PickerContainer}>
        <ScrollPicker
          // We need to tell the picker the current picked value
          currentValue={pickedValue}
          // The picker is a pure component so we need to tell it
          // what data it needs to subscribe to, otherwise it won't
          // re-render
          extraData={pickedValue}
          // The array of objects which makes up the list
          list={MOCK_DATA}
          // Callback function to update the picked value
          onItemPress={setPickedValue}
          // Changes the text color in the list
          labelColor="blue"
          // Changes color of the row separator in the list
          separatorColor="purple"
          // Changes color of the text of the picked item in the list
          selectedColor="red"
        />
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
... see example file for styles ...
});

export default BasicExample;

Bottom Sheet Example

Note: The bottom sheet component is not included in the package. I'm using react-native-raw-bottom-sheet

import React, {useRef, useState} from 'react';
import {View, Text, Button, StyleSheet} from 'react-native';
import RBSheet from 'react-native-raw-bottom-sheet';

import {ScrollPicker} from 'react-native-value-picker';

import {MOCK_DATA} from './mockData';

function BottomSheetExample() {
  const [pickedValue, setPickedValue] = useState(7);
  const refRBSheet = useRef();

  return (
    <View style={styles.Container}>

    ...

      <RBSheet
        ref={refRBSheet}
        closeOnDragDown={true}
        closeOnPressMask={true}
        height={300}
        customStyles={{
          draggableIcon: {
            backgroundColor: '#000',
          },
          container: {
            borderRadius: 12,
          },
        }}>
        {/* Start of Scroll Picker */}
        {/*
            The underlying FlatList is not wrapped with a View.
            So to align it in the sheet I wrap the picker and control
            the positioning. I like that approach because devs has full control
            over how the picker is placed & aligned.
        */}
        <View style={styles.SheetView}>
          <ScrollPicker
            // We need to tell the picker the current picked value
            currentValue={pickedValue}
            // The picker is a pure component so we need to tell it
            // what data it needs to subscribe to, otherwise it won't
            // re-render
            extraData={pickedValue}
            // The array of objects which makes up the list
            list={MOCK_DATA}
            // Callback function to update the picked value
            onItemPress={setPickedValue}
          />
        </View>
        {/* End of Scroll Picker */}
      </RBSheet>
    </View>
  );
}

const styles = StyleSheet.create({
... see the example file for styles ...
});

export default BottomSheetExample;

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].