Skip to main content

MaterialDrawer

Struct MaterialDrawer 

Source
pub struct MaterialDrawer<'a> { /* private fields */ }
Expand description

Material Design navigation drawer component.

Navigation drawers provide access to destinations and app functionality. They can be permanently on-screen or controlled by navigation triggers.

let mut drawer_open = true;

let drawer = MaterialDrawer::new(DrawerVariant::Permanent, &mut drawer_open)
    .header("Mail", Some("email@material.io"))
    .item("Inbox", Some("inbox"), true)
    .item("Sent", Some("send"), false)
    .item("Drafts", Some("drafts"), false);

drawer.show(ui.ctx());

Implementations§

Source§

impl<'a> MaterialDrawer<'a>

Source

pub fn new(variant: DrawerVariant, open: &'a mut bool) -> Self

Create a new navigation drawer with Material 3 defaults.

Source

pub fn new_with_id(variant: DrawerVariant, open: &'a mut bool, id: Id) -> Self

Create a new navigation drawer with custom ID.

Source

pub fn alignment(self, alignment: DrawerAlignment) -> Self

Set drawer alignment (start or end).

Source

pub fn width(self, width: f32) -> Self

Set drawer width.

Source

pub fn theme(self, theme: DrawerThemeData) -> Self

Set drawer theme.

Source

pub fn enable_drag_gesture(self, enable: bool) -> Self

Enable or disable drag gestures.

Source

pub fn edge_drag_width(self, width: f32) -> Self

Set the edge drag width for opening the drawer.

Source

pub fn barrier_dismissible(self, dismissible: bool) -> Self

Set whether tapping the barrier dismisses the drawer.

Source

pub fn semantic_label(self, label: impl Into<String>) -> Self

Set semantic label for accessibility.

Source

pub fn header( self, title: impl Into<String>, subtitle: Option<impl Into<String>>, ) -> Self

Add header with title and optional subtitle.

Source

pub fn item( self, text: impl Into<String>, icon: Option<impl Into<String>>, active: bool, ) -> Self

Add a navigation item.

Source

pub fn item_with_callback<F>( self, text: impl Into<String>, icon: Option<impl Into<String>>, active: bool, callback: F, ) -> Self
where F: Fn() + Send + Sync + 'static,

Add a navigation item with callback.

Source

pub fn add_item(self, item: DrawerItem) -> Self

Add a drawer item object.

Source

pub fn section( self, label: Option<impl Into<String>>, items: Vec<DrawerItem>, ) -> Self

Add a section with label and items.

Source

pub fn corner_radius(self, corner_radius: impl Into<CornerRadius>) -> Self

Set corner radius.

Source

pub fn elevation(self, elevation: f32) -> Self

Set elevation value.

Source

pub fn show(self, ctx: &Context) -> Response

Show the drawer using appropriate egui layout.

Trait Implementations§

Source§

impl Widget for MaterialDrawer<'_>

Source§

fn ui(self, ui: &mut Ui) -> Response

Allocate space, interact, paint, and return a Response. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for MaterialDrawer<'a>

§

impl<'a> !RefUnwindSafe for MaterialDrawer<'a>

§

impl<'a> Send for MaterialDrawer<'a>

§

impl<'a> Sync for MaterialDrawer<'a>

§

impl<'a> Unpin for MaterialDrawer<'a>

§

impl<'a> UnsafeUnpin for MaterialDrawer<'a>

§

impl<'a> !UnwindSafe for MaterialDrawer<'a>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> MaybeSend for T
where T: Send,