Android DatePicker with month and year build with Compose UI

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

//XML Layout

<androidx.compose.ui.platform.ComposeView
  android:id="@+id/composeDatePickerView"
  android:layout_width="match_parent"
  android:layout_height="match_parent" />
  
  
//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...
A simple compose weight picker drawn with canvas.

CanvasWeightPicker A simple compose weight picker drawn with canvas. Features Drag scale to select weight Haptic feedback on weight selected Video of

Material3 themed Jetpack Compose date & time pickers.
Material3 themed Jetpack Compose date & time pickers.

Compose material3 Date1 and Time pickers Highly customizable Jetpack Compose components with material3 support for date & time picking. Contents Lates

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

A customizable, easy-to-use, and functional circular time range picker library for Android
A customizable, easy-to-use, and functional circular time range picker library for Android

A customizable, easy-to-use, and functional circular time range picker library for Android. Use this library to mimic Apple's iOS or Samsung's bedtime picker.

CalEF (Calendar Entry Formatter) : Select an entry in Android-Kalender and send/share the entry's content as human readable text.

CalEF (Calendar Entry Formatter) Select an entry in Android-Kalender and send/share the entry's content as human readable text. Usually calendar entri

Amazing Dynamic Time UI :clock1030: :hourglass: and More
Amazing Dynamic Time UI :clock1030: :hourglass: and More

FlatTimeCollection Amazing Dynamic Time UI 🕥 ⌛ for Android To help you design your Layout. it is Not just a UI, But it contains a CountDownTimer with

Android Week View is an android library to display calendars (week view or day view) within the app. It supports custom styling.
Android Week View is an android library to display calendars (week view or day view) within the app. It supports custom styling.

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. Fea

A Material design back port of Android's CalendarView
A Material design back port of Android's CalendarView

Material Calendar View A Material design back port of Android's CalendarView. The goal is to have a Material look and feel, rather than 100% parity wi

Standalone Android widget for picking a single date from a calendar view.
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.

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
Fully customizable Calendar/DatePicker for Android/Kotlin

AMCalendar - Android Date (Range) Picker AMCalendar is a fully customisable widget for picking dates and ranges based on the native Calendar. It's an

null 6 Oct 18, 2022
Time-DatePicker - A Simple Time Date Picker With Kotlin

Time-DatePicker Time.DatePicker.mp4

Faysal Hossain 0 Jan 19, 2022
Android interval timer app using compose + compose navigation, dagger hilt, room, kotlin coroutines + flow and mvvm design pattern.

What's InTime? ⏳ InTime is an interval timer application using android jetpack components and a long running service. The purpose of this project is t

P. 46 Oct 10, 2022
Appleader707 1 Aug 9, 2022
Android Compose wheel picker library based on LazyColumn in vertical and LazyRow in horizontal.

About Android Compose wheel picker library based on LazyColumn in vertical and LazyRow in horizontal. Gradle Sample Default Item size Unfocused count

null 6 Dec 22, 2022
Nepali Date Picker library in Jetpack compose for android with Date conversion from BS to AD and vice-versa

Nepali Date picker Converter - Re in Compose This is a re-work of Nepali Date Picker Converter in jetpack compose and kotlin. English Locale Nepali Lo

Kiran Gyawali 4 Dec 23, 2022
Alwan 🎨 is an Android Jetpack Compose color picker library.

Alwan Alwan is an Android Jetpack Compose color picker library. Preview Recording.mp4 Download Gradle: dependencies { implementation 'com.raedapps:a

Raed Mughaus 6 Sep 16, 2022
JetCalendarView - A calendar library for Jetpack Compose

JetCalendar WIP 2022 Hit Refresh! Calendar view ❤️ Jetpack Compose License Copyr

Anmol Verma 8 Aug 17, 2022
Kalendar - A calendar to integrate Calendar with Custom design in your jetpack compose project

Kalendar - An Elementary Compose Calendar. This is a calendar to integrate Calen

Himanshu Singh 494 Jan 2, 2023
JetCountrypicker - Country code bottomsheet picker in Jetpack Compose

JetCountryPicker Country code bottomsheet picker in Jetpack Compose How to add i

Canopas Software 30 Nov 17, 2022