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