use fission::prelude::*;
fission_component! {
pub WeeklyHoursFilter<()> {
state {
minimum: f32 = 8.0,
maximum: f32 = 24.0,
}
}
view(filter, _state, cx) =>
Column(
children: [
Text(cx.tr("schedule.weekly_hours")),
RangeSlider(
id: WidgetId::explicit("schedule.weekly-hours"),
semantics_identifier: Some("schedule.weekly-hours".into()),
start: filter.minimum,
end: filter.maximum,
min: 0.0,
max: 40.0,
step: 1.0,
on_change: reduce {
if let Some(change) = cx.input.range_slider_change() {
if change.start.is_finite() && change.end.is_finite()
&& change.start >= 0.0 && change.end <= 40.0
&& change.start <= change.end
{
filter.minimum = change.start;
filter.maximum = change.end;
}
}
},
),
Text(format!(
"{}–{} {}",
filter.minimum,
filter.maximum,
cx.tr("duration.hours"),
)),
],
)
}
Field | Type | Meaning | Notes / default behavior |
|---|---|---|---|
id | Option<WidgetId> | Stable identity for focus and pointer capture. | Defaults to None. |
start | f32 | Lower bound of the displayed range. | Required. Expected to be within [min, max]. |
end | f32 | Upper bound of the displayed range. | Required. Expected to be within [min, max]. |
min | f32 | Minimum domain value. | Required. |
max | f32 | Maximum domain value. | Required. |
step | Option<f32> | Positive increment for snapping and key adjustment. | Without one, pointer movement is continuous and keys use one percent of the domain. |
semantics_identifier | Option<String> | Stable control/test identifier. | Thumbs add .start and .end suffixes. |
on_change | Option<ActionEnvelope> | Proposed-range notification. | Read start, end, active_thumb, and source from contextual input. |