Skip to main content

Wizard

Struct Wizard 

Source
pub struct Wizard<Msg> { /* private fields */ }
Expand description

A flow of pages the user goes through in order: Steps on top, the current step’s page, and a row of buttons.

The application owns the current step and every value. Next sends the next message; the application validates the step there and either advances or returns FormErrors::focus_first, so a broken step blocks the flow with focus on the problem. On the last step Next reads Finish and sends the finish message. Back is shown from the second step on.

Capabilities, each off until asked for: Wizard::on_cancel adds a Cancel button and makes Esc inside the wizard cancel; Wizard::on_step lets people go back by choosing a finished step; Wizard::busy shows Next working and ignores it; Wizard::page_height keeps the buttons in place across pages of different heights.

The buttons are named wizard-cancel, wizard-back and wizard-next, so Command::focus("wizard-next") reaches them. Their words are quvyta.wizard.cancel, back, next and finish.

Implementations§

Source§

impl<Msg: Clone + 'static> Wizard<Msg>

Source

pub fn new(labels: impl IntoIterator<Item = impl Into<String>>) -> Self

A wizard with steps named labels, on the first step.

Source

pub fn current(self, index: usize) -> Self

The current step.

Source

pub fn on_back(self, message: Msg) -> Self

Message for Back.

Source

pub fn on_next(self, message: Msg) -> Self

Message for Next on every step but the last.

Source

pub fn on_finish(self, message: Msg) -> Self

Message for Finish on the last step.

Source

pub fn on_cancel(self, message: Msg) -> Self

Adds a Cancel button; Esc inside the wizard sends the same message.

Source

pub fn on_step(self, message: impl Fn(usize) -> Msg + 'static) -> Self

Lets finished steps be chosen to go back to them; the message carries the step.

Source

pub fn busy(self, busy: bool) -> Self

Shows Next (or Finish) working and ignores it, e.g. while the last step is applied.

Source

pub fn page_height(self, rows: u16) -> Self

Gives every page exactly rows rows, so the buttons stay put between steps.

Source

pub fn show<'v>( self, ui: &'v mut View<'_, Msg>, page: impl FnOnce(&mut View<'_, Msg>), ) -> NodeMut<'v, Msg>

Adds the wizard to ui with the current step’s page built by page.

Auto Trait Implementations§

§

impl<Msg> !RefUnwindSafe for Wizard<Msg>

§

impl<Msg> !Send for Wizard<Msg>

§

impl<Msg> !Sync for Wizard<Msg>

§

impl<Msg> !UnwindSafe for Wizard<Msg>

§

impl<Msg> Freeze for Wizard<Msg>
where Option<Msg>: Freeze, Option<Box<dyn Fn(usize) -> Msg>>: Freeze,

§

impl<Msg> Unpin for Wizard<Msg>
where Option<Msg>: Unpin, Option<Box<dyn Fn(usize) -> Msg>>: Unpin,

§

impl<Msg> UnsafeUnpin for Wizard<Msg>
where Option<Msg>: UnsafeUnpin, Option<Box<dyn Fn(usize) -> Msg>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.