merge input into theme system

This commit is contained in:
Yifan Song 2023-09-27 13:34:51 +02:00 committed by sxyazi
parent 85a83ff731
commit 7a2384934d
No known key found for this signature in database
2 changed files with 12 additions and 7 deletions

View file

@ -2,7 +2,8 @@ use core::{input::InputMode, Ctx};
use std::ops::Range; use std::ops::Range;
use ansi_to_tui::IntoText; 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; use shared::Term;
pub(crate) struct Input<'a> { pub(crate) struct Input<'a> {
@ -30,14 +31,14 @@ impl<'a> Widget for Input<'a> {
Block::new() Block::new()
.borders(Borders::ALL) .borders(Borders::ALL)
.border_type(BorderType::Rounded) .border_type(BorderType::Rounded)
.border_style(Style::new().fg(Color::Blue)) .border_style(THEME.input.border.get())
.title({ .title({
let mut line = Line::from(input.title()); let mut line = Line::from(input.title());
line.patch_style(Style::new().fg(Color::White)); line.patch_style(THEME.input.title.get());
line line
}), }),
) )
.style(Style::new().fg(Color::White)) .style(THEME.input.text.get())
.render(area, buf); .render(area, buf);
if let Some(Range { start, end }) = input.selected() { if let Some(Range { start, end }) = input.selected() {
@ -46,7 +47,7 @@ impl<'a> Widget for Input<'a> {
buf.set_style( buf.set_style(
Rect { x, y, width: (end - start).min(win.width - x), height: 1.min(win.height - y) }, 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(),
) )
} }

View file

@ -1,7 +1,7 @@
use core::{tasks::TASKS_PERCENT, Ctx}; use core::{tasks::TASKS_PERCENT, Ctx};
use config::THEME; 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; use super::Clear;
@ -39,7 +39,11 @@ impl<'a> Widget for Layout<'a> {
Clear.render(area, buf); Clear.render(area, buf);
let block = Block::new() 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) .title_alignment(Alignment::Center)
.padding(Padding::new(0, 0, 1, 1)) .padding(Padding::new(0, 0, 1, 1))
// Maybe also add these border type in to the later theme system // Maybe also add these border type in to the later theme system