feat(tui): give the panes the colour the demo promised
The cursor row set a foreground, and ratatui only skips a cell's colour when that field is None — so selecting a row repainted its gold sizes, blue usernames and status glyphs into one flat cream. Table cursors now tint the background only, over a warm oxide wash instead of neutral. Browse files, their sizes and the settings popup rendered in the raw terminal foreground; they take the palette now, and free slots read green when a peer has one.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
use crate::models::{BrowseState, BrowseStatus, BrowseTabs};
|
||||
use crate::ui::{
|
||||
HIGHLIGHT_SYMBOL, dimmed_style, error_style, format_bytes,
|
||||
HIGHLIGHT_SYMBOL, body_style, dimmed_style, error_style, format_bytes,
|
||||
get_spinner_char, highlight_style, pane_block, primary_style,
|
||||
row_highlight_style, warning_style,
|
||||
};
|
||||
use ratatui::{
|
||||
Frame,
|
||||
@@ -76,11 +77,17 @@ fn render_browse_one(
|
||||
get_spinner_char(spinner_state),
|
||||
browse.username
|
||||
);
|
||||
frame.render_widget(Paragraph::new(text).block(block), area);
|
||||
frame.render_widget(
|
||||
Paragraph::new(text).style(dimmed_style()).block(block),
|
||||
area,
|
||||
);
|
||||
}
|
||||
BrowseStatus::Empty => {
|
||||
let text = format!("{} is not sharing any files.", browse.username);
|
||||
frame.render_widget(Paragraph::new(text).block(block), area);
|
||||
frame.render_widget(
|
||||
Paragraph::new(text).style(dimmed_style()).block(block),
|
||||
area,
|
||||
);
|
||||
}
|
||||
BrowseStatus::TimedOut => {
|
||||
let text = vec![
|
||||
@@ -89,11 +96,12 @@ fn render_browse_one(
|
||||
error_style(),
|
||||
),
|
||||
Line::raw(""),
|
||||
Line::raw(
|
||||
Line::styled(
|
||||
"They may be offline, or their connection can't be \
|
||||
reached (both of you may be behind a router/firewall).",
|
||||
body_style(),
|
||||
),
|
||||
Line::raw("Press r to try again."),
|
||||
Line::styled("Press r to try again.", dimmed_style()),
|
||||
];
|
||||
frame.render_widget(Paragraph::new(text).block(block), area);
|
||||
}
|
||||
@@ -107,15 +115,20 @@ fn render_browse_one(
|
||||
let glyph = if row.expanded { "▾" } else { "▸" };
|
||||
(
|
||||
Cell::from(format!("{indent}{glyph} {}", row.name))
|
||||
.style(primary_style()),
|
||||
.style(
|
||||
primary_style()
|
||||
.add_modifier(Modifier::BOLD),
|
||||
),
|
||||
Cell::from(String::new()),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
Cell::from(format!("{indent} {}", row.name)),
|
||||
Cell::from(format!("{indent} {}", row.name))
|
||||
.style(body_style()),
|
||||
Cell::from(
|
||||
row.size.map(format_bytes).unwrap_or_default(),
|
||||
),
|
||||
)
|
||||
.style(warning_style()),
|
||||
)
|
||||
};
|
||||
Row::new(vec![label, size])
|
||||
@@ -124,7 +137,7 @@ fn render_browse_one(
|
||||
|
||||
let table =
|
||||
Table::new(rows, [Constraint::Fill(1), Constraint::Length(12)])
|
||||
.row_highlight_style(highlight_style())
|
||||
.row_highlight_style(row_highlight_style())
|
||||
.highlight_symbol(HIGHLIGHT_SYMBOL)
|
||||
.highlight_spacing(HighlightSpacing::Always)
|
||||
.block(block);
|
||||
|
||||
@@ -199,12 +199,16 @@ fn build_info_lines(
|
||||
lines.push(label_value("Queue position", &position_text));
|
||||
|
||||
if let Some(slots) = download.metadata.peer_free_slots {
|
||||
let slot_text = if slots > 0 {
|
||||
format!("{slots} available")
|
||||
let (slot_text, slot_style) = if slots > 0 {
|
||||
(format!("{slots} available"), success_style())
|
||||
} else {
|
||||
"all busy".to_string()
|
||||
("all busy".to_string(), inactive_style())
|
||||
};
|
||||
lines.push(label_value("Free slots", &slot_text));
|
||||
lines.push(label_value_styled(
|
||||
"Free slots",
|
||||
slot_text,
|
||||
slot_style,
|
||||
));
|
||||
}
|
||||
|
||||
if let Some(speed) = download.metadata.peer_upload_speed {
|
||||
|
||||
@@ -2,8 +2,9 @@ use crate::models::DownloadEntry;
|
||||
use crate::ui::{
|
||||
GLYPH_ACTIVE, GLYPH_DONE, GLYPH_FAILED, HIGHLIGHT_SYMBOL, accent_style,
|
||||
body_style, dimmed_style, download_status_glyph, error_style, format_bytes,
|
||||
format_speed, header_style, highlight_style, inactive_style, info_style,
|
||||
pane_block, pane_title, primary_style, success_style, warning_style,
|
||||
format_speed, header_style, inactive_style, info_style, pane_block,
|
||||
pane_title, primary_style, row_highlight_style, success_style,
|
||||
warning_style,
|
||||
};
|
||||
use ratatui::{
|
||||
Frame,
|
||||
@@ -173,7 +174,7 @@ pub fn render_downloads_pane(
|
||||
|
||||
let table = Table::new(rows, widths)
|
||||
.header(header)
|
||||
.row_highlight_style(highlight_style())
|
||||
.row_highlight_style(row_highlight_style())
|
||||
.highlight_symbol(HIGHLIGHT_SYMBOL)
|
||||
.highlight_spacing(HighlightSpacing::Always)
|
||||
.block(pane_block(focused).title(pane_title(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::models::FileDisplayData;
|
||||
use crate::ui::{
|
||||
BYTES_PER_MB, HIGHLIGHT_SYMBOL, body_style, dimmed_style, format_bytes,
|
||||
header_style, highlight_style, info_style, pane_block, pane_title,
|
||||
header_style, info_style, pane_block, pane_title, row_highlight_style,
|
||||
success_style, warning_style,
|
||||
};
|
||||
use ratatui::{
|
||||
@@ -167,7 +167,7 @@ pub fn render_results_pane(
|
||||
|
||||
let table = Table::new(rows, widths)
|
||||
.header(header)
|
||||
.row_highlight_style(highlight_style())
|
||||
.row_highlight_style(row_highlight_style())
|
||||
.highlight_symbol(HIGHLIGHT_SYMBOL)
|
||||
.highlight_spacing(HighlightSpacing::Always)
|
||||
.block(pane_block(focused).title(pane_title("2", &title, focused)));
|
||||
|
||||
@@ -2,6 +2,7 @@ use crate::models::{RoomsState, RoomsView};
|
||||
use crate::ui::{
|
||||
HIGHLIGHT_SYMBOL, PANE_PADDING, accent_style, dimmed_style,
|
||||
highlight_style, info_style, pane_block, plain_title, primary_style,
|
||||
row_highlight_style,
|
||||
};
|
||||
use ratatui::{
|
||||
Frame,
|
||||
@@ -84,7 +85,7 @@ fn render_list(
|
||||
let table =
|
||||
Table::new(table_rows, [Constraint::Fill(1), Constraint::Length(8)])
|
||||
.header(header)
|
||||
.row_highlight_style(highlight_style())
|
||||
.row_highlight_style(row_highlight_style())
|
||||
.highlight_symbol(HIGHLIGHT_SYMBOL)
|
||||
.highlight_spacing(HighlightSpacing::Always)
|
||||
.block(block);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::models::{SearchEntry, SearchStatus};
|
||||
use crate::ui::{
|
||||
HIGHLIGHT_SYMBOL, body_style, dimmed_style, header_style, highlight_style,
|
||||
pane_block, pane_title, success_style, warning_style,
|
||||
HIGHLIGHT_SYMBOL, body_style, dimmed_style, header_style, pane_block,
|
||||
pane_title, row_highlight_style, success_style, warning_style,
|
||||
};
|
||||
use ratatui::{
|
||||
Frame,
|
||||
@@ -60,7 +60,7 @@ pub fn render_searches_pane(
|
||||
|
||||
let table = Table::new(rows, widths)
|
||||
.header(header)
|
||||
.row_highlight_style(highlight_style())
|
||||
.row_highlight_style(row_highlight_style())
|
||||
.highlight_symbol(HIGHLIGHT_SYMBOL)
|
||||
.highlight_spacing(HighlightSpacing::Always)
|
||||
.block(pane_block(focused).title(pane_title("1", "Searches", focused)));
|
||||
|
||||
Reference in New Issue
Block a user