use chrono::NaiveDate;
use fission::prelude::*;
use std::sync::Arc;
let widget: Widget = DateRangePicker {
id_start: WidgetId::explicit("range_start"),
id_end: WidgetId::explicit("range_end"),
start: view.state().range_start,
end: view.state().range_end,
is_start_open: view.state().range_start_open,
is_end_open: view.state().range_end_open,
on_change: Some(Arc::new(move |start: Option<NaiveDate>, end: Option<NaiveDate>| ActionEnvelope {
id: set_range_id,
payload: serde_json::to_vec(&SetDateRange { start, end }).unwrap(),
})),
on_toggle_start: Some(toggle_start_action),
on_toggle_end: Some(toggle_end_action),
on_close_start: Some(close_start_action),
on_close_end: Some(close_end_action),
}
.into();
Field | Type | Meaning | Notes / default behavior |
|---|---|---|---|
id_start | WidgetId | Stable identity for the start-date trigger. | Required. |
id_end | WidgetId | Stable identity for the end-date trigger. | Required. |
start | Option<NaiveDate> | Current start date. | Controlled by app state. |
end | Option<NaiveDate> | Current end date. | Controlled by app state. |
is_start_open | bool | Whether the start picker popup is open. | Controlled by app state. |
is_end_open | bool | Whether the end picker popup is open. | Controlled by app state. |
on_change | Option<Arc<dyn Fn(Option<NaiveDate>, Option<NaiveDate>) -> ActionEnvelope + Send + Sync>> | Closure that receives the updated pair. | Called when either side changes. |
on_toggle_start | Option<ActionEnvelope> | Action for opening or toggling the start picker. | Defaults to None. |
on_toggle_end | Option<ActionEnvelope> | Action for opening or toggling the end picker. | Defaults to None. |
on_close_start | Option<ActionEnvelope> | Explicit close action for the start picker. | Defaults to None. |
on_close_end | Option<ActionEnvelope> | Explicit close action for the end picker. | Defaults to None. |