pub struct DateRangePickerState { /* private fields */ }Expand description
Selection, date restrictions, visible month, and input mode for a date range.
A range includes both endpoints. Date restrictions apply to its endpoints; unavailable dates between them do not split the selected range.
Implementations§
Source§impl DateRangePickerState
impl DateRangePickerState
Sourcepub fn new(
start: Option<CalendarDate>,
end: Option<CalendarDate>,
displayed_month: Option<YearMonth>,
year_range: RangeInclusive<i32>,
is_selectable_date: Option<CallbackWith<CalendarDate, bool>>,
is_selectable_year: Option<CallbackWith<i32, bool>>,
display_mode: DatePickerDisplayMode,
) -> Self
pub fn new( start: Option<CalendarDate>, end: Option<CalendarDate>, displayed_month: Option<YearMonth>, year_range: RangeInclusive<i32>, is_selectable_date: Option<CallbackWith<CalendarDate, bool>>, is_selectable_year: Option<CallbackWith<i32, bool>>, display_mode: DatePickerDisplayMode, ) -> Self
Creates a range picker. Invalid initial endpoints are discarded.
Sourcepub fn selected_start_date(&self) -> Option<CalendarDate>
pub fn selected_start_date(&self) -> Option<CalendarDate>
Returns the inclusive start date, including an unfinished selection.
Sourcepub fn selected_end_date(&self) -> Option<CalendarDate>
pub fn selected_end_date(&self) -> Option<CalendarDate>
Returns the inclusive end date when the selection is complete.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Returns whether both endpoints are selected.
Sourcepub fn set_selection(
&mut self,
start: Option<CalendarDate>,
end: Option<CalendarDate>,
) -> bool
pub fn set_selection( &mut self, start: Option<CalendarDate>, end: Option<CalendarDate>, ) -> bool
Sets both endpoints atomically, returning false without changing an invalid range.
An end requires a start on or before it. Both endpoints must be selectable.
Sourcepub fn select_date(&mut self, date: CalendarDate) -> bool
pub fn select_date(&mut self, date: CalendarDate) -> bool
Selects the next endpoint, restarting after a complete range or an earlier date.
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clears both endpoints without moving the calendar.
Sourcepub fn is_date_selectable(&self, date: CalendarDate) -> bool
pub fn is_date_selectable(&self, date: CalendarDate) -> bool
Returns whether the date can be used as an endpoint.
Sourcepub fn year_range(&self) -> &RangeInclusive<i32> ⓘ
pub fn year_range(&self) -> &RangeInclusive<i32> ⓘ
Returns the allowed year range.
Sourcepub fn set_year_range(&mut self, range: RangeInclusive<i32>)
pub fn set_year_range(&mut self, range: RangeInclusive<i32>)
Updates the year range, clearing endpoints that are no longer selectable.
Sourcepub fn set_is_selectable_date(
&mut self,
predicate: Option<CallbackWith<CalendarDate, bool>>,
)
pub fn set_is_selectable_date( &mut self, predicate: Option<CallbackWith<CalendarDate, bool>>, )
Updates endpoint date restrictions, clearing invalid selections.
Sourcepub fn set_is_selectable_year(
&mut self,
predicate: Option<CallbackWith<i32, bool>>,
)
pub fn set_is_selectable_year( &mut self, predicate: Option<CallbackWith<i32, bool>>, )
Updates endpoint year restrictions, clearing invalid selections.
Sourcepub fn displayed_month(&self) -> YearMonth
pub fn displayed_month(&self) -> YearMonth
Returns the first visible calendar month.
Sourcepub fn set_displayed_month(&mut self, month: YearMonth)
pub fn set_displayed_month(&mut self, month: YearMonth)
Scrolls to a month, clamped to the allowed year range.
Sourcepub fn display_mode(&self) -> DatePickerDisplayMode
pub fn display_mode(&self) -> DatePickerDisplayMode
Returns the calendar or manual-input mode.
Sourcepub fn set_display_mode(&mut self, mode: DatePickerDisplayMode)
pub fn set_display_mode(&mut self, mode: DatePickerDisplayMode)
Changes input mode, showing the selected start month when returning to the calendar.
Sourcepub fn toggle_display_mode(&mut self)
pub fn toggle_display_mode(&mut self)
Switches between calendar and manual input.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DateRangePickerState
impl RefUnwindSafe for DateRangePickerState
impl Send for DateRangePickerState
impl Sync for DateRangePickerState
impl Unpin for DateRangePickerState
impl UnsafeUnpin for DateRangePickerState
impl UnwindSafe for DateRangePickerState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.