1use ratatui::style::{Modifier, Style};
2
3use crate::app::App;
5use crate::config::app_config::Theme;
6
7pub const SMALL_TERMINAL_HEIGHT: u16 = 45;
8
9pub fn get_color(is_active: bool, theme: Theme) -> Style {
10 match is_active {
11 true => Style::default()
12 .fg(theme.selected)
13 .add_modifier(Modifier::BOLD),
14 _ => Style::default().fg(theme.inactive),
15 }
16}
17
18pub fn capitalize_each_word(text: String) -> String {
19 text.split_whitespace()
20 .map(|word| {
21 let mut c = word.chars();
22 match c.next() {
23 None => String::new(),
24 Some(f) => f.to_uppercase().collect::<String>() + c.as_str(),
25 }
26 })
27 .collect::<Vec<String>>()
28 .join(" ")
29}
30
31pub fn get_main_layout_margin(app: &App) -> u16 {
32 if app.size.height > SMALL_TERMINAL_HEIGHT {
33 1
34 } else {
35 0
36 }
37}