From 7a2384934d12b541960131833696908ef7ac8fb3 Mon Sep 17 00:00:00 2001 From: Yifan Song Date: Wed, 27 Sep 2023 13:34:51 +0200 Subject: [PATCH] merge input into theme system --- app/src/input/input.rs | 11 ++++++----- app/src/tasks/layout.rs | 8 ++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/input/input.rs b/app/src/input/input.rs index b4935dd6..0946ddaa 100644 --- a/app/src/input/input.rs +++ b/app/src/input/input.rs @@ -2,7 +2,8 @@ use core::{input::InputMode, Ctx}; use std::ops::Range; use ansi_to_tui::IntoText; -use ratatui::{buffer::Buffer, layout::Rect, style::{Color, Style}, text::{Line, Text}, widgets::{Block, BorderType, Borders, Clear, Paragraph, Widget}}; +use config::THEME; +use ratatui::{buffer::Buffer, layout::Rect, text::{Line, Text}, widgets::{Block, BorderType, Borders, Clear, Paragraph, Widget}}; use shared::Term; pub(crate) struct Input<'a> { @@ -30,14 +31,14 @@ impl<'a> Widget for Input<'a> { Block::new() .borders(Borders::ALL) .border_type(BorderType::Rounded) - .border_style(Style::new().fg(Color::Blue)) + .border_style(THEME.input.border.get()) .title({ let mut line = Line::from(input.title()); - line.patch_style(Style::new().fg(Color::White)); + line.patch_style(THEME.input.title.get()); line }), ) - .style(Style::new().fg(Color::White)) + .style(THEME.input.text.get()) .render(area, buf); if let Some(Range { start, end }) = input.selected() { @@ -46,7 +47,7 @@ impl<'a> Widget for Input<'a> { buf.set_style( Rect { x, y, width: (end - start).min(win.width - x), height: 1.min(win.height - y) }, - Style::new().bg(Color::Rgb(72, 77, 102)), + THEME.input.visual.get(), ) } diff --git a/app/src/tasks/layout.rs b/app/src/tasks/layout.rs index 3d886e00..7c61c205 100644 --- a/app/src/tasks/layout.rs +++ b/app/src/tasks/layout.rs @@ -1,7 +1,7 @@ use core::{tasks::TASKS_PERCENT, Ctx}; use config::THEME; -use ratatui::{buffer::Buffer, layout::{self, Alignment, Constraint, Direction, Rect}, widgets::{Block, BorderType, Borders, List, ListItem, Padding, Widget}}; +use ratatui::{buffer::Buffer, layout::{self, Alignment, Constraint, Direction, Rect}, text::Line, widgets::{Block, BorderType, Borders, List, ListItem, Padding, Widget}}; use super::Clear; @@ -39,7 +39,11 @@ impl<'a> Widget for Layout<'a> { Clear.render(area, buf); let block = Block::new() - .title("Tasks") + .title({ + let mut line = Line::from("Tasks".to_string()); + line.patch_style(THEME.tasks.title.get()); + line +}) .title_alignment(Alignment::Center) .padding(Padding::new(0, 0, 1, 1)) // Maybe also add these border type in to the later theme system