1.2.3 • Published 4 years ago

react-native-navybits-date-time-picker v1.2.3

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

react-native-navybits-date-time-picker

This project is a modified version of react-native-datePicker. It solves the need to set a MinuteInterval on android using the native picker MaterialDateTimePicker

Getting started

$ npm install react-native-navybits-date-time-picker --save

Manual installation

iOS

you don't need to do anything

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.reactlibrary.RNNavybitsDateTimePickerPackage; to the imports at the top of the file
  • Add new RNNavybitsDateTimePickerPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-navybits-date-time-picker'
    project(':react-native-navybits-date-time-picker').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-navybits-date-time-picker/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-navybits-date-time-picker')

Example

Please refer to example.js android!150x300, 20% ios!150x300, 20%

Properties

PropDefaultTypeDescription
style-objectSpecify the style of the DatePicker button, eg. width, height...
date-string | date | Moment instanceSpecify the display date of DatePicker. string type value must match the specified format
mode'date'enumThe enum of date and time for android and ios, , datetime for ios only
format'YYYY-MM-DD'stringSpecify the display format of the date, which using moment.js. The default value change according to the mode.
okText'ok'stringSpecify the confirm text
cancelText'cancel'stringSpecify cancel text
minDate-string | dateRestricts the range of possible date values.
maxDate-string | dateRestricts the range of possible date values.
minTime-string | dateRestricts the range of possible date values.
maxTime-string | dateRestricts the range of possible date values.
duration300numberSpecify the animation duration of datepicker on ios.
hourInterval1numberControls hours interval on android time picker.
minuteInterval10numberControls minutes interval on time picker.(ios and android)
secondInterval10numberControls seconds interval on android time picker.
okColor'green'stringControls ok Text color.
cancelColor'red'stringControls cancel Text color.
accentColor'blue'stringControls date/Time header color.
darkThemefalsebooleanControls date/Time body color.(light or dark)
vibratefalsebooleanSet whether the dialogs should vibrate the device when a selection is made. (android only)
dismissOnPausefalsebooleanSet whether the picker dismisses itself when the parent Activity is paused or whether it recreates itself when the Activity is resumed.(android only)
enableSecondsfalsebooleanAllows you to enable or disable a seconds and minutes picker on the TimepickerDialog. Enabling the seconds picker, implies enabling the minutes picker. Disabling the minute picker will disable the seconds picker. The last applied setting will be used. By default enableSeconds = false and enableMinutes = true..(android only)
enableMinutestruebooleanAllows you to enable or disable a minutes on the TimepickerDialog. (android only)
showYearPickerFirstfalsebooleanShow the year picker first, rather than the month and day picker.. (android only)
scrollOrientation'horizontal'stringDetermines whether months scroll Horizontal or Vertical. Defaults to Horizontal for the v2 layout and Vertical for the v1 layout (android only)
disabledTimes-arrayYou can pass in an array of objects, each object contains hour limiter minute and or seconds limiter. These values will not be available for selection. (android only)
customStyles-objectThe hook of customize datepicker style, same as the native style. dateTouchBody, dateInput...
hideTextfalsebooleanhides the displayed date/Time
disabledfalsebooleanDisable date/Time picker button
is24Hour-booleanSet the TimePicker is24Hour flag. The default value depend on format.
allowFontScalingtruebooleanSet to false to disable font scaling for every text component.
placeholder''stringThe placeholder show when this.props.date is falsy
onDateChange-functionThis is called when the user confirm the picked date or time in the UI. The first and only argument is a date or time string representing the new date and time formatted by moment.js with the given format property.
onOpenModal-functionThis is called when the DatePicker Modal opens. (ios only)
onCloseModal-functionThis is called when the DatePicker Modal closes. (ios only)
onPressMask-functionThis is called when clicking the ios modal mask. (ios only)
TouchableComponentTouchableHighlightComponentReplace the TouchableHighlight with a custom Component. For example : TouchableOpacity
getDateStr-FunctionA function to override how to format the date into a String for display, receives a Date instance

Property customStyles available keys

  • appearance: dateInput, disabled, dateTouchBody, placeholderText, dateText
  • ios select panel: datePickerCon, datePicker, btnConfirm, btnTextConfirm, btnCancel, btnTextCancel

Instance Methods

MethodParamsDescription
onConfirm-Manually open the date picker panel
onCancel-Manually close the date picker panel like, similarly pressing cancel btn

Usage

import TimePicker from "react-native-navybits-date-time-picker";

 <TimePicker
          accentColor={this.state.accentColor}
          okColor={this.state.okColor}
          cancelColor={this.state.cancelColor}
          okText={"OK"}
          cancelText={"CANCEL"}
          mode={this.state.mode}
          is24Hour={this.state.is24Hour}
          disabled={this.state.disabled}
          onConfirm={this._handleDatePicked}
          onCancel={this._hideDateTimePicker}
          date={this.state.selectedDate}
          ref="TimePicker"
        />
1.2.3

4 years ago

1.2.2

4 years ago

1.2.0

4 years ago

1.2.1

4 years ago

1.1.9

5 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago