Compose Date Picker - Select month and year

Overview

Compose Date Picker - Select month and year

Compose Date Picker tries to offer you the year and month pickers which you can customize for your requirements. The library complately written with Jetpack Compose.

Support for Android 5.0 (API level 21) and up.

Screenshots

enter image description here enter image description here
enter image description here

Implementation

Add it in your root build.gradle at the end of repositories:

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

The easiest way to add the Compose Date Picker library to your project is by adding it as a dependency to your build.gradle

dependencies {
	implementation 'com.github.DogusTeknoloji:compose-date-picker:1.0.1'
}

Usage Compose Date Picker

ComposeCalendar(  
  minDate: Date? = null,  // Set min selectable date
  maxDate: Date? = null,  // Set max selectable date
  locale: Locale = Locale.getDefault(),  // Set locale for localization
  title: String = "",  // Set title 
  listener: SelectDateListener, // Set Listener for selected date
  showOnlyMonth: Boolean = false,  // Display only month picker
  showOnlyYear: Boolean = false,  // Display only year picker
  themeColor:Color = Color(0xFF614FF0), // Set picker color 
  negativeButtonTitle:String = "CANCEL",  // Set negative button text
  positiveButtonTitle:String = "OK"  // Set positive button text
)

Listener

interface SelectDateListener {  
    fun onDateSelected(date: Date)  
    fun onCanceled()  
}

Compose Sample

val calendar = Calendar.getInstance()  
calendar.set(Calendar.YEAR, 2010)  
calendar.set(Calendar.MONTH, 6)  
val calendarMax = Calendar.getInstance()  
calendarMax.set(Calendar.YEAR, 2032)  
calendarMax.set(Calendar.MONTH, 9)

Box(Modifier  
    .fillMaxSize()  
    .background(color = Color.Gray), contentAlignment = Alignment.Center) {  
   
      ComposeCalendar(minDate = calendar.time,  
      maxDate = calendarMax.time,  
      locale = Locale("en"),  
      title = "Select Date",  
      listener = object : SelectDateListener {  
                    override fun onDateSelected(date: Date) {  
                        Log.i("DATE", date.toString())  
                    }  
      
                    override fun onCanceled() {  
                        setOpen(false)  
                    }  
                })  
        }

XML Layout Sample

//Activity-Fragment binding.composeDatePickerView.apply{ setContent{ ComposeCalendar(minDate = calendar.time, maxDate = calendarMax.time, locale = Locale("en"), title = "Select Date", listener = object : SelectDateListener { override fun onDateSelected(date: Date) { Log.i("DATE", date.toString()) } override fun onCanceled() { setOpen(false) } }) } } ">
//XML Layout


  
  
  
//Activity-Fragment

binding.composeDatePickerView.apply{
    setContent{
	    ComposeCalendar(minDate = calendar.time,  
	      maxDate = calendarMax.time,  
	      locale = Locale("en"),  
	      title = "Select Date",  
	      listener = object : SelectDateListener {  
	                    override fun onDateSelected(date: Date) {  
	                        Log.i("DATE", date.toString())  
	                    }  
	      
	                    override fun onCanceled() {  
	                        setOpen(false)  
	                    }  
	                })  
    }
}

Design inspired by https://github.com/premkumarroyal/MonthAndYearPicker

You might also like...
Android library for better Picker DialogFragments
Android library for better Picker DialogFragments

DialogFragments modeled after the AOSP Clock and Calendar apps to improve UX for picking time, date, numbers, and other things.

📅 Minimal Calendar - This calendar library is built with jetpack compose. Easy, simple, and minimal.
📅 Minimal Calendar - This calendar library is built with jetpack compose. Easy, simple, and minimal.

📅 Minimal Calendar This calendar library is built with jetpack compose. Easy, simple, and minimal. Latest version The stable version of the library i

A kitchen timer implemented with Jetpack Compose
A kitchen timer implemented with Jetpack Compose

Kitchen Timer Motivation and Context To commemorate Jetpack Compose first beta release, Google launched the #AndroidDevChallenge. In the 2nd round, co

Clock of Clocks written in Jetpack Compose framework
Clock of Clocks written in Jetpack Compose framework

A Clock of Clocks made with Jetpack Compose You can download the APK Here. This project is inspired by A Clock of Clocks. Other Implementations This p

A Jetpack Compose library for handling calendar component rendering.
A Jetpack Compose library for handling calendar component rendering.

Compose Calendar Compose Calendar is a composable handling all complexity of rendering calendar component and date selection. Due to flexibility provi

Calendar - A component for compose desktop
Calendar - A component for compose desktop

日历 一个用于compose-desktop的日历组件。 截图 feature DayPicker的动画 月份选择器错误提示 点击非本月的时间会跳到上个月 to

GoogleCalendar Android Clone with Compose
GoogleCalendar Android Clone with Compose

GoogleCalendar Android Clone with Compose Status: WIP This is a jetpack compose sample app written in Kotlin following clean architecture principles.

Android calendar view inspired by Sunrise calendar and iOS7 stock calendar
Android calendar view inspired by Sunrise calendar and iOS7 stock calendar

SilkCal Android calendar view inspired by Sunrise calendar and iOS7 stock calendar. Usage Add compile 'me.nlmartian.silkcal:library:0.1.1' to your dep

📅 CosmoCalendar is a fully customizable calendar with a wide variety of features and displaying modes.
📅 CosmoCalendar is a fully customizable calendar with a wide variety of features and displaying modes.

CosmoCalendar Made by Applikey Solutions Usage Customization Common Selection Current day Navigation buttons Weekend days Connected days Disabled days

Comments
  • Make Month view type configurable on OneScreenMonthYear

    Make Month view type configurable on OneScreenMonthYear

    This PR makes the OneScreenMonthYear composable modifiable via the monthViewType, allowing it to display the month as either numbers or 3-letter name.

    image

    opened by HawkiesZA 0
  • Design issue in DarkMode

    Design issue in DarkMode

    Thanks great library.

    In Dark mode the color of un-selected month/year is not good.

    So we need a way to customize the color of the un-selected month/year .

    opened by nawaf11 0
  • Minimum Month January

    Minimum Month January

    I use the minimum date from January 2021 and the maximum date is January 2022 but february 2022 - december 2022 not disabled and still active supposedly february 2022 - december 2022 not active

    bug 
    opened by rohmatullaily 0
Releases(v1.1.1)
  • v1.1.1(Dec 22, 2022)

    What's Changed

    • Make Month view type configurable on OneScreenMonthYear by @HawkiesZA in https://github.com/DogusTeknoloji/compose-date-picker/pull/16

    New Contributors

    • @HawkiesZA made their first contribution in https://github.com/DogusTeknoloji/compose-date-picker/pull/16

    Full Changelog: https://github.com/DogusTeknoloji/compose-date-picker/compare/v1.1.0...v1.1.1

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Sep 22, 2022)

    What's Changed

    • OneScreen year and month ui added by @BerkkanB in https://github.com/DogusTeknoloji/compose-date-picker/pull/14

    Full Changelog: https://github.com/DogusTeknoloji/compose-date-picker/compare/v1.0.9...v1.1.0

    Source code(tar.gz)
    Source code(zip)
  • v1.0.9(May 25, 2022)

    What's Changed

    • Unselected Text Color can be customized now by @BerkkanB in https://github.com/DogusTeknoloji/compose-date-picker/pull/12

    Full Changelog: https://github.com/DogusTeknoloji/compose-date-picker/compare/v1.0.8...v1.0.9

    Source code(tar.gz)
    Source code(zip)
  • v1.0.8(May 23, 2022)

    What's Changed

    • Previous month day issue fixed; by @BerkkanB in https://github.com/DogusTeknoloji/compose-date-picker/pull/11

    Full Changelog: https://github.com/DogusTeknoloji/compose-date-picker/compare/v1.0.7...v1.0.8

    Source code(tar.gz)
    Source code(zip)
  • v1.0.7(Mar 3, 2022)

    What's Changed

    • Adding button text size parameter by @BerkkanB in https://github.com/DogusTeknoloji/compose-date-picker/pull/8

    Full Changelog: https://github.com/DogusTeknoloji/compose-date-picker/compare/v1.0.6...v1.0.7

    Source code(tar.gz)
    Source code(zip)
  • v1.0.6(Feb 23, 2022)

    What's Changed

    • Change month numbers format as 01,02,03 ..... by @BerkkanB in https://github.com/DogusTeknoloji/compose-date-picker/pull/6

    Full Changelog: https://github.com/DogusTeknoloji/compose-date-picker/compare/v1.0.5...v1.0.6

    Source code(tar.gz)
    Source code(zip)
  • v1.0.5(Feb 23, 2022)

    What's Changed

    • Feature/height changes fix and initial date option added by @BerkkanB in https://github.com/DogusTeknoloji/compose-date-picker/pull/5

    Full Changelog: https://github.com/DogusTeknoloji/compose-date-picker/compare/v1.0.4...v1.0.5

    Source code(tar.gz)
    Source code(zip)
  • v1.0.4(Jan 31, 2022)

    Full Changelog: https://github.com/DogusTeknoloji/compose-date-picker/compare/v1.0.3...v1.0.4

    • January to January issue fixed

    • When it is 31st day of month, there was an issue with selecting some months. Setting day of month to first day, fix the issue.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.3(Jan 10, 2022)

    What's Changed

    • Feature/months as number with header by @BerkkanB in https://github.com/DogusTeknoloji/compose-date-picker/pull/3

    Full Changelog: https://github.com/DogusTeknoloji/compose-date-picker/compare/v1.0.2...v1.0.3

    Source code(tar.gz)
    Source code(zip)
  • v1.0.2(Jan 10, 2022)

    What's Changed

    • Feature/add month number view by @BerkkanB in https://github.com/DogusTeknoloji/compose-date-picker/pull/2 ** Showing only month numbers and similar cases added to project.

    *Full Changelog: https://github.com/DogusTeknoloji/compose-date-picker/compare/v1.0.1...v1.0.2

    Source code(tar.gz)
    Source code(zip)
  • v1.0.1(Oct 13, 2021)

  • v1.0.0(Oct 13, 2021)

Owner
Doğuş Teknoloji
Doğuş Teknoloji
android library dialog month picker

RackMonthPicker android library dialog month picker Download Download via Maven: Add the JitPack repository to your build file <repositories> <rep

Kristiawan Adi L 41 Aug 13, 2022
Asimov-time-kt - Useful time and date related functions and extensions

asimov/time Useful time and date related functions and extensions. Installation

Nicolas Bottarini 1 Jan 7, 2022
Multiplatform Date and time library for Kotlin

Klock is a Date & Time library for Multiplatform Kotlin. It is designed to be as allocation-free as possible using Kotlin inline classes, to be consis

null 681 Dec 19, 2022
A simple Cupcake Ordering App, choose flavor, pickup on a date, get order summary and send order via any other app.

Cupcake app This app contains an order flow for cupcakes with options for quantity, flavor, and pickup date. The order details get displayed on an ord

Akshat Khandelwal 0 Dec 23, 2021
MinutesAliveApp - Basic Android App that ask for your date of birth and shows your age in minutes

MinutesAliveApp Basic Android App that ask for your date of birth and shows your

JestorDev 0 Jan 30, 2022
Standalone Android widget for picking a single date from a calendar view.

TimesSquare for Android Standalone Android widget for picking a single date from a calendar view. Usage Include CalendarPickerView in your layout XML.

Square 4.4k Dec 20, 2022
A material-styled android view that provisions picking of a date, time & recurrence option, all from a single user-interface.

SublimePicker A customizable view that provisions picking of a date, time & recurrence option, all from a single user-interface. You can also view 'Su

Vikram 2.3k Jan 4, 2023
Pick a date or time on Android in style

Material DateTime Picker - Select a time/date in style Material DateTime Picker tries to offer you the date and time pickers as shown in the Material

null 4.7k Dec 29, 2022
KotlinX multiplatform date/time library

kotlinx-datetime A multiplatform Kotlin library for working with date and time. See Using in your projects for the instructions how to setup a depende

Kotlin 1.6k Jan 5, 2023
Additions for Kotlin's date & time library kotlinx-datetime

fluid-time Additions for Kotlin's date & time library kotlinx-datetime. kotlinx-datetime is very early stage and not as actively developed as other of

Marc Knaup 39 Nov 11, 2022