Skip to main content

NavItem

Struct NavItem 

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

Source§

impl<K> NavItem<K>

Source

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.

Source

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.

Source

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.

Source

pub fn context_menu(self, entries: impl IntoIterator<Item = MenuEntry>) -> Self

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).

Source

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.

Source

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.

Source

pub fn badge_tint(self, color: Color) -> Self

The color for Self::badge_icon. None (the default) keeps the neutral template tint.

Source

pub fn section<M>(self, title: impl IntoText<M>) -> Self

Open a new section with this header, immediately before this row.

Source

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.

Source

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§

impl<K> NavContent<K> for NavItem<K>

Source§

fn push_sources(self, out: &mut Vec<ItemSource<K>>)

Append this content’s sources, in order.

Auto Trait Implementations§

§

impl<K = String> !RefUnwindSafe for NavItem<K>

§

impl<K = String> !Send for NavItem<K>

§

impl<K = String> !Sync for NavItem<K>

§

impl<K = String> !UnwindSafe for NavItem<K>

§

impl<K> Freeze for NavItem<K>
where K: Freeze,

§

impl<K> Unpin for NavItem<K>
where K: Unpin,

§

impl<K> UnsafeUnpin for NavItem<K>
where K: 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
§

impl<T> ErasedDestructor for T
where T: 'static,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Day API ↩ Guides· daybrite.dev