0.0.3 • Published 3 months ago

react-native-ethiopian-calendar-date-picker v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

React Native Ethiopian Calendar

A react native calendar component which is mainly intended for applications which require Ethiopian calendar.

Features

  • Ethiopian/Gregorian mode toggle
  • Supports multiple local languages
  • Supports month and year selection
  • Supports minimum date selection
  • Easy to customize
  • Zero dependency
  • Fully typed with typescript

Newly Added Features

  • Month and year picker Modal
  • min and max Date

Demo

npm.io

Installation

with yarn

yarn add react-native-ethiopian-calendar

Install with npm

npm i react-native-ethiopian-calendar

Usage/Examples

Typescript Example

import {
  Calendar,
  LanguageCode,
  Mode,
  SelectedDate,
} from 'react-native-ethiopian-calendar';

function App() {
  const [mode, setMode] = React.useState<Mode>('EC');
  const [locale, setLocale] = React.useState<LanguageCode>('AMH');
  const [selectedDate, setSelectedDate] = React.useState<SelectedDate>();

  const maxDate = {
      year: today.getFullYear() + 18,
      month: today.getMonth() + 1,
      day: today.getDate(),
  }

  const minDate = {
      year: today.getFullYear() - 18,
      month: today.getMonth() + 1,
      day: today.getDate(),
  }

  return (
      <Calendar
        mode={mode}
        onDatePress={(date) => setSelectedDate(date)}
        onModeChange={(selectedMode) => setMode(selectedMode)}
        onLanguageChange={(lang) => setLocale(lang)}
        locale={locale}
        maxDate={maxDate}
        minDate={minDate}
      />
  )
}

Javascript Example

import { Calendar } from 'react-native-ethiopian-calendar';

function App() {
  const [mode, setMode] = React.useState('EC');
  const [locale, setLocale] = React.useState('AMH');
  const [selectedDate, setSelectedDate] = React.useState();

  return (
    <Calendar
      mode={mode}
      onDatePress={(date) => setSelectedDate(date)}
      onModeChange={(selectedMode) => setMode(selectedMode)}
      onLanguageChange={(lang) => setLocale(lang)}
      locale={locale}
      maxDate={maxDate}
      minDate={minDate}
    />
  );
}

API Reference

PropTypeRequiredDescriptionDefault
modeModefalsea prop to switch b/n Ethiopian calendar and Gregorian calendarEC
localeLanguageCodefalseto change the language of days names and months names.AMH for EC and ENG for GC
themeThemefalseto override default style{}
hideHeaderButtonsbooleanfalseto hide switch mode & change language dropdowns.false
onDatePressfunction voidtruean event handler gets executed when date press event is fired.
onModeChangefunction voidfalsean event handler gets invoked on mode change.
onLanguageChangefunction voidfalsean event handler gets invoked on language change.
initialDateDatefalseif this prop is not set, the calendar will start from current month.today
minDateDatefalseto give minimum selectable date and date below the given will not be selectable.
maxDateDatefalseto give maximum selectable date and date above the given will not be selectable.

License

MIT

Made with create-react-native-library