Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow themable "like" component #525

Merged
merged 4 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ bright_magenta = "#ff79c6"
bright_cyan = "#8be9fd"
bright_white = "#ffffff"
[themes.component_style]
like = { fg = "Red", modifiers = ["Bold"] }
selection = { bg = "Black", fg = "White", modifiers = ["Bold"] }
secondary_row = { bg = "#677075" }

Expand Down
7 changes: 7 additions & 0 deletions spotify_player/src/config/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub struct ComponentStyle {
pub table_header: Option<Style>,
pub selection: Option<Style>,
pub secondary_row: Option<Style>,
pub like: Option<Style>,
}

#[derive(Default, Clone, Debug, Deserialize)]
Expand Down Expand Up @@ -302,6 +303,12 @@ impl Theme {
Some(s) => s.style(&self.palette),
}
}
pub fn like(&self) -> tui::style::Style {
match &self.component_style.like {
None => Style::default().style(&self.palette),
Some(s) => s.style(&self.palette),
}
}
}

impl Style {
Expand Down
9 changes: 4 additions & 5 deletions spotify_player/src/ui/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,11 +855,11 @@ fn render_track_table(
((id + 1).to_string(), Style::default())
};
Row::new(vec![
Cell::from(if data.user_data.is_liked_track(t) {
&configs.app_config.liked_icon
if data.user_data.is_liked_track(t) {
Cell::from(&configs.app_config.liked_icon as &str).style(ui.theme.like())
} else {
""
}),
Cell::from("")
},
Cell::from(id),
Cell::from(t.display_name()),
Cell::from(t.artists_info()),
Expand All @@ -873,7 +873,6 @@ fn render_track_table(
.style(style)
})
.collect::<Vec<_>>();

let track_table = Table::new(
rows,
[
Expand Down
Loading