1pub mod collection_dashboard;
2pub mod collection_viewer;
3pub mod confirm_popup;
4pub mod error_popup;
5pub mod input;
6pub mod overlay;
7mod spinner;
8pub mod terminal_too_small;
9mod under_construction;
10
11use crate::event_pool::Event;
12use crossterm::event::KeyEvent;
13use hac_core::command::Command;
14use ratatui::{layout::Rect, Frame};
15use tokio::sync::mpsc::UnboundedSender;
16
17pub trait Renderable {
19 fn draw(&mut self, frame: &mut Frame, size: Rect) -> anyhow::Result<()>;
20
21 #[allow(unused_variables)]
24 fn resize(&mut self, new_size: Rect) {}
25
26 #[allow(unused_variables)]
29 fn register_command_handler(&mut self, sender: UnboundedSender<Command>) -> anyhow::Result<()> {
30 Ok(())
31 }
32
33 fn handle_tick(&mut self) -> anyhow::Result<()> {
36 Ok(())
37 }
38}
39
40pub trait Eventful {
43 type Result;
44
45 fn handle_event(&mut self, event: Option<Event>) -> anyhow::Result<Option<Self::Result>> {
48 match event {
49 Some(Event::Key(key_event)) => self.handle_key_event(key_event),
50 _ => Ok(None),
51 }
52 }
53
54 #[allow(unused_variables)]
56 fn handle_key_event(&mut self, key_event: KeyEvent) -> anyhow::Result<Option<Self::Result>> {
57 Ok(None)
58 }
59}