rust_kanban/ui/rendering/view/
help_menu.rs

1use crate::{
2    app::App,
3    ui::{
4        rendering::{
5            common::{draw_help, render_close_button, render_logs},
6            utils::check_if_active_and_get_style,
7            view::HelpMenu,
8        },
9        Renderable,
10    },
11};
12use ratatui::{
13    layout::{Constraint, Direction, Layout},
14    widgets::{Block, Borders},
15    Frame,
16};
17
18impl Renderable for HelpMenu {
19    fn render(rect: &mut Frame, app: &mut App, is_active: bool) {
20        let chunks = Layout::default()
21            .direction(Direction::Vertical)
22            .constraints([Constraint::Fill(1), Constraint::Length(4)].as_ref())
23            .split(rect.area());
24
25        let help_chunks = Layout::default()
26            .direction(Direction::Horizontal)
27            .constraints(
28                [
29                    Constraint::Fill(1),
30                    Constraint::Length(1),
31                    Constraint::Fill(1),
32                ]
33                .as_ref(),
34            )
35            .margin(1)
36            .split(chunks[0]);
37
38        let general_style = check_if_active_and_get_style(
39            is_active,
40            app.current_theme.inactive_text_style,
41            app.current_theme.general_style,
42        );
43
44        let help_menu = draw_help(app, chunks[0], is_active);
45        let help_separator = Block::default()
46            .borders(Borders::LEFT)
47            .border_style(general_style);
48
49        rect.render_widget(help_menu.0, chunks[0]);
50        rect.render_stateful_widget(
51            help_menu.1,
52            help_chunks[0],
53            &mut app.state.app_table_states.help,
54        );
55        rect.render_widget(help_separator, help_chunks[1]);
56        rect.render_stateful_widget(
57            help_menu.2,
58            help_chunks[2],
59            &mut app.state.app_table_states.help,
60        );
61        render_logs(app, true, chunks[1], rect, is_active);
62        if app.config.enable_mouse_support {
63            render_close_button(rect, app, is_active);
64        }
65    }
66}