1.0.2 • Published 5 years ago

@davidgovea/react-native-wheel-datepicker v1.0.2

Weekly downloads
155
License
WTFPL
Repository
github
Last release
5 years ago

@davidgovea/react-native-wheel-datepicker

NPM Build Status npm.io

A iOS style picker and datepicker components for ReactNative.

This is the fourth fork of repository, since it seems that @pinguinjkeke is no longer supporting react-native-wheel-datepicker.

Goals of this fork:

  • Maintenance / updates for RN & platform changes
  • Implement some missing features on Android (12-hour AM/PM mode, minute intervals)
  • Typescript definitions
  • Add tests
  • Semver adherance

Introduction

Cross platform Picker component for React-native.

Since picker is originally supported by iOS while Android only supports a ugly Spinner component. If you want to have the same user behaviour, you can use this.

The android component is based on wheel-picker which runs super fast and smoothly. It also supports curved effect which make it exactly the same looking and feel as the ios picker.

npm.io npm.io

npm.io

Installation

npm i @davidgovea/react-native-wheel-datepicker --save

Configration (for RN below 0.60):

react-native link @davidgovea/react-native-wheel-datepicker

<Picker> Component

import { Picker } from '@davidgovea/react-native-wheel-datepicker';

<Picker
  style={{ flex: 1 }}
  selectedValue={3}
  pickerData={[1, 2, 3, 4, 5, 6]}
  onValueChange={value => { console.log(value); }}
/>

Picker props

PropertyTypeDefaultDescription
pickerDataany[]-Required: an array of data to display in picker
onValueChange(value: any) => void-Required: selected value changed callback
selectedValueany?First item of pickerDataSet/control the selected value
textColorstring'#333'(Android only) Color of spinner text
textSizenumber26(Android only) Spinner text size
itemSpacenumber20(Android only) Spacing between spinner items
itemStylestylenull(iOS only) passed into PickerIOS for item styling
stylestylenullStyle applied to the picker element

<DatePicker> Component

import { DatePicker } from '@davidgovea/react-native-wheel-datepicker';

<DatePicker
  mode="datetime"
  use12Hours
  minuteInterval={15}
  onDateChange={(date) => { console.log(date); }}
/>

DatePicker props

PropertyTypeDefaultDescription
onDateChange(value: Date) => void-Required: selected date changed callback
modeenum('date', 'time', 'datetime')'date'Show date, time, or both in picker
dateDatenew Date() (now)Provide/control the selected date value
maximumDateDate10 years in futureRestricts the range of possible date/time values.
minimumDateDate10 years in pastRestricts the range of possible date/time values.
minuteIntervalenum(1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30)1The interval at which minutes can be selected.
use12Hoursbooleanfalse(Android only) Use 12-hour AM/PM for hour selection. On iOS, DatePickerIOS automatically uses i18n information to enable 12-hour mode.
ordercustom string'D-M-Y'(Android only) Ordering of date fields. Use "D" for day, "M" for month, "Y" for year, separated by dashes ("-")
labelUnit{ year: string, month: string, date: string }{ year: '', month: '', date: '' }(Android only) Suffix labels for year, month, date values
textColorstring'#333'(Android only) Color of spinner text
textSizenumber26(Android only) Spinner text size
itemSpacenumber20(Android only) Spacing between spinner items
stylestylenullStyle applied to the datepicker element

DEPRECATED Integration with CustomDatePickerIOS

CustomDatePickerIOS can apparently cause Appstore approval issues. This library will be removing iOS functionality in a future release. Users are advised to use the builtin Pickers on iOS.

By default, package provides default DatePickerIOS on the iOS side to simplify usage on both platforms.

You can install react-native-custom-datepicker-ios package if you need textColor functionality on IOS platform.

Just install:

npm i react-native-custom-datepicker-ios
// or
yarn add react-native-custom-datepicker-ios

link dependencies:

react-native link react-native-custom-datepicker-ios

And register CustomDatePickerIOS inside react-native-wheel-datepicker package.

import { registerCustomDatePickerIOS } from '@davidgovea/react-native-wheel-datepicker';
import CustomDatePickerIOS from 'react-native-custom-datepicker-ios';

registerCustomDatePickerIOS(CustomDatePickerIOS);

Then you can use textColored components for both platforms inside render function!

import { DatePicker } from '@davidgovea/react-native-wheel-datepicker';

// ...
render() {
  return (
    <DatePicker
      mode="date"
      textColor="green"
    />
  )
}
1.0.2

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.232

6 years ago

0.0.231

6 years ago

0.0.230

6 years ago

0.0.229

6 years ago

0.0.228

6 years ago

0.0.227

6 years ago

0.0.226

6 years ago

0.0.225

6 years ago

0.0.224

6 years ago

0.0.223

6 years ago