Giter VIP home page Giter VIP logo

xiangyutian / eventscalendar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tizisdeepan/eventscalendar

0.0 0.0 0.0 986 KB

Events Calendar is a user-friendly library that helps you achieve a cool Calendar UI with events mapping. You can customise every pixel of the calendar as per your wish and still achieve in implementing all the functionalities of the native android calendar in addition with adding dots to the calendar which represents the presence of an event on the respective dates. It can be done easily, you are just a few steps away from implementing your own badass looking Calendar for your very own project!

License: Apache License 2.0

Kotlin 98.70% Java 1.30%

eventscalendar's Introduction

Events Calendar

License

Single Selection Mode Range Selection Mode Multiple Selection Mode
Single Selection Mode Range Selection Mode Multiple Selection Mode

What is Events Calendar?

Events Calendar is a user-friendly library that helps you achieve a cool Calendar UI with events mapping. You can customise every pixel of the calendar as per your wish and still achieve in implementing all the functionalities of the native android calendar in addition with adding dots to the calendar which represents the presence of an event on the respective dates. Events Calendar also has multi-lingual support. You are just a few steps away from implementing your own badass looking Calendar for your very own project!

Implementation

[1] In your app module gradle file

dependencies {
    implementation 'com.github.tizisdeepan:eventscalendar:1.5.2'
}

[2] In your project level gradle file

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

[3] Use EventsCalendar in your layout.xml

<com.events.calendar.views.EventsCalendar
    android:id="@+id/eventsCalendar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#000000"
    android:overScrollMode="never"
    app:eventDotColor="#ff0000"
    app:isBoldTextOnSelectionEnabled="true"
    app:monthTitleColor="#ffffff"
    app:primaryTextColor="#c4c4c4"
    app:secondaryTextColor="#666666"
    app:selectedTextColor="#000000"
    app:selectionColor="#ffe600"
    app:weekHeaderColor="#c6c6c6"
    app:rangeSelectionColor="#ffe600"
    app:rangeSelectionStartColor="#c1ae01"
    app:rangeSelectionEndColor="#c1ae01" />

[4] Implement EventCalendar.Callback on your Activity/ Fragment

class MainActivity : AppCompatActivity(), EventsCalendar.Callback {
    ...
    override fun onDayLongPressed(selectedDate: Calendar?) {
        Log.e("LONG", "CLICKED")
    }
    
    override fun onMonthChanged(monthStartDate: Calendar?) {
        Log.e("MON", "CHANGED")
    }

    override fun onDaySelected(selectedDate: Calendar?) {
        Log.e("SHORT", "CLICKED")
    }
}

[5] Create instances and set default values for the EventsCalendar in your Activity/ Fragment

//set today's date [today: Calendar]
eventsCalendar.setToday(today)
//set starting month [start: Calendar] and ending month [end: Calendar]
eventsCalendar.setMonthRange(start, end)
//set start day of the week as you wish [startday: Int, doReset: Boolean]
eventsCalendar.setWeekStartDay(Calendar.SUNDAY, false)
//set current date and scrolls the calendar to the corresponding month of the selected date [today: Calendar]
eventsCalendar.setCurrentSelectedDate(today)
//set font for dates
eventsCalendar.setDatesTypeface(typeface)
//set font for title of the calendar
eventsCalendar.setMonthTitleTypeface(typeface)
//set font for week names
eventsCalendar.setWeekHeaderTypeface(typeface)
//set the callback for EventsCalendar
eventsCalendar.setCallback(this)
//set events on the EventsCalendar [c: Calendar]
eventsCalendar.addEvent(c)
//disable a specific day on the EventsCalendar [c: Calendar]
eventsCalendar.disableDate(dc)
//disable days in a week on the whole EventsCalendar [varargs days: Int]
eventsCalendar.disableDaysInWeek(Calendar.SATURDAY, Calendar.SUNDAY)

[6] You can change selection mode of the calendar as you wish

eventsCalendar.setSelectionMode(eventsCalendar.SINGLE_SELECTION)

Available Selection modes are,

  1. SINGLE_SELECTION -> can select single day at a time
  2. RANGE_SELECTION -> can select range of days at a time
  3. MULTIPLE_SELECTION -> can select multiple days at a time (not necessary that the selected days be consequtive)

Documentation

XML Kotlin/Java Description
app:primaryTextColor setPrimaryTextColor(color: Int) Primary Text color of the calendar (selectable dates)
app:secondaryTextColor setSecondaryTextColor(color: Int) Secondary Text color of the calendar (disabled dates)
app:selectedTextColor setSelectedTextColor(color: Int) Text color of the Selected date
app:selectionColor setSelectionColor(color: Int) Color for the Selection Circle
app:rangeSelectionColor setRangeSelectionColor(color: Int) Color for the Selection Background
app:rangeSelectionStartColor setRangeSelectionStartColor(color: Int) Color for the Range Start Selection Background
app:rangeSelectionEndColor setRangeSelectionEndColor(color: Int) Color for the Range End Selection Background
app:weekHeaderColor setWeekHeaderColor(color: Int) Text color for the Week Header labels
app:monthTitleColor setMonthTitleColor(color: Int) Text color for the Month Title in the calendar view
app:eventDotColor setEventDotColor(color: Int) Color for the Event Dots marked in the calendar view
app:isBoldTextOnSelectionEnabled setIsBoldTextOnSelectionEnabled(isEnabled: Boolean) Sets whether the dates should be highlighted or not

Voila! You have implemented an awesome Events Calendar for your Android Project now!

Developed By

Follow me on Twitter Add me to Linkedin

eventscalendar's People

Contributors

tizisdeepan avatar deepan5901 avatar antoxa2584x 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.