Skip to main content

HeaderItem

Struct HeaderItem 

Source
pub struct HeaderItem { /* private fields */ }
Expand description

An iOS bar button for super::host::Screen::header_left_items and super::host::Screen::header_right_items: what it shows, an optional native menu of desktop::MenuItems, and handlers that run when the platform reports their ids as the root’s Menu event.

ⓘ
HeaderItem::system(HeaderSystemItem::Edit).on_press(edit)
HeaderItem::symbol_title("sparkles", "Upgrade").on_press(upgrade)
HeaderItem::symbol("ellipsis.circle")
    .label("More")
    .menu([
        desktop::MenuItem::new("Share").on_select(share),
        desktop::MenuItem::submenu("Danger", [
            desktop::MenuItem::new("Delete").destructive(true).on_select(remove),
        ])
        .inline(true),
    ])

Implementations§

Source§

impl HeaderItem

Source

pub fn system(item: HeaderSystemItem) -> Self

A system-item button.

Source

pub fn symbol(name: impl Into<Arc<str>>) -> Self

An SF Symbol button.

Source

pub fn new(label: impl Into<Arc<str>>) -> Self

A titled button (label is what it shows).

Source

pub fn symbol_title( name: impl Into<Arc<str>>, title: impl Into<Arc<str>>, ) -> Self

A button showing an SF Symbol and title after it; VoiceOver reads the title unless Self::label is set.

Source

pub fn key(self, key: impl Into<Arc<str>>) -> Self

Optional key for keeping a UIBarButtonItem across updates; also the button’s accessibility identifier, which tests name it by (id:<key>).

Source

pub fn label(self, label: impl Into<Arc<str>>) -> Self

VoiceOver’s label when the content is a system item or symbol.

Source

pub fn shares_background(self, shares: bool) -> Self

Whether the button shares its background with the bar buttons next to it (default true): on iOS 26 and later, false gives it a glass capsule of its own instead of the one its neighbors share (UIBarButtonItem.sharesBackground). Earlier iOS versions ignore it.

Source

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

Disables the button.

Source

pub fn on_press(self, f: impl Fn() + 'static) -> Self

Runs f when the button is pressed and it has no menu.

Source

pub fn menu(self, items: impl IntoIterator<Item = MenuItem>) -> Self

Opens this native menu on press (the button’s Self::on_press is unused while a menu is set).

Trait Implementations§

Source§

impl Clone for HeaderItem

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HeaderItem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl IntoReactive<HeaderItem> for HeaderItem

Auto Trait Implementations§

§

impl !RefUnwindSafe for HeaderItem

§

impl !Send for HeaderItem

§

impl !Sync for HeaderItem

§

impl !UnwindSafe for HeaderItem

§

impl Forget for HeaderItem

§

impl Freeze for HeaderItem
where *const ArcInner<str> is !null: Freeze, PhantomData<ArcInner<str>>: Freeze, *const RcInner<dyn Fn()> is !null: Freeze, PhantomData<RcInner<dyn Fn()>>: Freeze, *const u8 is !null: Freeze, PhantomData<MenuItem>: Freeze,

§

impl Move for HeaderItem

§

impl Unpin for HeaderItem
where Arc<str>: Unpin, Rc<dyn Fn()>: Unpin, *const u8 is !null: Unpin, Rc<str>: Unpin, &'static str: Unpin, Arc<dyn AsRef<[u8]> + Send + Sync>: Unpin, Arc<Rgba>: Unpin,

§

impl UnsafeUnpin for HeaderItem
where *const ArcInner<str> is !null: UnsafeUnpin, PhantomData<ArcInner<str>>: UnsafeUnpin, *const RcInner<dyn Fn()> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn()>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<MenuItem>: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.