Highlight selected entry in tabs, only when the tab is active

This commit is contained in:
ChristianVisintin
2020-12-14 15:52:01 +01:00
parent ad339aa959
commit ad44f020a5
2 changed files with 13 additions and 12 deletions

View File

@@ -18,6 +18,7 @@ Released on 14/12/2020
- File explorer: - File explorer:
- Fixed color mismatch in local explorer - Fixed color mismatch in local explorer
- Explorer tabs have now 70% of layout height, while logging area is 30% - 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: - Auth page:
- align popup text to center - align popup text to center
- Keybindings: - Keybindings:

View File

@@ -166,6 +166,11 @@ impl FileTransferActivity {
.iter() .iter()
.map(|entry: &FsEntry| ListItem::new(Span::from(format!("{}", entry)))) .map(|entry: &FsEntry| ListItem::new(Span::from(format!("{}", entry))))
.collect(); .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) List::new(files)
.block( .block(
Block::default() Block::default()
@@ -189,12 +194,7 @@ impl FileTransferActivity {
)), )),
) )
.start_corner(Corner::TopLeft) .start_corner(Corner::TopLeft)
.highlight_style( .highlight_style(Style::default().fg(fg).bg(bg).add_modifier(Modifier::BOLD))
Style::default()
.fg(Color::Black)
.bg(Color::LightYellow)
.add_modifier(Modifier::BOLD),
)
} }
/// ### draw_remote_explorer /// ### draw_remote_explorer
@@ -207,6 +207,11 @@ impl FileTransferActivity {
.iter() .iter()
.map(|entry: &FsEntry| ListItem::new(Span::from(format!("{}", entry)))) .map(|entry: &FsEntry| ListItem::new(Span::from(format!("{}", entry))))
.collect(); .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) List::new(files)
.block( .block(
Block::default() Block::default()
@@ -230,12 +235,7 @@ impl FileTransferActivity {
)), )),
) )
.start_corner(Corner::TopLeft) .start_corner(Corner::TopLeft)
.highlight_style( .highlight_style(Style::default().bg(bg).fg(fg).add_modifier(Modifier::BOLD))
Style::default()
.bg(Color::LightBlue)
.fg(Color::Black)
.add_modifier(Modifier::BOLD),
)
} }
/// ### draw_log_list /// ### draw_log_list