pub struct ToastHost<A = ()> { /* private fields */ }Expand description
A full-slot host that overlays a stack of toasts over one optional child.
The host itself is never focusable. Close activation is pointer-only and checks visible values in reverse order. Bound mode removes all matching IDs; controlled/static mode reports dismissal but cannot mutate its source. Toasts are not clipped or virtualized and may extend outside a small host.
§Examples
use ailloli_ui_widgets::controls::{Toast, ToastHost};
let host: ToastHost<()> = ToastHost::new().toast(Toast::new("saved", "Saved"));
let _ = host;Implementations§
Source§impl<A: 'static> ToastHost<A>
impl<A: 'static> ToastHost<A>
Sourcepub fn height(self, value: impl Into<Length>) -> Self
pub fn height(self, value: impl Into<Length>) -> Self
Sets preferred height from a logical-pixel or length value.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().height(40.0);
let _ = widget;Sourcepub fn min_width(self, value: impl Into<Length>) -> Self
pub fn min_width(self, value: impl Into<Length>) -> Self
Sets the minimum width bound.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().min_width(40.0);
let _ = widget;Sourcepub fn max_width(self, value: impl Into<Length>) -> Self
pub fn max_width(self, value: impl Into<Length>) -> Self
Sets the maximum width bound.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().max_width(320.0);
let _ = widget;Sourcepub fn min_height(self, value: impl Into<Length>) -> Self
pub fn min_height(self, value: impl Into<Length>) -> Self
Sets the minimum height bound.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().min_height(24.0);
let _ = widget;Sourcepub fn max_height(self, value: impl Into<Length>) -> Self
pub fn max_height(self, value: impl Into<Length>) -> Self
Sets the maximum height bound.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().max_height(240.0);
let _ = widget;Sourcepub fn fill(self) -> Self
pub fn fill(self) -> Self
Sets both preferred axes to parent fill.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().fill();
let _ = widget;Sourcepub fn fill_width(self) -> Self
pub fn fill_width(self) -> Self
Sets preferred width to parent fill.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().fill_width();
let _ = widget;Sourcepub fn fill_height(self) -> Self
pub fn fill_height(self) -> Self
Sets preferred height to parent fill.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().fill_height();
let _ = widget;Sourcepub fn margin(self, value: f32) -> Self
pub fn margin(self, value: f32) -> Self
Sets uniform outer margin in logical pixels.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().margin(8.0);
let _ = widget;Sourcepub fn padding(self, value: f32) -> Self
pub fn padding(self, value: f32) -> Self
Sets uniform inner padding in logical pixels.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().padding(8.0);
let _ = widget;Sourcepub fn flex_grow(self) -> Self
pub fn flex_grow(self) -> Self
Sets flex-grow weight to one.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().flex_grow();
let _ = widget;Sourcepub fn flex_grow_by(self, value: f32) -> Self
pub fn flex_grow_by(self, value: f32) -> Self
Sets a dimensionless flex-grow weight.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().flex_grow_by(2.0);
let _ = widget;Sourcepub fn flex_shrink(self, value: f32) -> Self
pub fn flex_shrink(self, value: f32) -> Self
Sets a dimensionless flex-shrink weight.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().flex_shrink(1.0);
let _ = widget;Sourcepub fn flex_basis(self, value: impl Into<Length>) -> Self
pub fn flex_basis(self, value: impl Into<Length>) -> Self
Sets the preferred main-axis flex basis.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().flex_basis(80.0);
let _ = widget;Sourcepub fn align_self(self, value: AlignItems) -> Self
pub fn align_self(self, value: AlignItems) -> Self
Overrides cross-axis alignment for this flex item.
§Examples
use ailloli_ui_core::style::AlignItems;
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().align_self(AlignItems::Center);
let _ = widget;Source§impl<A: 'static> ToastHost<A>
impl<A: 'static> ToastHost<A>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty top-right host with no child or dismissal callback.
§Examples
use ailloli_ui_widgets::controls::ToastHost;
let host: ToastHost<()> = ToastHost::new();
let _ = host;Sourcepub fn toast(self, toast: Toast) -> Self
pub fn toast(self, toast: Toast) -> Self
Appends one toast to a snapshot of the current binding.
This converts the result to static mode and clears a writable binding. Repeated calls preserve order and grow an unbounded vector.
§Examples
use ailloli_ui_widgets::controls::{Toast, ToastHost};
let host: ToastHost<()> = ToastHost::new().toast(Toast::new("one", "First"));
let _ = host;Sourcepub fn toasts(self, toasts: impl Into<Binding<Vec<Toast>>>) -> Self
pub fn toasts(self, toasts: impl Into<Binding<Vec<Toast>>>) -> Self
Replaces the static or reactive controlled toast list.
This clears bound mode, so close activation cannot mutate the source. The callback can be used to ask the consumer to update it.
§Examples
use ailloli_ui_widgets::controls::{Toast, ToastHost};
let host: ToastHost<()> = ToastHost::new().toasts(vec![Toast::new("one", "First")]);
let _ = host;Sourcepub fn bind_toasts(self, toasts: impl Into<Signal<Vec<Toast>>>) -> Self
pub fn bind_toasts(self, toasts: impl Into<Signal<Vec<Toast>>>) -> Self
Installs a writable signal for two-way dismissal.
Close activation removes every toast whose ID equals the activated ID, then invokes the optional callback once.
§Examples
use std::{cell::RefCell, rc::Rc};
use ailloli_ui_runtime::component::Signal;
use ailloli_ui_widgets::controls::{Toast, ToastHost};
let toasts = Signal::new(Rc::new(RefCell::new(vec![Toast::new("one", "First")])), Rc::new(|| {}));
let host: ToastHost<()> = ToastHost::new().bind_toasts(toasts);
let _ = host;Sourcepub fn position(self, position: ToastPosition) -> Self
pub fn position(self, position: ToastPosition) -> Self
Selects the corner and vertical stacking direction.
§Examples
use ailloli_ui_widgets::controls::{ToastHost, ToastPosition};
let host: ToastHost<()> = ToastHost::new().position(ToastPosition::BottomLeft);
let _ = host;Sourcepub fn toast_style(self, style: ToastStyle) -> Self
pub fn toast_style(self, style: ToastStyle) -> Self
Replaces complete toast-stack style and geometry.
§Examples
use ailloli_ui_core::Theme;
use ailloli_ui_widgets::controls::{ToastHost, ToastStyle};
let style = ToastStyle::from_theme(Theme::dark());
let host: ToastHost<()> = ToastHost::new().toast_style(style);
let _ = host;Sourcepub fn on_dismiss(self, f: impl Fn(String) -> A + 'static) -> Self
pub fn on_dismiss(self, f: impl Fn(String) -> A + 'static) -> Self
Maps each dismissed ID to an application action and dispatches it.
The mapper runs after bound values are removed. A later handler replaces it.
§Examples
use ailloli_ui_widgets::controls::ToastHost;
enum Action { Dismissed(String) }
let host = ToastHost::new().on_dismiss(Action::Dismissed);
let _ = host;Sourcepub fn on_dismiss_ctx(
self,
f: impl Fn(&mut EventCtx<A>, String) + 'static,
) -> Self
pub fn on_dismiss_ctx( self, f: impl Fn(&mut EventCtx<A>, String) + 'static, ) -> Self
Installs a context-aware dismissal callback.
§Examples
use ailloli_ui_widgets::controls::ToastHost;
let host = ToastHost::<()>::new().on_dismiss_ctx(|ctx, _id| ctx.request_repaint());
let _ = host;