maxkeppeler/sheets-compose-dialogs

Prevent user from picking Future Dates with disabledDates CalendarConfig parameter

Tonnie-Dev opened this issue · 2 comments

In the CalendarConfig constructor, there is disabledDates parameter. How can you use it to prevent user from selecting future dates?

Before version 1.1.1 we used a constant - something like this ....

disabledTimeline = CalendarTimeline.FUTURE

However, this is not being resolved on my end when I upgrade to version 1.1.1*
error

I see the disabledDates takes a list of LocalDates so I came up with this work-around but it is not helping.

val startRange = LocalDate.now().minusYears(10) // allow dates up to 1 year in the past
    val disabledDates = startRange..LocalDate.now()
    val disabledDatesList = disabledDates.toList

I will appreciate any leads to hack this.

Cheers.

Hi Tonnie,

I wanted to inform you that CalendarTimeline has been discontinued.
However, defining the date boundaries for display has become much simpler.

Below is an example that uses a local date range:

Copy code
val boundary = LocalDate.now().minusYears(1)..LocalDate.now()
CalendarDialog(
    ...
    config = CalendarConfig(
        boundary = boundary,
        ...
    ),
    ...
)

With this code, only dates from one year ago to the present day will be displayed.

Let me know if you have any questions & feel free to showcase your app in the README when using the library.

Wow, thanks Max,

Was using disabledDates instead of boundary

Many thanks for clarifying.