0.1.1 • Published 11 months ago

react-native-wheely-picker v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

react-native-wheely

Original repository: https://github.com/erksch/react-native-wheely

This fork adds ability to pass renderItem function to render custom options.

An all JavaScript, highly customizable wheel picker for react native.

Installation

Install with yarn

yarn add 'react-native-wheely-picker'

Usage

import React, { useState } from 'react';
import { Text } from 'react-native'
import WheelPicker from 'react-native-wheely-picker';

function CityPicker() {
  const [selectedIndex, setSelectedIndex] = useState(0);

  return (
    <WheelPicker
      selectedIndex={selectedIndex}
      options={['Berlin', 'London', 'Amsterdam']}
      onChange={(index) => setSelectedIndex(index)}
      renderItem={(item) => {
        return <Text>{item}</Text>
      }}
    />
  );
}

Props

NameTypeDescription
optionsany[]Options to be displayed in the wheel picker. Options are rendered from top to bottom, meaning the first item in the options will be at the top and the last at the bottom.
selectedIndexnumberIndex of the currently selected option.
onChange(index: number) => voidHandler that is called when the selected option changes.
visibleRestnumberAmount of additional options that are visible in each direction. Default is 2, resulting in 5 visible options.
itemHeightnumberHeight of each option in the picker. Default is 40.
itemStyleStyleProp<ViewStyle>Style for the option's container.
containerStyleStyleProp<ViewStyle>Style of the picker.
selectedIndicatorStyleStyleProp<ViewStyle>Style of overlaying selected-indicator in the middle of the picker.
rotationFunction(x: number) => numberFunction to determine the x rotation of items based on their current distance to the center (which is x). Default is rotation equation
scaleFunction(x: number) => numberFunction to determine the scale of items based on their current distance to the center (which is x). Default is scale quation
opacityFunction(x: number) => numberFunction to determine the opacity of items based on their current distance to the center (which is x). Default is opacity equation
decelerationRate"normal", "fast", numberHow quickly the underlying scroll view decelerates after the user lifts their finger. See the ScrollView docs. Default is "fast".
containerPropsViewPropsProps that are applied to the container which wraps the FlatList and the selected indicator.
flatListPropsFlatListPropsProps that are applied to the FlatList.
renderItemrenderItem: (option: any, index: number) => React.ReactElementrender option of the list