pub struct NavItem<K = String> { /* private fields */ }Expand description
One nav item (docs/navigation.md): a key, a title, and its decorations, built by item.
The same value describes a static destination (item("home", title).page(home_page)) and
a row of a data-driven block (nav_items(move || feeds(), |f| item(f.id, f.name))).
Implementations§
Sourcepub fn page<P: Piece>(self, build: impl Fn() -> P + 'static) -> Self
pub fn page<P: Piece>(self, build: impl Fn() -> P + 'static) -> Self
The page this item opens; build runs when the item is first shown. An item without
one is built by the nav’s Nav::destination, the usual choice for a data-driven block
whose rows share one page shape.
Sourcepub fn icon(self, icon: impl Into<ImageName>) -> Self
pub fn icon(self, icon: impl Into<ImageName>) -> Self
A bundled-image name for the item’s native icon (typed ImageName,
resolved like image(), e.g. res::images::nav_home), or an absolute local image path
supplied as an owned string. Shown beside the label where the backend’s nav supports it
(the Windows NavigationView, the iOS/macOS source list); backends that can’t decorate
rows ignore it. AppKit/UIKit preserve the colors of local files; bundled glyphs remain
templates.
Sourcepub fn icon_tint(self, color: Color) -> Self
pub fn icon_tint(self, color: Color) -> Self
Tint this row’s icon (docs/vectors.md): the glyph recolors to color instead of the
backend’s neutral template tint. Backends without per-row tinting keep the neutral look.
Attach a context menu to this row (docs/menus.md): shown on secondary-click /
long-press, the same menu_item/sub_menu builders as everywhere else. A chosen
entry runs its action exactly like a piece context menu. Backends without per-row
menus drop it (see the matrix in docs/menus.md).
Sourcepub fn badge<M>(self, badge: impl IntoText<M>) -> Self
pub fn badge<M>(self, badge: impl IntoText<M>) -> Self
A trailing accessory for this row (an unread count, a status). Rendered right-aligned
and de-emphasized where the toolkit has an affordance for it, and dropped where it does
not (see docs/coverage-matrix.md). Empty text shows no badge, so a count can return ""
at zero.
Sourcepub fn badge_icon(self, icon: impl Into<ImageName>) -> Self
pub fn badge_icon(self, icon: impl Into<ImageName>) -> Self
A trailing accessory glyph for this row, in the same slot as Self::badge and drawn
after it. Takes a bundled image name exactly as Self::icon does, so a symbol
(Symbol::Star) or an app image both work.
This is what a row-level status gets drawn with (a starred page’s star) where badge
carries a count or a word. Pair it with Self::badge_tint when the glyph’s color is
part of its meaning; left untinted it takes the backend’s neutral template tint and reads
as another piece of chrome.
Sourcepub fn badge_tint(self, color: Color) -> Self
pub fn badge_tint(self, color: Color) -> Self
The color for Self::badge_icon. None (the default) keeps the neutral template tint.
Sourcepub fn section<M>(self, title: impl IntoText<M>) -> Self
pub fn section<M>(self, title: impl IntoText<M>) -> Self
Open a new section with this header, immediately before this row.
Sourcepub fn section_id<M>(
self,
id: impl Into<String>,
title: impl IntoText<M>,
) -> Self
pub fn section_id<M>( self, id: impl Into<String>, title: impl IntoText<M>, ) -> Self
Open a section with an identity independent of its localized title or first row.
Sourcepub fn immersive(self) -> Self
pub fn immersive(self) -> Self
Mark this item’s pushed page immersive-chrome (docs/navigation.md): on backends with an immersive nav mode (android edge-to-edge today) its pushed page keeps the floating transparent bar over full-bleed content; unmarked pages get the standard opaque bar. A no-op on every other backend.
Trait Implementations§
Source§fn push_sources(self, out: &mut Vec<ItemSource<K>>)
fn push_sources(self, out: &mut Vec<ItemSource<K>>)
Auto Trait Implementations§
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<T> ErasedDestructor for Twhere
T: 'static,
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