mod async_button;
mod async_search;
mod async_view;
mod popups;
mod refresh_button;
pub use async_button::AsyncButton;
pub use async_search::AsyncSearch;
pub use async_view::{AsyncView, StateLayout};
pub use popups::{ErrorPopup, NotifyPopup};
pub use refresh_button::RefreshButton;
use crate::bind::{Bind, MaybeSend};
pub trait UiExt {
fn popup_error(&self, error: &str) -> bool;
fn popup_notify(&self, info: &str) -> bool;
fn refresh_button<T, E, Fut>(
&mut self,
bind: &mut Bind<T, E>,
f: impl FnOnce() -> Fut,
secs: f64,
) where
Fut: Future<Output = Result<T, E>> + MaybeSend + 'static,
T: MaybeSend + 'static,
E: MaybeSend + 'static;
}
impl UiExt for egui::Ui {
fn popup_error(&self, error: &str) -> bool {
ErrorPopup::new(error).show(self.ctx())
}
fn popup_notify(&self, info: &str) -> bool {
NotifyPopup::new(info).show(self.ctx())
}
fn refresh_button<T, E, Fut>(
&mut self,
bind: &mut Bind<T, E>,
f: impl FnOnce() -> Fut,
secs: f64,
) where
Fut: Future<Output = Result<T, E>> + MaybeSend + 'static,
T: MaybeSend + 'static,
E: MaybeSend + 'static,
{
RefreshButton::new(bind).interval_secs(secs).show(self, f);
}
}