From b9d61698523b2489fe831e8acaf1684b065a2c17 Mon Sep 17 00:00:00 2001 From: krolxon Date: Sun, 28 Apr 2024 15:53:23 +0530 Subject: highlight current playing songs in lists --- src/ui.rs | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'src/ui.rs') diff --git a/src/ui.rs b/src/ui.rs index 0bd87af..d2066ad 100755 --- a/src/ui.rs +++ b/src/ui.rs @@ -1,4 +1,5 @@ use crate::app::{App, SelectedTab}; +use clap::builder::styling::RgbColor; use ratatui::{ prelude::*, widgets::{block::Title, *}, @@ -51,12 +52,25 @@ pub fn render(app: &mut App, frame: &mut Frame) { fn draw_directory_browser(frame: &mut Frame, app: &mut App, size: Rect) { let mut song_state = ListState::default(); let total_songs = app.conn.conn.stats().unwrap().songs.to_string(); - let mut list: Vec = vec![]; + let mut list: Vec = vec![]; for (t, s) in app.browser.filetree.iter() { if t == "file" { - list.push(s.to_string()); + let mut status: bool = false; + for sn in app.queue_list.list.iter() { + if sn.contains(s) { + status = true; + } + } + if status { + list.push(ListItem::new(s.clone().bold())); + } else { + list.push(ListItem::new(Line::styled(s, Style::default()))); + } } else { - list.push(format!("[{}]", *s)); + list.push(ListItem::new(Line::styled( + format!("[{}]", *s), + Style::default(), + ))); } } let list = List::new(list) @@ -97,7 +111,16 @@ fn draw_queue(frame: &mut Frame, app: &mut App, size: Rect) { Title::from(format!("Volume: {}%", app.conn.volume).bold().green()) .alignment(Alignment::Right), ); - let list = List::new(app.queue_list.list.clone()) + + let mut items: Vec = vec![]; + for item in app.queue_list.list.iter() { + if item.contains(&app.conn.current_song.file) { + items.push(ListItem::new(item.clone().bold())) + } else { + items.push(ListItem::new(item.clone())); + } + } + let list = List::new(items) .block(title.borders(Borders::ALL)) .highlight_style( Style::new() -- cgit v1.2.3