8.3.1 • Published 2 years ago

react-native-months-years-selector v8.3.1

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

react-native-month-selector

This package lets you select months. It also allows you to use swipe gestures to navigate between pages.

Install

npm install react-native-month-selector --save
yarn add react-native-month-selector

Props

ParamsTypeDefaultDescription
selectedDatemoment.Moment (a valid moment.js instance)moment()currently highlighted / selected month
currentDatemoment.Momentmoment()today's date
maxDatemoment.Momentmoment()the maximum date than can be shown
minDatemoment.Momentmoment("01-01-2000", "DD-MM-YYYY")the mimimum date than can be shown
selectedBackgroundColorstring"#000"the color of the highlight for the seleced month
selectedMonthTextStyleTextStyle{ color: "#fff" }text style for the selected month
seperatorHeightnumber1height of the separators
seperatorColorstring"#b6c3cb"color of the separators
nextIconJSX.Elementnullcustom react component for the next button
prevIconJSX.Elementnullcustom react component for the prev button
nextTextstring"Next"custom text for the next button
prevTextstring"Prev"custom text for the prev button
containerStyleViewStylenullcustom style for the container
yearTextStyleTextStylenullcustom style for the year text
monthTextStyleTextStylenullcustom style of the text for the months
currentMonthTextStyleTextStylenullcustom style for the current month text
initialViewmoment.Momentmoment()which month should be selected initially
onMonthTapped(month: moment.Moment) => any(month) => {}function called when month is pressed
onYearChanged(year: moment.Moment) => any(year) => {}function called when the year is changed (when we navigate pages)
monthDisabledStyleTextStyle{ color: "#00000050" }text style for disabled months
localeLanguagestring"en"specify the localization language for moment.js
localeSettingsmoment.LocaleSpecification{}to update the moment.js localization settings
swipablebooleanfalseenables swiping between pages
velocityThresholdnumber0.3Velocity that has to be breached in order for swipe to be triggered (vx and vy properties of gestureState)
directionalOffsetThresholdnumber80Absolute offset that shouldn't be breached for swipe to be triggered (dy for horizontal swipe, dx for vertical swipe)
gestureIsClickThresholdnumber5Absolute distance that should be breached for the gesture to not be considered a click (dx or dy properties of gestureState)

Sample Usage

import MonthSelectorCalendar from 'react-native-month-selector'; //add this import line

  <View style={styles.container}>
      <Text style={styles.welcome}>
        Selected Month is { this.state.month && this.state.month.format('MMM YYYY')}
      </Text>
      <MonthSelectorCalendar
          selectedDate={this.state.month}
          onMonthTapped={(date) => this.setState({ month: date })} 
      />
    </View>

Month Calendar

I'm open to keep this updated. Please open PRs!

Contributors

  • Nabil Cambiaso
  • Nouhaila Jellouli
  • Said Gouzal