rust_kanban/ui/rendering/popup/
save_theme_prompt.rs1use crate::{
2 app::{state::Focus, App},
3 ui::{
4 rendering::{
5 common::{render_blank_styled_canvas, render_close_button},
6 popup::SaveThemePrompt,
7 utils::{
8 centered_rect_with_length, check_if_active_and_get_style,
9 get_mouse_focusable_field_style,
10 },
11 },
12 Renderable,
13 },
14};
15use ratatui::{
16 layout::{Alignment, Constraint, Direction, Layout},
17 widgets::{Block, BorderType, Borders, Paragraph},
18 Frame,
19};
20
21impl Renderable for SaveThemePrompt {
22 fn render(rect: &mut Frame, app: &mut App, is_active: bool) {
23 let popup_area = centered_rect_with_length(40, 10, rect.area());
24 let chunks = Layout::default()
25 .direction(Direction::Vertical)
26 .constraints([Constraint::Fill(1), Constraint::Fill(1)].as_ref())
27 .margin(2)
28 .split(popup_area);
29
30 let save_theme_button_style =
31 get_mouse_focusable_field_style(app, Focus::SubmitButton, &chunks[0], is_active, false);
32 let dont_save_theme_button_style =
33 get_mouse_focusable_field_style(app, Focus::ExtraFocus, &chunks[1], is_active, false);
34 let general_style = check_if_active_and_get_style(
35 is_active,
36 app.current_theme.inactive_text_style,
37 app.current_theme.general_style,
38 );
39 let save_theme_button = Paragraph::new("Save Theme to File")
40 .style(save_theme_button_style)
41 .block(
42 Block::default()
43 .borders(Borders::ALL)
44 .border_type(BorderType::Rounded)
45 .border_style(save_theme_button_style),
46 )
47 .alignment(Alignment::Center);
48 let dont_save_theme_button = Paragraph::new("Don't Save Theme to File")
49 .style(dont_save_theme_button_style)
50 .block(
51 Block::default()
52 .borders(Borders::ALL)
53 .border_type(BorderType::Rounded)
54 .border_style(dont_save_theme_button_style),
55 )
56 .alignment(Alignment::Center);
57 let border_block = Block::default()
58 .title("Save Theme?")
59 .borders(Borders::ALL)
60 .border_type(BorderType::Rounded)
61 .border_style(general_style);
62
63 render_blank_styled_canvas(rect, &app.current_theme, popup_area, is_active);
64 rect.render_widget(save_theme_button, chunks[0]);
65 rect.render_widget(dont_save_theme_button, chunks[1]);
66 rect.render_widget(border_block, popup_area);
67 if app.config.enable_mouse_support {
68 render_close_button(rect, app, is_active)
69 }
70 }
71}