Skip to main content

Navigation

Function Navigation 

Source
pub fn Navigation(_: NavigationProps) -> Element
Expand description

A set of destinations with one of them selected, plus the screen they lead to.

The children that are NavigationItem are the destinations; every other child is the content of the selected screen. Splitting by kind rather than by index means a destination that only exists under some condition does not force the Host to keep two lists in step by hand.

Nothing here says bar, rail or drawer. The Renderer has already measured the window, so it chooses: a bar across the bottom of a phone-shaped window, a rail down the side of a tablet-shaped one, a drawer standing open on a desktop. Asking the Host to choose would mean the width travelling up, a whole VirtualDom pass, and a tree of destinations being destroyed and rebuilt every time the window crossed a boundary, to arrive at the same three layouts the Renderer can reach by moving the nodes it already has.

selected_index counts destinations, not children. It seeds the Renderer’s selection and moves it when the change came from somewhere other than a tap; a tap moves the selection in the Renderer and reports it by firing that destination’s own on_click.

§Props

For details, see the props struct definition.