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