ArchitShah248/CalendarDateRangePicker

option to disable future dates

Closed this issue · 5 comments

there are many cases when we have to show only past dates, but as of now there isan option to disable past dates but no option to disable future dates.
please let me know about this

thanks!

May i know how to enable past dates

Hello folks, I have added api setSelectableDateRange(startDate, endDate) to enable/disable date range in V1.1.6. I hope it will be useful for you.

Happy coding!

what will be startDate and endDate I just only want to disable future date what is the range of previous date it is does not matter.

Hi @syedqbuster,
First set visible month range by using calendar.setVisibleMonthRange(startMonth,endMonth) to show visible months range (past+future / only past / only future).
Then use calendar.setSelectableDateRange(startDateSelectable, endDateSelectable) to select selectable date range within visible month range.

Happy coding!

Hi @ArchitShah248,

I'm using the following code:

    val startCalendar = Calendar.getInstance().apply { add(Calendar.MONTH, -rangeMonth) }
    val endCalendar = Calendar.getInstance()

    bottomSheetRangePicker.setVisibleMonthRange(startCalendar, endCalendar)
    bottomSheetRangePicker.setSelectedDateRange(startCalendar, endCalendar)

But this allows me select the future dates of this month.
e.g. today is April 3, since visible range includes this month, it allows me to select date upto April 30.