gitv_tui/ui/components/
mod.rs1use 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_convo_preview;
12pub mod issue_create;
13pub mod issue_detail;
14pub mod issue_list;
15pub mod label_list;
16pub mod search_bar;
17pub mod status_bar;
18pub mod title_bar;
19#[async_trait(?Send)]
22pub trait DumbComponent {
23 fn render(&mut self, area: Layout, buf: &mut Buffer);
24 fn register_action_tx(&mut self, action_tx: tokio::sync::mpsc::Sender<Action>) {
25 let _ = action_tx;
26 }
27 async fn handle_event(&mut self, event: Action) -> Result<(), AppError> {
28 let _ = event;
29 Ok(())
30 }
31}
32
33#[async_trait(?Send)]
34pub trait Component: HasFocus {
35 fn render(&mut self, area: Layout, buf: &mut Buffer);
36 fn register_action_tx(&mut self, action_tx: tokio::sync::mpsc::Sender<Action>) {
37 let _ = action_tx;
38 }
39 async fn handle_event(&mut self, event: Action) -> Result<(), AppError> {
40 let _ = event;
41 Ok(())
42 }
43 fn cursor(&self) -> Option<(u16, u16)> {
44 None
45 }
46 fn should_render(&self) -> bool {
47 true
48 }
49 fn is_animating(&self) -> bool {
50 false
51 }
52 fn capture_focus_event(&self, _event: &Event) -> bool {
53 false
54 }
55 #[allow(unused_variables)]
56 fn set_index(&mut self, index: usize) {}
57
58 fn set_global_help(&self) {}
59}