From ad44f020a55350fb49a6e41f352c836b6f5a0e1f Mon Sep 17 00:00:00 2001 From: ChristianVisintin Date: Mon, 14 Dec 2020 15:52:01 +0100 Subject: [PATCH] Highlight selected entry in tabs, only when the tab is active --- CHANGELOG.md | 1 + .../filetransfer_activity/layout.rs | 24 +++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67a0d4f..40828f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Released on 14/12/2020 - File explorer: - Fixed color mismatch in local explorer - Explorer tabs have now 70% of layout height, while logging area is 30% + - Highlight selected entry in tabs, only when the tab is active - Auth page: - align popup text to center - Keybindings: diff --git a/src/ui/activities/filetransfer_activity/layout.rs b/src/ui/activities/filetransfer_activity/layout.rs index 3a0d5f3..637750d 100644 --- a/src/ui/activities/filetransfer_activity/layout.rs +++ b/src/ui/activities/filetransfer_activity/layout.rs @@ -166,6 +166,11 @@ impl FileTransferActivity { .iter() .map(|entry: &FsEntry| ListItem::new(Span::from(format!("{}", entry)))) .collect(); + // Get colors to use; highlight element inverting fg/bg only when tab is active + let (fg, bg): (Color, Color) = match self.tab { + FileExplorerTab::Local => (Color::Black, Color::LightYellow), + _ => (Color::LightYellow, Color::Reset), + }; List::new(files) .block( Block::default() @@ -189,12 +194,7 @@ impl FileTransferActivity { )), ) .start_corner(Corner::TopLeft) - .highlight_style( - Style::default() - .fg(Color::Black) - .bg(Color::LightYellow) - .add_modifier(Modifier::BOLD), - ) + .highlight_style(Style::default().fg(fg).bg(bg).add_modifier(Modifier::BOLD)) } /// ### draw_remote_explorer @@ -207,6 +207,11 @@ impl FileTransferActivity { .iter() .map(|entry: &FsEntry| ListItem::new(Span::from(format!("{}", entry)))) .collect(); + // Get colors to use; highlight element inverting fg/bg only when tab is active + let (fg, bg): (Color, Color) = match self.tab { + FileExplorerTab::Remote => (Color::Black, Color::LightBlue), + _ => (Color::LightBlue, Color::Reset), + }; List::new(files) .block( Block::default() @@ -230,12 +235,7 @@ impl FileTransferActivity { )), ) .start_corner(Corner::TopLeft) - .highlight_style( - Style::default() - .bg(Color::LightBlue) - .fg(Color::Black) - .add_modifier(Modifier::BOLD), - ) + .highlight_style(Style::default().bg(bg).fg(fg).add_modifier(Modifier::BOLD)) } /// ### draw_log_list