Skip to main content

gitv_tui/ui/components/
mod.rs

1use async_trait::async_trait;
2use rat_widget::focus::HasFocus;
3use ratatui::buffer::Buffer;
4
5use crate::errors::AppError;
6use crate::ui::{Action, layout::Layout};
7use ratatui::crossterm::event::Event;
8
9pub mod help;
10pub mod issue_conversation;
11pub mod issue_create;
12pub mod issue_detail;
13pub mod issue_list;
14pub mod label_list;
15pub mod search_bar;
16pub mod status_bar;
17pub mod title_bar;
18
19#[async_trait(?Send)]
20pub trait DumbComponent {
21    fn render(&mut self, area: Layout, buf: &mut Buffer);
22    fn register_action_tx(&mut self, action_tx: tokio::sync::mpsc::Sender<Action>) {
23        let _ = action_tx;
24    }
25    async fn handle_event(&mut self, event: Action) -> Result<(), AppError> {
26        let _ = event;
27        Ok(())
28    }
29}
30
31#[async_trait(?Send)]
32pub trait Component: HasFocus {
33    fn render(&mut self, area: Layout, buf: &mut Buffer);
34    fn register_action_tx(&mut self, action_tx: tokio::sync::mpsc::Sender<Action>) {
35        let _ = action_tx;
36    }
37    async fn handle_event(&mut self, event: Action) -> Result<(), AppError> {
38        let _ = event;
39        Ok(())
40    }
41    fn cursor(&self) -> Option<(u16, u16)> {
42        None
43    }
44    fn should_render(&self) -> bool {
45        true
46    }
47    fn is_animating(&self) -> bool {
48        false
49    }
50    fn capture_focus_event(&self, _event: &Event) -> bool {
51        false
52    }
53    #[allow(unused_variables)]
54    fn set_index(&mut self, index: usize) {}
55
56    fn set_global_help(&self) {}
57}