All Projects → CleverPumpkin → Crunchycalendar

CleverPumpkin / Crunchycalendar

Licence: mit
A beautiful material calendar with endless scroll, range selection and a lot more!

Programming Languages

java
68154 projects - #9 most used programming language
kotlin
9241 projects

Projects that are alternatives of or similar to Crunchycalendar

Material Calendar View
📅 Material Design Calendar compatible with API 11+
Stars: ✭ 360 (-22.58%)
Mutual labels:  material-design, custom-view, calendar, calendar-view
Primedatepicker
PrimeDatePicker is a tool that provides picking a single day, multiple days, and a range of days.
Stars: ✭ 292 (-37.2%)
Mutual labels:  material-design, calendar, calendar-view
Peppy Calendarview
Simple and fast Material Design calendar view for Android.
Stars: ✭ 30 (-93.55%)
Mutual labels:  custom-view, calendar, calendar-view
Timetable
📅 Customizable flutter calendar widget including day and week views
Stars: ✭ 140 (-69.89%)
Mutual labels:  material-design, calendar, calendar-view
Android Week View
Android Week View is an android library to display calendars (week view or day view) within the app. It supports custom styling.
Stars: ✭ 3,347 (+619.78%)
Mutual labels:  custom-view, calendar, calendar-view
Cvcalendar
A custom visual calendar for iOS 8+ written in Swift (>= 4.0).
Stars: ✭ 3,435 (+638.71%)
Mutual labels:  custom-view, calendar, calendar-view
Bluetooth State View
Material design animated Bluetooth state view for Android
Stars: ✭ 36 (-92.26%)
Mutual labels:  material-design, custom-view
Etar Calendar
Android open source calendar
Stars: ✭ 1,051 (+126.02%)
Mutual labels:  material-design, calendar
Battery Meter View
🔋 Material design battery meter (i.e. level, state) view for Android
Stars: ✭ 57 (-87.74%)
Mutual labels:  material-design, custom-view
GCCalendar
A customizable calendar view for iOS 9+ written in Swift.
Stars: ✭ 53 (-88.6%)
Mutual labels:  calendar, calendar-view
Customizablecalendar
CustomizableCalendar is a library that allows you to create your calendar, customizing UI and behaviour
Stars: ✭ 214 (-53.98%)
Mutual labels:  calendar, calendar-view
Devextreme Reactive
Business React components for Bootstrap and Material-UI
Stars: ✭ 1,800 (+287.1%)
Mutual labels:  material-design, calendar
CalendarView
日历控件
Stars: ✭ 14 (-96.99%)
Mutual labels:  calendar, calendar-view
React Material Calendar
React component inspired by google calendar app.
Stars: ✭ 25 (-94.62%)
Mutual labels:  material-design, calendar
Calendarview
An Easy to Use Calendar for iOS (Swift 5.0)
Stars: ✭ 429 (-7.74%)
Mutual labels:  calendar, calendar-view
Supercalendar
@deprecated android 自定义日历控件 支持左右无限滑动 周月切换 标记日期显示 自定义显示效果跳转到指定日期
Stars: ✭ 2,732 (+487.53%)
Mutual labels:  calendar, calendar-view
Jzcalendarweekview
Calendar Week & Day View in iOS Swift
Stars: ✭ 272 (-41.51%)
Mutual labels:  calendar, calendar-view
Android Week Calendar
android可自定义日历方案,支持农历、自定义日历控件、排班、左右滑动、周月切换、跳转到指定日期等功能
Stars: ✭ 186 (-60%)
Mutual labels:  calendar, calendar-view
Eventscalendar
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!
Stars: ✭ 188 (-59.57%)
Mutual labels:  calendar, calendar-view
Tableview
TableView is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells.
Stars: ✭ 2,928 (+529.68%)
Mutual labels:  material-design, custom-view

alt text

CrunchyCalendar

A light, powerful and easy to use Calendar Widget with a number out of the box features:

  • Infinite vertical scrolling in both directions;
  • Setting date boundaries to restrict scrolling inside of a specific time period;
  • Single / multiple / range dates selection;
  • Pre-selecting dates;
  • Color customization;
  • Displaying color indicators;
  • Setting own custom ItemDecoration;
  • Presented as a View subclass which can be displayed everywhere: in Activity, Fragment or Dialog, or can be integrated into another custom View.

alt text

Dependency

This library is available on jCenter. jCenter is the default Maven repository used by Android Studio. Download

Gradle

implementation 'ru.cleverpumpkin:crunchycalendar:2.0.0'

Maven

<dependency>
  <groupId>ru.cleverpumpkin</groupId>
  <artifactId>crunchycalendar</artifactId>
  <version>2.0.0</version>
  <type>pom</type>
</dependency>

Usage

Here's a basic example of Calendar usage.

First of all, you should declare CalendarView in your layout XML file.

  <ru.cleverpumpkin.calendar.CalendarView 
        android:id="@+id/calendar_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

Perform Calendar setup in your Activity or Fragment class.

val calendarView = view.findViewById(R.id.calendar_view)
val calendar = Calendar.getInstance()

// Initial date
calendar.set(2018, Calendar.JUNE, 1)
val initialDate = CalendarDate(calendar.time)

// Minimum available date
calendar.set(2018, Calendar.MAY, 15)
val minDate = CalendarDate(calendar.time)

// Maximum available date
calendar.set(2018, Calendar.JULY, 15)
val maxDate = CalendarDate(calendar.time)

// List of preselected dates that will be initially selected
val preselectedDates: List<CalendarDate> = getPreselectedDates()

// The first day of week
val firstDayOfWeek = java.util.Calendar.MONDAY

// Set up calendar with all available parameters
calendarView.setupCalendar(
    initialDate = initialDate, 
    minDate = minDate,
    maxDate = maxDate,
    selectionMode = SelectionMode.NONE,
    selectedDates = preselectedDates,
    firstDayOfWeek = firstDayOfWeek,
    showYearSelectionView = true
)
                

Note: all parameters in setupCalendar() method are optional and have default values.

To handle date click / long click with custom action, you can do this:

// Set date click callback 
calendarView.onDateClickListener = { date ->

    // Do something ... 
    // for example get list of selected dates
    val selectedDates = calendarView.selectedDates 
}

// Set date long click callback 
calendarView.onDateLongClickListener = { date ->

    // Do something ... 
}

Saving and Restoring state

Calendar takes care of saving and restoring its internal state (selected dates, selection mode, etc.), so there's no need to save it manually and call CalendarView.setupCalendar() method every time, when Activity or Fragment is recreated.

If a Calendar was set up with CalendarView.setupCalendar() method before restoring state, previous saved state will be ignored.

Dates Selection

Calendar supports several selection modes: single, multiple and range.

Note: You can restrict selection of some dates by implementing your own filtration logic:

// Here we make weekends unavailable for selection
calendarView.dateSelectionFilter = { date ->
    date.dayOfWeek != Calendar.SATURDAY && date.dayOfWeek != Calendar.SUNDAY
}

Single date selection

Only one date can be selected at a time.

// Set up calendar with SelectionMode.SINGLE
calendarView.setupCalendar(selectionMode = SelectionMode.SINGLE)

...

// Get selected date or null
val selectedDate: CalendarDate? = calendarView.selectedDate

// Get list with single selected date or empty list
val selectedDates: List<CalendarDate> = calendarView.selectedDates

Multiple dates selection

A number of dates can be selected. Pressing an already selected date will unselect it.

// Set up calendar with SelectionMode.MULTIPLE
calendarView.setupCalendar(selectionMode = SelectionMode.MULTIPLE)

...

// Get all selected dates in order they were added or empty list
val selectedDates: List<CalendarDate> = calendarView.selectedDates

Range date selection

Allows you to select a date range. Previous selected range is cleared when you select another one.

// Set up calendar with SelectionMode.RANGE
calendarView.setupCalendar(selectionMode = SelectionMode.RANGE)

... 

// Get all selected dates in range (includes start and end date) or empty list
val selectedDates: List<CalendarDate> = calendarView.selectedDates

Color Indicators

The Calendar is able to display simple color indicators (dots) on the date cell.

Color indicator represents as simple interface, which you can implement in your classes.

interface DateIndicator {
    val date: CalendarDate // indicator date
    val color: Int // indicator color
}

Here's an example of setting indicators to display on the Calendar.

// Set up calendar
calendarView.setupCalendar()


val indicators: List<DateIndicator> = getDatesIndicators()

// Set List of indicators that will be displayed on the calendar 
calendarView.datesIndicators = indicators


To get all indicators for specific date, you can do this:

// Set date click callback 
calendarView.onDateClickListener = { date ->

    // Get all indicators for the date
    val indicatorsForDate = calendarView.getDateIndicators(date)
    
    // do something ... 
}

View Customization

Calendar appearance open for customization.

Styling using XML

Calendar appearance can be customized with XML attributes. Here's an example of applying custom style to change Calendar appearance.

Define your custom style for the Calendar.

<style name="CalendarViewCustomStyle">
    <item name="android:background">@android:color/white</item>
    <item name="calendar_date_background">@drawable/custom_date_bg_selector</item>
    <item name="calendar_date_text_color">@color/custom_date_text_selector</item>
    <item name="calendar_day_bar_background">@color/custom_calendar_days_bar_background</item>
    <item name="calendar_day_bar_text_color">@color/custom_calendar_days_bar_text_color</item>
    <item name="calendar_grid_color">@color/custom_calendar_grid_color</item>
    <item name="calendar_grid_on_selected_dates">false</item>
    <item name="calendar_month_text_color">@color/custom_calendar_month_text_color</item>
    <item name="calendar_year_selection_arrows_color">
        @color/custom_calendar_year_selection_arrows_color
    </item>
    <item name="calendar_year_selection_background">
        @color/custom_calendar_year_selection_background
    </item>
    <item name="calendar_year_selection_text_color">
        @color/custom_calendar_year_selection_text_color
    </item>
</style>

Apply your custom style.

<ru.cleverpumpkin.calendar.CalendarView
    android:id="@+id/calendar_view"
    style="@style/CalendarViewCustomStyle"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

To define custom styles for all Calendars in your app at once you can do this:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

    <!-- ...snip... -->
    
    <item name="calendarViewStyle">@style/CalendarViewCustomStyle</item>
    
    <!-- ...etc... -->
</style>

Styling using code

You can also set styles and colors programmatically:

 with(calendarView) {
     setDrawGridOnSelectedDates(drawGrid = true)
     setGridColorRes(R.color.custom_calendar_grid_color)
     setYearSelectionBarBackgroundColorRes(R.color.custom_calendar_year_selection_background)
     setYearSelectionBarArrowsColorRes(R.color.custom_calendar_year_selection_arrows_color)
     setYearSelectionBarTextColorRes(R.color.custom_calendar_year_selection_text_color)
     setDaysBarBackgroundColorRes(R.color.custom_calendar_days_bar_background)
     setDaysBarTextColorRes(R.color.custom_calendar_days_bar_text_color)
     setMonthTextColorRes(R.color.custom_calendar_month_text_color)
     setDateCellBackgroundRes(R.drawable.custom_date_bg_selector)
     setDateCellTextColorRes(R.color.custom_date_text_selector)
}

If you need to add some custom drawing logic for Calendar, you can implement standard RecyclerView.ItemDecoration and add it for Calendar using addCustomItemDecoration() method.

// Set up calendar
calendarView.setupCalendar()

// Some custom decoration logic 
val customItemDecoration = CustomItemDecoration()

// Add custom item decoration for calendar
calendarView.addCustomItemDecoration(customItemDecoration)

There is an abstract helper class AbsDateItemDecoration that you can extend to implement custom drawing logic for specific dates cells.

Sample app

The Sample app is available for download from Google Play.

Sketch file

Wouldn’t it be a real pain for your designer to ignore Calendar View in your apps mockups? Or for them to try and explain to you, which colors you should use by adding them to Jira task in plain text?

That is lame. That’s why we’ve added a .sketch-file to this repository here. Have fun!

License


MIT License

Copyright (c) 2018 CleverPumpkin Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Maintainers

alt text

CrunchyCalendar is maintained and developed by CleverPumpkin.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].