Change color of unavailable song

If song is not available/playable, use secondary text color.

Fixes #1300
This commit is contained in:
Henrik Friedrichsen
2023-10-14 22:31:57 +02:00
parent a1a986344f
commit 6ee00e39d3
2 changed files with 6 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ pub struct Track {
pub added_at: Option<DateTime<Utc>>, pub added_at: Option<DateTime<Utc>>,
pub list_index: usize, pub list_index: usize,
pub is_local: bool, pub is_local: bool,
pub is_playable: Option<bool>,
} }
impl Track { impl Track {
@@ -71,6 +72,7 @@ impl Track {
added_at: None, added_at: None,
list_index: 0, list_index: 0,
is_local: track.is_local, is_local: track.is_local,
is_playable: track.is_playable,
} }
} }
@@ -109,6 +111,7 @@ impl From<&SimplifiedTrack> for Track {
added_at: None, added_at: None,
list_index: 0, list_index: 0,
is_local: track.is_local, is_local: track.is_local,
is_playable: track.is_playable,
} }
} }
} }
@@ -149,6 +152,7 @@ impl From<&FullTrack> for Track {
added_at: None, added_at: None,
list_index: 0, list_index: 0,
is_local: track.is_local, is_local: track.is_local,
is_playable: track.is_playable,
} }
} }
} }

View File

@@ -221,6 +221,7 @@ impl<I: ListItem + Clone> View for ListView<I> {
let currently_playing = let currently_playing =
item.is_playing(&self.queue) && self.queue.get_current_index() == Some(i); item.is_playing(&self.queue) && self.queue.get_current_index() == Some(i);
let is_local = item.track().map(|t| t.is_local).unwrap_or_default(); let is_local = item.track().map(|t| t.is_local).unwrap_or_default();
let is_playable = item.track().map(|t| t.is_playable).unwrap_or_default();
let style = if self.selected == i { let style = if self.selected == i {
if currently_playing { if currently_playing {
@@ -241,7 +242,7 @@ impl<I: ListItem + Clone> View for ListView<I> {
ColorType::Color(*printer.theme.palette.custom("playing").unwrap()), ColorType::Color(*printer.theme.palette.custom("playing").unwrap()),
ColorType::Color(*printer.theme.palette.custom("playing_bg").unwrap()), ColorType::Color(*printer.theme.palette.custom("playing_bg").unwrap()),
) )
} else if is_local { } else if is_local || is_playable == Some(false) {
ColorStyle::secondary() ColorStyle::secondary()
} else { } else {
ColorStyle::primary() ColorStyle::primary()