use dioxus::prelude::*;
use fermi::{AtomRef, use_atom_ref, use_init_atom_root};
use dioxus_toast::{ToastInfo, ToastManager};
fn main() {
dioxus_desktop::launch(app)
}
static TOAST_MANAGER: AtomRef<ToastManager> = |_| ToastManager::default();
fn app(cx: Scope) -> Element {
use_init_atom_root(&cx);
std::panic::set_hook(Box::new(|info| {
println!("Panic: {}", info);
}));
let toast = use_atom_ref(&cx, TOAST_MANAGER);
cx.render(rsx! {
dioxus_toast::ToastFrame {
manager: toast
}
div {
button {
onclick: move |_| {
let _id = toast.write().popup(ToastInfo::simple("hello world"));
println!("New Toast ID: {}", _id);
},
"Normal Toast"
}
button {
onclick: move |_| {
let _id = toast.write().popup(ToastInfo::success("Hello World!", "Success"));
println!("New Toast ID: {}", _id);
},
"Success Toast"
}
button {
onclick: move |_| {
let _id = toast.write().popup(ToastInfo {
heading: Some("top-right".into()),
context: "Top Right Toast".into(),
allow_toast_close: true,
position: dioxus_toast::Position::TopRight,
icon: None,
hide_after: None
});
},
"Top Right"
}
}
})
}
-
Notifications
You must be signed in to change notification settings - Fork 6
dioxus-toast
License
mrxiaozhuox/dioxus-toast
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|