1.2.2 • Published 7 years ago

react-native-calendar-datepicker v1.2.2

Weekly downloads
119
License
Apache-2.0
Repository
github
Last release
7 years ago

React Native Calendar Datepicker

Description

This project aims at providing developers with a cross-platform, highly customizable, calendar date picker component for React Native.

Here is a quick example of how it works, with custom appearance:

alt text

Installation

npm install --save react-native-calendar-datepicker

Minimum react-native: "^0.33.0"

Basic Usage

Getting started with this component is very very easy. However, the initial appearance is minimalistic, but the library offers the developer the ability to easily customize it.

In its most basic form, the usage of this component looks like this:

import Calendar from 'react-native-calendar-datepicker';
import Moment from 'moment';

...

  <Calendar
    onChange={(date) => this.setState({date})}
    selected={this.state.date}
    // We use Moment.js to give the minimum and maximum dates.
    minDate={Moment().startOf('day')}
    maxDate={Moment().add(10, 'years').startOf('day')}
    />

API Reference

Note: Each date provided will be a Moment.js object.

Basic properties

PropertyTypeExplanation
selectedMomentThe currently selected date
onChange(date: Moment) => voidCallback for selecting a date
minDateMomentMandatory Minimum selectable date
maxDateMomentMandatory Maximum selectable date
startStage"day"/"month"/"year"Default: "day" Whether you would like to select the day, month or year first.
finalStage"day"/"month"/"year"Default: "day" The last level of selection you want.
slideThresholdnumber[Default: min(width / 3, 250)] The number of pixels after which the slide event will be triggered.
showArrowsbooleanDefault: false Whether you would like to show arrow buttons for moving between months.

Locale specific calendar

In order to change the locale of the calendar, just change the locale of Moment.js. Please make sure to do so before using the calendar component.

Styling properties

In its initial form the component has a minimalistic appearance, shown in the picture below, but it can easily be customized.

Styled example with arrows:

Below is the list of properties that can be used for styling. For a concrete example, check out the demo app link

PropertyTypeExplanation
styleView.propTypes.styleView wrapper of the calendar
barViewView.propTypes.styleStyling the view wrapper for the bar at the top of the component
barTextText.propTypes.styleStyling the text in the top bar
stageViewView.propTypes.styleStyling the view wrapper of the current stage
dayHeaderViewView.propTypes.styleStyling the view wrapper of day names
dayHeaderTextText.propTypes.styleStyling the text of day names
dayRowViewView.propTypes.styleStyling each row view of days
dayViewView.propTypes.styleView wrapper of each day
dayTextText.propTypes.styleStyling the text of each day number
dayTodayTextText.propTypes.styleHighlighting today in the calendar
daySelectedTextText.propTypes.styleHighlighting the selected day in the calendar
dayDisabledTextText.propTypes.styleStyling unavailable dates in the calendar
monthTextText.propTypes.styleStyling the text for each month in the month selector
monthDisabledTextText.propTypes.styleStyling unavailable months
monthSelectedTextText.propTypes.styleStyling selected month
yearMinTintColorstringStyling left side of year slider
yearMaxTintColorstringStyling right side of year slider
yearSliderSlider.propTypes.styleStyling the year slider
yearTextText.propTypes.styleStyling the year text

TODO

  • Add unit tests
  • Add integration test
  • Set up continous integration
  • Hook to codeclimate.com

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Credits

Main Developer: Vlad-Doru Ion

Pull requests by:

License

Apache License 2.0

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.2

7 years ago

1.1.1

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago