rust_kanban/ui/rendering/view/
title_body_help.rs

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