3.1.1 • Published 4 years ago

react-native-persian-calendar-picker v3.1.1

Weekly downloads
40
License
MIT
Repository
github
Last release
4 years ago

React Native Jalaali (Persian) Calendar

NPM Version Build Status

This is a Jalaali (Persian) Calendar Picker Component for React Native

The package is both Android and iOS compatible.

Installation

$ yarn add react-native-persian-calendar-picker

or

$ npm install react-native-persian-calendar-picker --save

Prerequisites

CalendarPicker requires Moment JS. Date props may be anything parseable by Moment: Javascript Date, Moment date, or ISO8601 datetime string.

Usage

How to use it:

import React from 'react';
import {
  StyleSheet,
  Text,
  View,
} from 'react-native';
import PersianCalendarPicker from 'react-native-persian-calendar-picker';

class PersianCalendarPickerExample extends React.Component {
  constructor(props) {
		super(props);

    this.state = {
      selectedStartDate: null,
    };

		this.onDateChange = this.onDateChange.bind(this);
  }

  onDateChange(date) {
    this.setState({ selectedStartDate: date });
  }

  render() {
    const { selectedStartDate } = this.state;
    const startDate = selectedStartDate ? selectedStartDate.toString() : '';
    return (
      <View style={styles.container}>

        <PersianCalendarPicker
          onDateChange={this.onDateChange}
				/>

        <View>
          <Text>SELECTED DATE:{ startDate }</Text>
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#FFFFFF',
    marginTop: 100,
  },
});

PersianCalendarPicker props

PropTypeDescription
isRTLBooleanOptional. Force layout to be RTL. Default is false
weekdaysArrayOptional. List of week days. Eg. ['Sat', 'Sun', ...] Must be 7 days
monthsArrayOptional. List of months names. Eg. ['Farvardin', 'Ordibehesht', ...] Must be 12 months
allowRangeSelectionBooleanOptional. Allow to select date ranges. Default is false
previousTitleStringOptional. Title of button for previous month. Default is Previous
nextTitleStringOptional. Title of button for next month. Default is Next
selectedDayColorStringOptional. Color for selected day
selectedDayStyleViewStyleOptional. Style for selected day. May override selectedDayColor.
selectedDayTextColorStringOptional. Text color for selected day
selectedRangeStartStyleViewStyleOptional. Style for range selected start day.
selectedRangeEndStyleViewStyleOptional. Style for range selected end day.
selectedRangeStyleViewStyleOptional. Style for all days in range selection.
disabledDatesArray or FunctionOptional. Specifies dates that cannot be selected. Array of Dates, or a function that returns true for a given Moment date (apologies for the inverted logic).
selectedStartDateDateOptional. Specifies a selected Start Date.
selectedEndDateDateOptional. Specifies a selected End Date.
minRangeDurationNumber or ArrayOptional. Specifies a minimum range duration when using allowRangeSelection. Can either pass a number to be used for all dates or an Array of objects if the minimum range duration depends on the date {date: Moment-parsable date, minDuration: Number
maxRangeDurationNumber or ArrayOptional. Specifies a maximum range duration when using allowRangeSelection. Can either pass a number to be used for all dates or an Array of objects if the maximum range duration depends on the date {date: Moment-parsable date, maxDuration: Number
todayBackgroundColorStringOptional. Background color for today. Default is #cccccc
todayTextStyleTextStyleOptional. Text styling for today.
textStyleObjectOptional. Style overall text. Change fontFamily, color, etc.
customDatesStylesArrayOptional. Style individual date(s). Array of objects {date: Moment-parseable date, containerStyle: ViewStyle, style: ViewStyle, textStyle: TextStyle}
scaleFactorNumberOptional. Default (375) scales to window width
minDateDateOptional. Specifies minimum date to be selected
maxDateDateOptional. Specifies maximum date to be selected
initialDateDateOptional. Date that calendar opens to. Defaults to today.
widthNumberOptional. Width of CalendarPicker's container. Defaults to Dimensions width.
heightNumberOptional. Height of CalendarPicker's container. Defaults to Dimensions height.
swipeConfigObjectOptional. Config passed to Swiper.
enableSwipeBooleanOptional. Whether to enable swiping. Default is true
enableDateChangeBooleanOptional. Whether to enable pressing on day. Default is true
onDateChangeFunctionOptional. Callback when a date is selected. Returns Moment date as first parameter.
onMonthChangeFunctionOptional. Callback when Previous / Next month is pressed. Returns Moment date as first parameter.
onSwipeFunctionOptional. Callback when swipe event is triggered. Returns swipe direction as first parameter.
dayShapeStringOptional. Shape of the Day component. Default is circle. Available options are circle and square.
headingLevelNumberOptional. Sets the aria-level for the calendar title heading when on Web. Default is 1.

Styles

Some styles will overwrite some won't. For instance:

  • If you provide textStyle with fontFamily and color, out of ranges dates will not apply your color, just fontFamily.

Order of precedence:

  • defaultColor => textStyle => selectedDayColor
  • defaultTodayBackgroundColor => todayBackgroundColor
  • defaultBackgroundColor => selectedDayColor
  • defaultTextStyles => textStyle => selectedDayTextColor

Suggestions?

Open Issues. Submit PRs.

3.1.1

4 years ago

3.1.0

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

8 years ago