use egui::{RichText, Ui};
pub struct LoadingIndicator<'a> {
message: Option<&'a str>,
}
impl<'a> LoadingIndicator<'a> {
pub fn new() -> Self {
Self { message: None }
}
#[must_use]
pub fn message(mut self, msg: &'a str) -> Self {
self.message = Some(msg);
self
}
pub fn show(self, ui: &mut Ui) {
ui.horizontal(|ui| {
ui.spinner();
ui.label(
RichText::new(self.message.unwrap_or("Loading..."))
.color(ui.visuals().weak_text_color()),
);
});
}
}
impl Default for LoadingIndicator<'_> {
fn default() -> Self {
Self::new()
}
}