Giter Site home page Giter Site logo

kcalendar-view's Introduction

KCalendar-View

Modern calendar view supporting both Hijri and Gregorian calendars but in highly dynamic way

LinkedIn License: MIT JitPack

Features

  • Supporting multi locale mainly [EN, AR]
  • Supporting both [Hijri, Gregorian] calendars
  • Java time used in dates conversion
  • Day view binder
  • Month view binder
  • 100% Kotlin

Getting Started

Instillation

Add the JitPack repository to your project level build.gradle:

allprojects {
 repositories {
    google()
    jcenter()
    maven { url "https://jitpack.io" }
 }
}

Add CalendarView to your app build.gradle:

dependencies {
	implementation 'com.github.nLoops:KCalendar-View:<latest-version>'
}

How to use it

Step One

Adding view to XML with starter attrs

        <com.thebluekernel.calendar.library.data.ui.monthlist.KCalendarView
            android:id="@+id/calendarView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:cal_WeekTextStyle="@style/Widget.Calendar.Week.Text"
            app:cal_calendarMaxYear="2022"
            app:cal_calendarMinYear="2021"
            app:cal_calendarStartOfWeek="sunday"
            app:cal_calendarType="gregorian"
            app:cal_dayViewRes="@layout/item_day_layout"
            app:cal_locale="en"
            app:cal_monthViewRes="@layout/item_month_res_layout"
            app:cal_scrollDirection="horizontal" />

Define your item cell xml

    <TextView
        android:id="@+id/dayTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:includeFontPadding="false"
        android:padding="4dp"
        android:textAlignment="center"
        android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
        tools:text="22" />

Define your month header xml

    <TextView
        android:id="@+id/tvMonthName"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:gravity="center"
        android:textAlignment="center"
        android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@id/btnArrowNext"
        app:layout_constraintStart_toEndOf="@id/btnArrowPrev"
        app:layout_constraintTop_toTopOf="parent"
        tools:text="Nov 2019" />

Step Two

Conform binders contract for both Day and Month

        val dayBinder = object : CalendarDayBinder<DayViewContainer> {
            override fun create(view: View) = DayViewContainer(view)

            override fun bind(holder: DayViewContainer, day: CalendarDay) {
              // handle your logic here
            }

        }
        val monthBinder = object : CalendarMonthBinder<MonthViewContainer> {
            override fun create(view: View) = MonthViewContainer(view)

            override fun bind(holder: MonthViewContainer, month: CalendarMonth) {
              // handle month logic here
            }

        }
  // assign binders to calendar view
  calendarView.dayBinder = dayBinder
  calendarView.monthBinder = monthBinder

You can refer to demo projcet examples for practical usage.

Screenshots

Demo app screenshots

TODO

  • Range date selection.
  • Week row.
  • Multi-date selection.
  • Async setup for better performance especially into big range of dates.

Contribution

Feel free to fork project and do your changes, but don't forget to leave a start _

kcalendar-view's People

Contributors

nloops avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

joeyoggie

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.