pub struct TabStrip<Msg: Clone> { /* private fields */ }Expand description
The open documents, as a strip on a desktop and a bar on a phone.
On a desktop, a strip of tabs with their icon, title and close button, sharing the width between a minimum and a part of the
screen and scrolling sideways when even the minimum does not fit; buttons may go before the tabs, right after the last one
and at the far right, and part of the width is always left clear. On a phone, a bar with the active tab and a counter that
asks for the TabOverview, a grid of cards of every tab.
The widget is stateless but for its TabMotion, which the app keeps so tabs grow, shrink and slide as they open and close:
tab_strip( self.titles.iter().map( |( key, title )| tab( *key, title.clone() ).symbol( "features/console" ) ) )
.selected( self.active )
.on_select( Msg::Select )
.on_close( Msg::Close )
.on_overview( Msg::Overview )
.layout( if self.phone { TabLayout::Mobile } else { TabLayout::Desktop } )
.motion( &self.motion )
.into()Implementations§
Source§impl<Msg: Clone + 'static> TabStrip<Msg>
impl<Msg: Clone + 'static> TabStrip<Msg>
pub fn new(tabs: impl IntoIterator<Item = TabItem>) -> Self
pub fn selected(self, idx: usize) -> Self
Sourcepub fn on_select(self, f: impl Fn(usize) -> Msg + 'static) -> Self
pub fn on_select(self, f: impl Fn(usize) -> Msg + 'static) -> Self
Called with the index of the tab pressed.
Sourcepub fn on_close(self, f: impl Fn(usize) -> Msg + 'static) -> Self
pub fn on_close(self, f: impl Fn(usize) -> Msg + 'static) -> Self
Called with the index of the tab whose close button was pressed.
Sourcepub fn on_overview(self, msg: Msg) -> Self
pub fn on_overview(self, msg: Msg) -> Self
The message the phone bar’s counter sends, to show the TabOverview. Without it the bar has no counter.
Sourcepub fn reorderable(self, reorderable: bool) -> Self
pub fn reorderable(self, reorderable: bool) -> Self
Whether the desktop strip’s tabs can be dragged into another order; the app forwards the drag to the
TabMotion and moves the tab TabMotion::drag_end reports. Dragging a tab selects it. Default: false.
Sourcepub fn leading(self, button: impl Into<Element<Msg>>) -> Self
pub fn leading(self, button: impl Into<Element<Msg>>) -> Self
A button at the far left, before the tabs; also at the left of the phone bar.
Sourcepub fn after_tabs(self, button: impl Into<Element<Msg>>) -> Self
pub fn after_tabs(self, button: impl Into<Element<Msg>>) -> Self
A button right after the last tab, such as a new tab button. Not on the phone bar: the overview’s header has those.
Sourcepub fn trailing(self, button: impl Into<Element<Msg>>) -> Self
pub fn trailing(self, button: impl Into<Element<Msg>>) -> Self
A button at the far right; also at the right of the phone bar.
Sourcepub fn mobile_center(self, center: impl Into<Element<Msg>>) -> Self
pub fn mobile_center(self, center: impl Into<Element<Msg>>) -> Self
What the phone bar shows in place of the active tab’s icon and title, such as an address field.
pub fn colors(self, colors: TabStripColors) -> Self
pub fn layout(self, layout: TabLayout) -> Self
Sourcepub fn motion(self, motion: &TabMotion) -> Self
pub fn motion(self, motion: &TabMotion) -> Self
The animation state the app keeps; without it the tabs do not animate.
pub fn build(self) -> Element<Msg>
Trait Implementations§
Auto Trait Implementations§
impl<Msg> Freeze for TabStrip<Msg>where
Msg: Freeze,
impl<Msg> !RefUnwindSafe for TabStrip<Msg>
impl<Msg> !Send for TabStrip<Msg>
impl<Msg> !Sync for TabStrip<Msg>
impl<Msg> Unpin for TabStrip<Msg>where
Msg: Unpin,
impl<Msg> !UnwindSafe for TabStrip<Msg>
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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