1.1.1 • Published 3 years ago

react-native-ep-calendar v1.1.1

Weekly downloads
175
License
MIT
Repository
github
Last release
3 years ago

react-native-ep-calendar

1. Installation

react-native-ep-calendar requires react-native >= 0.63.4. It also uses react-native-svg to display icons. To install simply run

npm install react-native-ep-calendar

in your project. For iOS you need to install the pods:

cd ios && pod install && cd ..

2. Usage

The Calendar component takes some parameters, but they are all optional.

PropertyDescriptionDefault
darkThemeA style object defining the dark theme. See 4. Themes.null (predefined style).
lightThemeA style object defining the light theme. See 4. Themes.null (predefined style).
localizationCurrently unusednull
markedDatesArray of Objects containing a date property and a markerType as stringtoday with default marker
markerTypesArray of Objects containing a string property markerType as identifier and a style objectempty array
maxDateMax date the user can see.null
minDateMin date the user can seenull
onDayLongPressCallback for a long press on a daynull
onDayPressCallback for a normal press on a daynull
onMonthChangeListenerCallback when changing the displayed month & yearnull
startDateStarting date of the calendar componenttoday
useDarkModeDarkmode for calendar allowed?true

2.1 markedDates

Needs an array of objects containing a date and a markerType, for example:

let markedDates = [
  {
    date: new Date(Date.now()),
    markerType: 'myMarker'
  },
];

2.2 markerTypes

Needs an array of objects containg a markerType and some style objects:

let markerTypes = [
  {
    markerType: 'myMarker',
    markerTextStyle: {color: 'red'}.
    markerTouchableStyle = {backgroundColor: 'transparent'},
    markerColumnStyle = null
  },
];

2.3 onMonthChangeListener

This callback gets fired, when the users changes the displayed month. The callback receives four parameters: 1. previousMonth 2. previousYear 3. month 4. year

In our example that callback is used to load the data for the new month.

3. Example

An example with some properties set:

                <Calendar
                  markerTypes={[missMarker]}
                  markedDates={[...checkedMarker, ...missedMarkers]}
                  darkTheme={{
                    markerColor: habit.Color,
                    markerTextColor: getTextColorForBgHex(habit.Color),
                  }}
                  lightTheme={{
                    markerColor: habit.Color,
                    markerTextColor: getTextColorForBgHex(habit.Color),
                  }}
                  onMonthChangeListener={(
                    previousMonth,
                    previousYear,
                    month,
                    year,
                  ) => {
                    getTimelineData(
                      habit,
                      month,
                      year,
                      setCheckedMarker,
                      setMissedMarker,
                    );
                  }}
                />          

alt text

4. Themes

5. License

This component is licensed under MIT