Giter VIP home page Giter VIP logo

react-native-month-view-calendar's Introduction

version downloads

@iftek/react-native-month-view-calendar

React Native Month View Calendar

ย 

Install

npm install --save @iftek/react-native-month-view-calendar

Basic usage

import React from 'react';
import MonthViewCalendar from '@iftek/react-native-month-view-calendar';
import { View, ScrollView } from 'react-native'

const Component = () => {
  const eventsForCalendar = [
  	{
  	  title: 'My awesome event',
  	  date: new Date(),
  	},
  ];

  return (
    <ScrollView>
      <MonthViewCalendar
        cellStyles={{ minHeight: 65 }}
        events={eventsForCalendar}
        renderEvent={(event, i) => {
          return (
            <Text key={i} numberOfLines={1}>{event.title}</Text>
          )
        }}
      />
    </ScrollView>
  );
}

Props

Properties Default type Description
date new Date() Date from which the calendar will be built
dayTextStyles {} TextStyle | (day:Date) => TextStyle Styles for label day(numer of day), can be function, array or object
todayTextStyles {} Styles for label day(today), can be array or object
otherMonthsDayTextStyles {} Styles for label day(numer of day) other months, can be array or object
otherMonthsEnabled false other months day cell onPress enabled or not
events Array of events
headerTextStyles {} Styles for label week day name, can be array or object
cellStyles {} ViewStyle | (day:Date) => ViewStyle Styles for all cells, can be function, array or object
pastMonthsCellStyles {} Styles for all cells from past dates
weekDays ['S', 'M', 'T', 'W', 'T', 'F', 'S'] Array with name of the day of the week
renderEvent Function required to render event information. Example (event, index) =>
onPress Callback when day cell is pressed
onSwipe Callback when calendar is swiped
onSwipePrev Callback when calendar is swiped to previous month
onSwipeNext Callback when calendar is swiped to next month
onScrollToIndexFailed Callback to handle errors on swipe

Methods

To use the component methods save a reference to it:

const reference = useRef();

<MonthViewCalendar
  ref={reference}
/>
  • goToDate(date): the component navigates to a custom date, date variable must be an instance of Date. Example: reference.current.goToDate(new Date());
  • getCurrentDate() returns current date that being displayed

Event object

{
  /// your props
  date: new Date(),
}

react-native-month-view-calendar's People

Contributors

yuan9090 avatar ivanaquino avatar strappberry avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.