Skip to content

Commit

Permalink
UI cleanup for save track icon (#498)
Browse files Browse the repository at this point in the history
* Cleanup - new icons, new location, small fixes
  • Loading branch information
jacksongoode authored Aug 4, 2024
1 parent 2d9bdcb commit a492c33
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 45 deletions.
4 changes: 2 additions & 2 deletions psst-gui/src/ui/album.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ fn album_menu(album: &Arc<Album>, library: &Arc<Library>) -> Menu<AppState> {
let more_than_one_artist = album.artists.len() > 1;
let title = if more_than_one_artist {
LocalizedString::new("menu-item-show-artist-name")
.with_placeholder(format!("Go To Artist “{}”", artist_link.name))
.with_placeholder(format!("Go to Artist “{}”", artist_link.name))
} else {
LocalizedString::new("menu-item-show-artist").with_placeholder("Go To Artist")
LocalizedString::new("menu-item-show-artist").with_placeholder("Go to Artist")
};
menu = menu.entry(
MenuItem::new(title)
Expand Down
2 changes: 1 addition & 1 deletion psst-gui/src/ui/episode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub fn episode_menu(episode: &Episode, _library: &Arc<Library>) -> Menu<AppState
let mut menu = Menu::empty();

menu = menu.entry(
MenuItem::new(LocalizedString::new("menu-item-show-show").with_placeholder("Go To Show"))
MenuItem::new(LocalizedString::new("menu-item-show-show").with_placeholder("Go to Show"))
.command(cmd::NAVIGATE.with(Nav::ShowDetail(episode.show.clone()))),
);

Expand Down
4 changes: 2 additions & 2 deletions psst-gui/src/ui/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ fn playing_item_widget() -> impl Widget<NowPlaying> {
},
|selector: &bool, _, _| {
match selector {
true => &icons::HEART_SOLID,
false => &icons::HEART_OUTLINE,
true => &icons::CIRCLE_CHECK,
false => &icons::CIRCLE_PLUS,
}
.scale(theme::ICON_SIZE_SMALL)
.boxed()
Expand Down
20 changes: 10 additions & 10 deletions psst-gui/src/ui/track.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use druid::{
widget::{CrossAxisAlignment, Either, Flex, Label, ViewSwitcher},
widget::{CrossAxisAlignment, Either, Flex, Label, LineBreaking, ViewSwitcher},
LensExt, LocalizedString, Menu, MenuItem, Size, TextAlignment, Widget, WidgetExt,
};
use psst_core::{
Expand Down Expand Up @@ -142,8 +142,8 @@ pub fn playable_widget(track: &Track, display: Display) -> impl Widget<PlayRow<A
|row: &PlayRow<Arc<Track>>, _| row.ctx.library.contains_track(&row.item),
|selector: &bool, _, _| {
match selector {
true => &icons::HEART_SOLID,
false => &icons::HEART_OUTLINE,
true => &icons::CIRCLE_CHECK,
false => &icons::CIRCLE_PLUS,
}
.scale(theme::ICON_SIZE_SMALL)
.boxed()
Expand Down Expand Up @@ -230,9 +230,9 @@ pub fn track_menu(
let more_than_one_artist = track.artists.len() > 1;
let title = if more_than_one_artist {
LocalizedString::new("menu-item-show-artist-name")
.with_placeholder(format!("Go To Artist “{}”", artist_link.name))
.with_placeholder(format!("Go to Artist “{}”", artist_link.name))
} else {
LocalizedString::new("menu-item-show-artist").with_placeholder("Go To Artist")
LocalizedString::new("menu-item-show-artist").with_placeholder("Go to Artist")
};
menu = menu.entry(
MenuItem::new(title)
Expand All @@ -243,7 +243,7 @@ pub fn track_menu(
if let Some(album_link) = track.album.as_ref() {
menu = menu.entry(
MenuItem::new(
LocalizedString::new("menu-item-show-album").with_placeholder("Go To Album"),
LocalizedString::new("menu-item-show-album").with_placeholder("Go to Album"),
)
.command(cmd::NAVIGATE.with(Nav::AlbumDetail(album_link.to_owned()))),
);
Expand Down Expand Up @@ -287,7 +287,7 @@ pub fn track_menu(
}

if let PlaybackOrigin::Playlist(playlist) = origin {
// do some (hopefully) quick checks to determine if we should give the
// Do some (hopefully) quick checks to determine if we should give the
// option to remove items from this playlist, only allowing it if the
// playlist is collaborative or we are the owner of it
let should_show = {
Expand Down Expand Up @@ -319,7 +319,7 @@ pub fn track_menu(
menu = menu.entry(
MenuItem::new(
LocalizedString::new("menu-item-remove-from-playlist")
.with_placeholder("Remove from this playlist"),
.with_placeholder("Remove from current Playlist"),
)
.command(playlist::REMOVE_TRACK.with(PlaylistRemoveTrack {
link: playlist.to_owned(),
Expand All @@ -331,9 +331,9 @@ pub fn track_menu(

menu = menu.entry(
MenuItem::new(
LocalizedString::new("menu-item-add-to-queue").with_placeholder("Add Track To Queue"),
LocalizedString::new("menu-item-add-to-queue").with_placeholder("Add Track to Queue"),
)
//PlayerCommand
// PlayerCommand
.command(cmd::ADD_TO_QUEUE.with((
QueueEntry {
item: crate::ui::Playable::Track(track.clone()),
Expand Down
48 changes: 24 additions & 24 deletions psst-gui/src/webapi/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,14 @@ impl WebApi {

/// Artist endpoints.
impl WebApi {
// https://developer.spotify.com/documentation/web-api/reference/artists/get-artist/
// https://developer.spotify.com/documentation/web-api/reference/get-artist/
pub fn get_artist(&self, id: &str) -> Result<Artist, Error> {
let request = self.get(format!("v1/artists/{}", id))?;
let result = self.load_cached(request, "artist", id)?;
Ok(result.data)
}

// https://developer.spotify.com/documentation/web-api/reference/artists/get-artists-albums/
// https://developer.spotify.com/documentation/web-api/reference/get-an-artists-albums/
pub fn get_artist_albums(&self, id: &str) -> Result<ArtistAlbums, Error> {
let request = self
.get(format!("v1/artists/{}/albums", id))?
Expand Down Expand Up @@ -295,7 +295,7 @@ impl WebApi {
Ok(artist_albums)
}

// https://developer.spotify.com/documentation/web-api/reference/artists/get-artists-top-tracks/
// https://developer.spotify.com/documentation/web-api/reference/get-artists-top-tracks/
pub fn get_artist_top_tracks(&self, id: &str) -> Result<Vector<Arc<Track>>, Error> {
#[derive(Deserialize)]
struct Tracks {
Expand All @@ -309,7 +309,7 @@ impl WebApi {
Ok(result.tracks)
}

// https://developer.spotify.com/documentation/web-api/reference/artists/get-related-artists/
// https://developer.spotify.com/documentation/web-api/reference/get-related-artists/
pub fn get_related_artists(&self, id: &str) -> Result<Cached<Vector<Artist>>, Error> {
#[derive(Clone, Data, Deserialize)]
struct Artists {
Expand All @@ -324,7 +324,7 @@ impl WebApi {

/// Album endpoints.
impl WebApi {
// https://developer.spotify.com/documentation/web-api/reference/albums/get-album/
// https://developer.spotify.com/documentation/web-api/reference/get-an-album/
pub fn get_album(&self, id: &str) -> Result<Cached<Arc<Album>>, Error> {
let request = self
.get(format!("v1/albums/{}", id))?
Expand All @@ -336,7 +336,7 @@ impl WebApi {

/// Show endpoints. (Podcasts)
impl WebApi {
// https://developer.spotify.com/documentation/web-api/reference/#/operations/get-multiple-episodes
// https://developer.spotify.com/documentation/web-api/reference/get-multiple-episodes
pub fn get_episodes(
&self,
ids: impl IntoIterator<Item = EpisodeId>,
Expand All @@ -354,7 +354,7 @@ impl WebApi {
Ok(result.episodes)
}

// https://developer.spotify.com/documentation/web-api/reference/#/operations/get-a-shows-episodes
// https://developer.spotify.com/documentation/web-api/reference/get-a-shows-episodes
pub fn get_show_episodes(&self, id: &str) -> Result<Vector<Arc<Episode>>, Error> {
let request = self
.get(format!("v1/shows/{}/episodes", id))?
Expand All @@ -376,7 +376,7 @@ impl WebApi {

/// Track endpoints.
impl WebApi {
// https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-track
// https://developer.spotify.com/documentation/web-api/reference/get-track
pub fn get_track(&self, id: &str) -> Result<Arc<Track>, Error> {
let request = self
.get(format!("v1/tracks/{}", id))?
Expand All @@ -388,7 +388,7 @@ impl WebApi {

/// Library endpoints.
impl WebApi {
// https://developer.spotify.com/documentation/web-api/reference/library/get-users-saved-albums/
// https://developer.spotify.com/documentation/web-api/reference/get-users-saved-albums/
pub fn get_saved_albums(&self) -> Result<Vector<Arc<Album>>, Error> {
#[derive(Clone, Deserialize)]
struct SavedAlbum {
Expand All @@ -404,21 +404,21 @@ impl WebApi {
.collect())
}

// https://developer.spotify.com/documentation/web-api/reference/library/save-albums-user/
// https://developer.spotify.com/documentation/web-api/reference/save-albums-user/
pub fn save_album(&self, id: &str) -> Result<(), Error> {
let request = self.put("v1/me/albums")?.query("ids", id);
self.send_empty_json(request)?;
Ok(())
}

// https://developer.spotify.com/documentation/web-api/reference/library/remove-albums-user/
// https://developer.spotify.com/documentation/web-api/reference/remove-albums-user/
pub fn unsave_album(&self, id: &str) -> Result<(), Error> {
let request = self.delete("v1/me/albums")?.query("ids", id);
self.send_empty_json(request)?;
Ok(())
}

// https://developer.spotify.com/documentation/web-api/reference/library/get-users-saved-tracks/
// https://developer.spotify.com/documentation/web-api/reference/get-users-saved-tracks/
pub fn get_saved_tracks(&self) -> Result<Vector<Arc<Track>>, Error> {
#[derive(Clone, Deserialize)]
struct SavedTrack {
Expand All @@ -434,7 +434,7 @@ impl WebApi {
.collect())
}

// https://developer.spotify.com/documentation/web-api/reference/#/operations/get-users-saved-shows
// https://developer.spotify.com/documentation/web-api/reference/get-users-saved-shows
pub fn get_saved_shows(&self) -> Result<Vector<Arc<Show>>, Error> {
#[derive(Clone, Deserialize)]
struct SavedShow {
Expand All @@ -450,28 +450,28 @@ impl WebApi {
.collect())
}

// https://developer.spotify.com/documentation/web-api/reference/library/save-tracks-user/
// https://developer.spotify.com/documentation/web-api/reference/save-tracks-user/
pub fn save_track(&self, id: &str) -> Result<(), Error> {
let request = self.put("v1/me/tracks")?.query("ids", id);
self.send_empty_json(request)?;
Ok(())
}

// https://developer.spotify.com/documentation/web-api/reference/library/remove-tracks-user/
// https://developer.spotify.com/documentation/web-api/reference/remove-tracks-user/
pub fn unsave_track(&self, id: &str) -> Result<(), Error> {
let request = self.delete("v1/me/tracks")?.query("ids", id);
self.send_empty_json(request)?;
Ok(())
}

// https://developer.spotify.com/documentation/web-api/reference/#/operations/save-shows-user
// https://developer.spotify.com/documentation/web-api/reference/save-shows-user
pub fn save_show(&self, id: &str) -> Result<(), Error> {
let request = self.put("v1/me/shows")?.query("ids", id);
self.send_empty_json(request)?;
Ok(())
}

// https://developer.spotify.com/documentation/web-api/reference/#/operations/remove-shows-user
// https://developer.spotify.com/documentation/web-api/reference/remove-shows-user
pub fn unsave_show(&self, id: &str) -> Result<(), Error> {
let request = self.delete("v1/me/shows")?.query("ids", id);
self.send_empty_json(request)?;
Expand Down Expand Up @@ -499,7 +499,7 @@ impl WebApi {

/// Playlist endpoints.
impl WebApi {
// https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-a-list-of-current-users-playlists
// https://developer.spotify.com/documentation/web-api/reference/get-a-list-of-current-users-playlists
pub fn get_playlists(&self) -> Result<Vector<Playlist>, Error> {
let request = self.get("v1/me/playlists")?;
let result = self.load_all_pages(request)?;
Expand All @@ -518,14 +518,14 @@ impl WebApi {
Ok(())
}

// https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-playlist
// https://developer.spotify.com/documentation/web-api/reference/get-playlist
pub fn get_playlist(&self, id: &str) -> Result<Playlist, Error> {
let request = self.get(format!("v1/me/playlists/{}", id))?;
let result = self.load(request)?;
Ok(result)
}

// https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-playlists-tracks
// https://developer.spotify.com/documentation/web-api/reference/get-playlists-tracks
pub fn get_playlist_tracks(&self, id: &str) -> Result<Vector<Arc<Track>>, Error> {
#[derive(Clone, Deserialize)]
struct PlaylistItem {
Expand Down Expand Up @@ -570,15 +570,15 @@ impl WebApi {
Ok(())
}

// https://developer.spotify.com/documentation/web-api/reference/#endpoint-add-tracks-to-playlist
// https://developer.spotify.com/documentation/web-api/reference/add-tracks-to-playlist
pub fn add_track_to_playlist(&self, playlist_id: &str, track_uri: &str) -> Result<(), Error> {
let request = self
.post(format!("v1/playlists/{}/tracks", playlist_id))?
.query("uris", track_uri);
self.send_empty_json(request)
}

// https://developer.spotify.com/documentation/web-api/reference/#/operations/remove-tracks-playlist
// https://developer.spotify.com/documentation/web-api/reference/remove-tracks-playlist
pub fn remove_track_from_playlist(
&self,
playlist_id: &str,
Expand Down Expand Up @@ -651,7 +651,7 @@ impl WebApi {

/// Recommendation endpoints.
impl WebApi {
// https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-recommendations
// https://developer.spotify.com/documentation/web-api/reference/get-recommendations
pub fn get_recommendations(
&self,
data: Arc<RecommendationsRequest>,
Expand Down Expand Up @@ -705,7 +705,7 @@ impl WebApi {

/// Track endpoints.
impl WebApi {
// https://developer.spotify.com/documentation/web-api/reference/tracks/get-audio-analysis/
// https://developer.spotify.com/documentation/web-api/reference/get-audio-analysis/
pub fn _get_audio_analysis(&self, track_id: &str) -> Result<AudioAnalysis, Error> {
let request = self.get(format!("v1/audio-analysis/{}", track_id))?;
let result = self.load_cached(request, "audio-analysis", track_id)?;
Expand Down
13 changes: 7 additions & 6 deletions psst-gui/src/widget/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,16 @@ pub static EXPLICIT: SvgIcon = SvgIcon {
svg_size: Size::new(24.0, 24.0),
op: PaintOp::Fill,
};
// Font Awesome - heart solid
pub static HEART_SOLID: SvgIcon = SvgIcon {
svg_path: "M12 2.1c6.66-7.3 23.3 5.48 0 21.9C-11.3 7.58 5.34-5.2 12 2.1z",
// SF Pro Regular - plus.circle
pub static CIRCLE_PLUS: SvgIcon = SvgIcon {
svg_path: "M11.9531 23.9062C18.4922 23.9062 23.9062 18.4805 23.9062 11.9531C23.9062 5.41406 18.4805 0 11.9414 0C5.41406 0 0 5.41406 0 11.9531C0 18.4805 5.42578 23.9062 11.9531 23.9062ZM11.9531 21.9141C6.42188 21.9141 2.00391 17.4844 2.00391 11.9531C2.00391 6.42188 6.41016 1.99219 11.9414 1.99219C17.4727 1.99219 21.9141 6.42188 21.9141 11.9531C21.9141 17.4844 17.4844 21.9141 11.9531 21.9141ZM6.51562 11.9531C6.51562 12.5273 6.91406 12.9141 7.51172 12.9141L10.957 12.9141L10.957 16.3711C10.957 16.957 11.3555 17.3672 11.9297 17.3672C12.5156 17.3672 12.9258 16.9688 12.9258 16.3711L12.9258 12.9141L16.3828 12.9141C16.9688 12.9141 17.3789 12.5273 17.3789 11.9531C17.3789 11.3672 16.9688 10.957 16.3828 10.957L12.9258 10.957L12.9258 7.51172C12.9258 6.91406 12.5156 6.50391 11.9297 6.50391C11.3555 6.50391 10.957 6.91406 10.957 7.51172L10.957 10.957L7.51172 10.957C6.91406 10.957 6.51562 11.3672 6.51562 11.9531Z",
svg_size: Size::new(24.0, 24.0),
op: PaintOp::Fill,
};
// Font Awesome - heart regular
pub static HEART_OUTLINE: SvgIcon = SvgIcon {
svg_path: "m12 4.4-1.08-1.18C8.4.45 3.77 1.4 2.1 4.88c-.78 1.64-.96 4 .47 7.02 1.38 2.9 4.25 6.38 9.43 10.17 5.18-3.79 8.05-7.27 9.43-10.17 1.43-3.02 1.26-5.38.47-7.02-1.67-3.48-6.3-4.43-8.82-1.66ZM12 24C-11 7.79 4.92-4.86 11.74 1.83l.26.27a4.68 5 0 0 1 .26-.27C19.08-4.87 35 7.79 12 24z",

// SF Pro Regular - checkmark.circle.fill
pub static CIRCLE_CHECK: SvgIcon = SvgIcon {
svg_path: "M23.9062 11.9531C23.9062 18.4805 18.4922 23.9062 11.9531 23.9062C5.42578 23.9062 0 18.4805 0 11.9531C0 5.41406 5.41406 0 11.9414 0C18.4805 0 23.9062 5.41406 23.9062 11.9531ZM15.5977 7.30078L10.5938 15.3398L8.21484 12.2695C7.92188 11.8828 7.66406 11.7773 7.32422 11.7773C6.79688 11.7773 6.38672 12.2109 6.38672 12.7383C6.38672 13.0078 6.49219 13.2656 6.66797 13.5L9.60938 17.1094C9.91406 17.5195 10.2422 17.6836 10.6406 17.6836C11.0391 17.6836 11.3789 17.4961 11.625 17.1094L17.1328 8.4375C17.2734 8.19141 17.4258 7.92188 17.4258 7.66406C17.4258 7.11328 16.9453 6.76172 16.4297 6.76172C16.125 6.76172 15.8203 6.94922 15.5977 7.30078Z",
svg_size: Size::new(24.0, 24.0),
op: PaintOp::Fill,
};
Expand Down

0 comments on commit a492c33

Please sign in to comment.