Fixed status icon background
This commit is contained in:
+2
-1
@@ -152,7 +152,8 @@ fn draw_tile_meta(
|
|||||||
availability: Option<Availability>,
|
availability: Option<Availability>,
|
||||||
selected: bool,
|
selected: bool,
|
||||||
) {
|
) {
|
||||||
let marker = availability.map(|availability| availability_marker(availability, selected));
|
let selected_style = selected.then(|| theme::tab_active_for(state));
|
||||||
|
let marker = availability.map(|availability| availability_marker(availability, selected_style));
|
||||||
let marker_width = marker
|
let marker_width = marker
|
||||||
.map(|(label, _)| UnicodeWidthStr::width(label) as u16)
|
.map(|(label, _)| UnicodeWidthStr::width(label) as u16)
|
||||||
.unwrap_or(0)
|
.unwrap_or(0)
|
||||||
|
|||||||
+18
-7
@@ -19,25 +19,36 @@ use crate::library::models::Availability;
|
|||||||
|
|
||||||
pub(crate) fn availability_marker(
|
pub(crate) fn availability_marker(
|
||||||
availability: Availability,
|
availability: Availability,
|
||||||
selected: bool,
|
selected_style: Option<Style>,
|
||||||
) -> (&'static str, Style) {
|
) -> (&'static str, Style) {
|
||||||
let (label, style) = match availability {
|
let (label, style) = match availability {
|
||||||
Availability::Local => ("●", Style::new().fg(Color::Green)),
|
Availability::Local => ("●", Style::new().fg(Color::Green)),
|
||||||
Availability::Mixed => ("◐", Style::new().fg(Color::Yellow)),
|
Availability::Mixed => ("◐", Style::new().fg(Color::Yellow)),
|
||||||
Availability::Remote => ("⇅", theme::accent()),
|
Availability::Remote => ("⇅", theme::accent()),
|
||||||
};
|
};
|
||||||
if selected {
|
(label, selected_style.unwrap_or(style))
|
||||||
(label, theme::tab_active())
|
|
||||||
} else {
|
|
||||||
(label, style)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn availability_prefix(availability: Availability) -> Span<'static> {
|
pub(crate) fn availability_prefix(availability: Availability) -> Span<'static> {
|
||||||
let (label, style) = availability_marker(availability, false);
|
let (label, style) = availability_marker(availability, None);
|
||||||
Span::styled(format!("{label} "), style)
|
Span::styled(format!("{label} "), style)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn selected_availability_marker_uses_the_supplied_mode_style() {
|
||||||
|
let client_style = Style::new().fg(Color::Black).bg(Color::Yellow);
|
||||||
|
|
||||||
|
let (label, style) = availability_marker(Availability::Local, Some(client_style));
|
||||||
|
|
||||||
|
assert_eq!(label, "●");
|
||||||
|
assert_eq!(style, client_style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn draw(frame: &mut Frame, state: &AppState, keymap: &Keymap) {
|
pub fn draw(frame: &mut Frame, state: &AppState, keymap: &Keymap) {
|
||||||
if state.visualizer.active {
|
if state.visualizer.active {
|
||||||
crate::visualizer::draw(frame, state);
|
crate::visualizer::draw(frame, state);
|
||||||
|
|||||||
@@ -18,13 +18,6 @@ pub fn dim() -> Style {
|
|||||||
Style::new().fg(DIM)
|
Style::new().fg(DIM)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tab_active() -> Style {
|
|
||||||
Style::new()
|
|
||||||
.fg(Color::Black)
|
|
||||||
.bg(ACCENT)
|
|
||||||
.add_modifier(Modifier::BOLD)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn tab_active_for(state: &AppState) -> Style {
|
pub fn tab_active_for(state: &AppState) -> Style {
|
||||||
Style::new()
|
Style::new()
|
||||||
.fg(Color::Black)
|
.fg(Color::Black)
|
||||||
|
|||||||
Reference in New Issue
Block a user