DateRangePickerState
-
Cmn
interface DateRangePickerState
A state object that can be hoisted to observe the date range picker state. See rememberDateRangePickerState.
Summary
Public functions |
||
|---|---|---|
Unit |
setSelection(startDateMillis: Long?, endDateMillis: Long?)Sets a start and end selection dates. |
Cmn
|
Public properties |
||
|---|---|---|
DisplayMode |
A |
Cmn
|
Long |
A timestamp that represents the currently displayed month start date in UTC milliseconds from the epoch. |
Cmn
|
CalendarLocale |
A locale that will be used when formatting dates, determining the input format, week-days, and more. |
Cmn
|
SelectableDates |
A |
Cmn
|
Long? |
A timestamp that represents the selected end date start of the day in UTC milliseconds from the epoch. |
Cmn
|
Long? |
A timestamp that represents the selected start date start of the day in UTC milliseconds from the epoch. |
Cmn
|
IntRange |
An |
Cmn
|
Extension functions |
||
|---|---|---|
YearMonth |
Returns a |
android
|
LocalDate? |
Returns a |
android
|
LocalDate? |
Returns a |
android
|
Unit |
@RequiresApi(value = 26)Sets the |
android
|
Unit |
@RequiresApi(value = 26)Sets the |
android
|
Public functions
setSelection
fun setSelection(startDateMillis: Long?, endDateMillis: Long?): Unit
Sets a start and end selection dates.
The function expects the dates to be within the state's year-range, and for the start date to appear before, or be equal, the end date. Also, if an end date is provided (e.g. not null), a start date is also expected to be provided. In any other case, an IllegalArgumentException is thrown.
| Parameters | |
|---|---|
startDateMillis: Long? |
timestamp in UTC milliseconds from the epoch that represents the start date selection. Provide a |
endDateMillis: Long? |
timestamp in UTC milliseconds from the epoch that represents the end date selection. Provide a |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
in case the given timestamps do not comply with the expected values specified above. |
Public properties
displayMode
var displayMode: DisplayMode
A DisplayMode that represents the current UI mode (i.e. picker or input).
displayedMonthMillis
var displayedMonthMillis: Long
A timestamp that represents the currently displayed month start date in UTC milliseconds from the epoch.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
in case the value is set with a timestamp that does not fall within the |
locale
val locale: CalendarLocale
A locale that will be used when formatting dates, determining the input format, week-days, and more.
selectableDates
val selectableDates: SelectableDates
A SelectableDates that is consulted to check if a date is allowed.
In case a date is not allowed to be selected, it will appear disabled in the UI.
selectedEndDateMillis
val selectedEndDateMillis: Long?
A timestamp that represents the selected end date start of the day in UTC milliseconds from the epoch.
| See also | |
|---|---|
setSelection |
for setting this value along with the |
selectedStartDateMillis
val selectedStartDateMillis: Long?
A timestamp that represents the selected start date start of the day in UTC milliseconds from the epoch.
| See also | |
|---|---|
setSelection |
for setting this value along with the |
Extension functions
getDisplayedMonth
@RequiresApi(value = 26)
@ExperimentalMaterial3Api
fun DateRangePickerState.getDisplayedMonth(): YearMonth
Returns a YearMonth representation of the displayed month in this DateRangePickerState. The returned YearMonth is based on the DateRangePickerState.displayedMonthMillis, which represents midnight of the first day of the displayed month in UTC milliseconds from the epoch.
getSelectedEndDate
@RequiresApi(value = 26)
@ExperimentalMaterial3Api
fun DateRangePickerState.getSelectedEndDate(): LocalDate?
Returns a LocalDate representation of the selected end date in this DateRangePickerState, or null in case there is no selection.
getSelectedStartDate
@RequiresApi(value = 26)
@ExperimentalMaterial3Api
fun DateRangePickerState.getSelectedStartDate(): LocalDate?
Returns a LocalDate representation of the selected start date in this DateRangePickerState, or null in case there is no selection.
setDisplayedMonth
@RequiresApi(value = 26)
@ExperimentalMaterial3Api
fun DateRangePickerState.setDisplayedMonth(yearMonth: YearMonth): Unit
Sets the DateRangePickerState.displayedMonthMillis based on a given YearMonth.
Converts the YearMonth to the start of the first day of that month (midnight) in UTC and apply it to the DateRangePickerState displayedMonthMillis.
setSelection
@RequiresApi(value = 26)
@ExperimentalMaterial3Api
fun DateRangePickerState.setSelection(
startDate: LocalDate?,
endDate: LocalDate?
): Unit
Sets the DateRangePickerState start and end dates selection.
The provided LocalDates are converted to the start of the day (midnight) in UTC and applied to the DateRangePickerState.
The function expects the dates to be within the state's year-range, and for the start date to appear before, or be equal, the end date. Also, if an end date is provided (e.g. not null), a start date is also expected to be provided. In any other case, an IllegalArgumentException is thrown.
| Parameters | |
|---|---|
startDate: LocalDate? |
a |
endDate: LocalDate? |
a |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
in case the given |