Skip to main content

Alert

Struct Alert 

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

Alert component for inline messages

Built on top of the Card component with custom styling for alerts

§Example

use armas_basic::components::{Alert, AlertVariant};

fn ui(ui: &mut egui::Ui) {
    // Default info alert
    Alert::new("Operation completed").show(ui);

    // Destructive alert
    Alert::new("Something went wrong")
        .variant(AlertVariant::Destructive)
        .show(ui);

    // Custom color alert
    Alert::new("Custom alert")
        .color(egui::Color32::from_rgb(100, 200, 150))
        .show(ui);
}

Implementations§

Source§

impl Alert

Source

pub fn new(message: impl Into<String>) -> Self

Create a new alert

Source

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

Set the alert title

Source

pub const fn variant(self, variant: AlertVariant) -> Self

Set the variant

Source

pub const fn destructive(self) -> Self

Make this a destructive alert

Source

pub const fn color(self, color: Color32) -> Self

Set custom color (overrides variant color)

Source

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

Make the alert dismissible

Source

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

Set a fixed width

Source

pub const fn show_icon(self, show: bool) -> Self

Show or hide the icon

Source

pub fn show(self, ui: &mut Ui) -> AlertResponse

Show the alert using Card component

Returns AlertResponse with information about user interaction

Auto Trait Implementations§

§

impl Freeze for Alert

§

impl RefUnwindSafe for Alert

§

impl Send for Alert

§

impl Sync for Alert

§

impl Unpin for Alert

§

impl UnsafeUnpin for Alert

§

impl UnwindSafe for Alert

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, 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.