1.0.8 • Published 5 years ago

@payal_maniyar/react-native_datetimepicker v1.0.8

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

@payal_maniyar/react-native_datetimepicker

npm (scoped) npm bundle size (minified)

Removes all spaces from a string.

Install

$ npm install @payal_maniyar/react-native_datetimepicker

Usage

import DateTimePicker from '@payal_maniyar/react-native_datetimepicker';

 <DateTimePicker
        style = {
          {
            width: '100%',
            marginBottom: 8
          }
        }
        mode = "datetime" //{"datetime"}
        placeholder = "Pick a Date"
        format = "DD/M/YYYY HH:mm a"
        date = {
          this.state.date
        }
        minDate = {
          moment().add(10, 'years').format("DD/M/YYYY HH:mm a")
        }
        maxDate = {
          moment().subtract(10, 'years').format("DD/M/YYYY HH:mm a")
        }
        confirmBtnText = "Done"
        cancelBtnText = "Cancel"
        customStyles = {
          {
            dateIcon: {
              position: 'absolute',
              right: 0,
              marginLeft: 0
            },
            dateInput: {
              marginRight: 36,
              borderRadius: 5,
            }
            // ... You can check the source to find the other keys.
          }
        }
        onDateChange = {
          (date) =>
          this.setState({
            date: date
          })
        }

        />

Properties

PropDefaultTypeDescription
style-objectSpecify the style of the DateTimePicker container, eg. width, height,backgroundColor etc...
date-string | date | Moment instanceSpecify the display date of DatePicker. string type value must match the specified format
mode'date'enumThe enum of date, datetime and time
androidMode'default'enumThe enum of default, calendar and spinner (only Android)
format'YYYY-MM-DD'stringSpecify the display format of the date, which using moment.js. The default value change according to the mode.
confirmBtnText'确定'stringSpecify the text of confirm btn in ios.
cancelBtnText'取消'stringSpecify the text of cancel btn in ios.
iconSource-{uri: string} | numberSpecify the icon. Same as the source of Image, always using require()
minDate-string | dateRestricts the range of possible date values.
maxDate-string | dateRestricts the range of possible date values.
duration300numberSpecify the animation duration of datepicker.
customStyles-objectThe hook of customize datepicker style, same as the native style. dateTouchBody, dateInput...
showIcontruebooleanController whether or not show the icon
hideTextfalsebooleanController whether or not show the dateText
iconComponent-elementSet the custom icon
disabledfalsebooleanController whether or not disable the picker
is24Hour-booleanSet the TimePicker is24Hour flag. The default value depend on format. Only work in Android
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 open.
onCloseModal-functionThis is called when the DatePicker Modal close
onPressMask-functionThis is called when clicking the ios modal mask
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, dateIcon, placeholderText, dateText
  • ios select panel: datePickerCon, datePicker, btnConfirm, btnTextConfirm, btnCancel, btnTextCancel

Instance Methods

MethodParamsDescription
onPressDate-Manually open the date picker panel
onPressCancel-Manually close the date picker panel like, similarly pressing cancel btn