1use bevy::prelude::Resource;
6use egui::{Context, WidgetText};
7use egui_notify::{Toast, Toasts};
8
9#[derive(Resource, Default)]
11pub struct Notifications {
12 toasts: Toasts,
14}
15
16impl Notifications {
17 pub fn ui(&mut self, ctx: &Context) {
19 self.toasts.show(ctx);
20 }
21
22 pub fn info(&mut self, text: impl Into<WidgetText>) {
24 let toast = Toast::info(text);
25
26 self.toasts.add(toast);
27 }
28
29 pub fn warn(&mut self, text: impl Into<WidgetText>) {
31 let toast = Toast::warning(text);
32
33 self.toasts.add(toast);
34 }
35
36 pub fn error(&mut self, text: impl Into<WidgetText>) {
38 let toast = Toast::error(text);
39
40 self.toasts.add(toast);
41 }
42}