pub struct Step { /* private fields */ }Expand description
One page in a Stepper.
A step carries a localized title, optional supporting_text, a content
factory (the body shown when the step is active), and an optional
completion gate. The recommended data-flow pattern: the application owns
its form state as Signals, the content factory binds widgets to those
signals (write side), and complete_when derives
the Next gate from the same signals.
Implementations§
Source§impl Step
impl Step
pub fn new(title: impl Into<LocalizedString>) -> Self
Sourcepub fn content<W, F>(self, factory: F) -> Selfwhere
W: Widget + 'static,
F: Fn() -> W + 'static,
pub fn content<W, F>(self, factory: F) -> Selfwhere
W: Widget + 'static,
F: Fn() -> W + 'static,
The body shown while this step is active. The factory may capture
clones of the application’s form Signals to read/write step input.
Sourcepub fn content_boxed(
self,
factory: impl Fn() -> Box<dyn Widget> + 'static,
) -> Self
pub fn content_boxed( self, factory: impl Fn() -> Box<dyn Widget> + 'static, ) -> Self
The body shown while this step is active, as a boxed widget — the escape hatch for a body whose concrete type varies at runtime.
content is generic over one W: Widget, and
Box<dyn Widget> does not itself implement Widget, so a step whose
body branches on app state cannot be expressed as a single content
factory. Box each branch instead of duplicating the surrounding
builder:
Step::new(lit!("Details")).content_boxed({
let purpose = purpose.clone();
move || -> Box<dyn Widget> {
match purpose.get() {
Purpose::Novel => Box::new(novel_form()),
Purpose::Import => Box::new(import_form()),
}
}
})Sourcepub fn supporting_text(self, text: impl Into<LocalizedString>) -> Self
pub fn supporting_text(self, text: impl Into<LocalizedString>) -> Self
Secondary line under the title in the header / indicator.
Sourcepub fn status(self, status: StepStatus) -> Self
pub fn status(self, status: StepStatus) -> Self
Set the step’s initial StepStatus.
Sourcepub fn optional(self, optional: bool) -> Self
pub fn optional(self, optional: bool) -> Self
Mark the step optional (reachable but skippable — surfaces a Skip
button while active). Equivalent to .status(StepStatus::Optional).
Sourcepub fn complete_when(self, signal: impl Into<Prop<bool>>) -> Self
pub fn complete_when(self, signal: impl Into<Prop<bool>>) -> Self
Reactive Next gate: while this step is active, Next is enabled iff
signal is true. Derive it from the same form signals the step’s
content writes — e.g. name.map(|n| !n.is_empty()).
Sourcepub fn validate_on_next(self, f: impl Fn() -> bool + 'static) -> Self
pub fn validate_on_next(self, f: impl Fn() -> bool + 'static) -> Self
Imperative validation fallback: checked on the Next click. Returning
false blocks navigation. Prefer complete_when
where a reactive signal is available.
Sourcepub fn visible_when(self, visible: impl Into<Prop<bool>>) -> Self
pub fn visible_when(self, visible: impl Into<Prop<bool>>) -> Self
Reactive visibility: while visible is false this step drops out of
the flow — Next / Back / indicator clicks skip it, and its marker is
hidden from the indicator strip (and from AT).
This is how a branching wizard is expressed: declare every step once and gate the conditional ones on the choice that selects them, instead of maintaining one step list per branch.
let purpose = Signal::new(Purpose::Novel);
Stepper::new()
.step(Step::new(lit!("Purpose")).content(|| purpose_picker()))
.step(Step::new(lit!("Import source"))
.visible_when(purpose.map(|p| *p == Purpose::Import))
.content(|| import_form()))Hiding the step the user is currently on does not navigate away from it — gate steps ahead of the choice, not the one making it.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Step
impl !Send for Step
impl !Sync for Step
impl !UnwindSafe for Step
impl Freeze for Step
impl Unpin for Step
impl UnsafeUnpin for Step
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more