pub struct BadgeView<State: 'static> { /* private fields */ }Expand description
A declarative badge wrapping any child view. See the module docs.
Implementations§
Source§impl<State: 'static> BadgeView<State>
impl<State: 'static> BadgeView<State>
Sourcepub fn dot(self) -> Self
pub fn dot(self) -> Self
Show an unlabeled dot — wins over Self::count if both are set.
Sourcepub fn count(self, count: u32) -> Self
pub fn count(self, count: u32) -> Self
Show a numeric label, formatted against Self::max_count (default
[DEFAULT_MAX_COUNT], 99 — e.g. 150 paints "99+").
Sourcepub fn max_count(self, max_count: u32) -> Self
pub fn max_count(self, max_count: u32) -> Self
Override the overflow ceiling Self::count formats against.
[DEFAULT_MAX_COUNT] (99) unless set.
Sourcepub fn alignment(self, alignment: BadgeAlignment) -> Self
pub fn alignment(self, alignment: BadgeAlignment) -> Self
Anchor the indicator at a different top-edge corner.
BadgeAlignment::TopRight by default.
Sourcepub fn offset(self, offset: Vec2) -> Self
pub fn offset(self, offset: Vec2) -> Self
Override the nudge away from the anchored edge. [DEFAULT_OFFSET]
((8, -6)) unless set; dx is ignored when
BadgeAlignment::TopCenter.
Sourcepub fn background_color(self, color: Color) -> Self
pub fn background_color(self, color: Color) -> Self
Override the theme-resolved errorContainer container fill.
Sourcepub fn foreground_color(self, color: Color) -> Self
pub fn foreground_color(self, color: Color) -> Self
Override the theme-resolved onErrorContainer label/dot ink.
Sourcepub fn semantic_label(self, label: impl Into<String>) -> Self
pub fn semantic_label(self, label: impl Into<String>) -> Self
Override the indicator’s accessibility label. Defaults to
"Notifications: {count}" for a numeric badge or "Notifications"
for a dot (the reference’s own default label text).
Trait Implementations§
Source§impl<State: 'static> View<State> for BadgeView<State>
impl<State: 'static> View<State> for BadgeView<State>
Source§type Element = BadgeWidget
type Element = BadgeWidget
Source§fn build(&self, ctx: &mut BuildCtx<'_>) -> BadgeWidget
fn build(&self, ctx: &mut BuildCtx<'_>) -> BadgeWidget
Source§fn rebuild(
&self,
prev: &Self,
element: &mut BadgeWidget,
ctx: &mut BuildCtx<'_>,
) -> ChangeFlags
fn rebuild( &self, prev: &Self, element: &mut BadgeWidget, ctx: &mut BuildCtx<'_>, ) -> ChangeFlags
prev (the previous view of the same type) against the live
element, mutating it in place and reporting what changed.Auto Trait Implementations§
impl<State> !RefUnwindSafe for BadgeView<State>
impl<State> !Send for BadgeView<State>
impl<State> !Sync for BadgeView<State>
impl<State> !UnwindSafe for BadgeView<State>
impl<State> Freeze for BadgeView<State>
impl<State> Unpin for BadgeView<State>
impl<State> UnsafeUnpin for BadgeView<State>where
AnyView<State>: UnsafeUnpin,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Source§impl<State, V> ViewSeq<State, One> for Vwhere
State: 'static,
V: View<State>,
impl<State, V> ViewSeq<State, One> for Vwhere
State: 'static,
V: View<State>,
Source§fn extend_views(self, out: &mut Vec<AnyView<State>>)
fn extend_views(self, out: &mut Vec<AnyView<State>>)
out — erasing each
with AnyView::new (a no-op for an element already an AnyView).