pub mod collection_dashboard;
pub mod collection_viewer;
pub mod confirm_popup;
pub mod error_popup;
pub mod input;
pub mod overlay;
mod spinner;
pub mod terminal_too_small;
mod under_construction;
use crate::event_pool::Event;
use crossterm::event::KeyEvent;
use hac_core::command::Command;
use ratatui::{layout::Rect, Frame};
use tokio::sync::mpsc::UnboundedSender;
pub trait Renderable {
fn draw(&mut self, frame: &mut Frame, size: Rect) -> anyhow::Result<()>;
#[allow(unused_variables)]
fn resize(&mut self, new_size: Rect) {}
#[allow(unused_variables)]
fn register_command_handler(&mut self, sender: UnboundedSender<Command>) -> anyhow::Result<()> {
Ok(())
}
fn handle_tick(&mut self) -> anyhow::Result<()> {
Ok(())
}
}
pub trait Eventful {
type Result;
fn handle_event(&mut self, event: Option<Event>) -> anyhow::Result<Option<Self::Result>> {
match event {
Some(Event::Key(key_event)) => self.handle_key_event(key_event),
_ => Ok(None),
}
}
#[allow(unused_variables)]
fn handle_key_event(&mut self, key_event: KeyEvent) -> anyhow::Result<Option<Self::Result>> {
Ok(None)
}
}