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

Homepage revamp #520

Merged
merged 32 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
baca090
Add cover image to all tracks, if enabled
Aug 28, 2024
795da0a
fix
Aug 28, 2024
179fcbe
Merge branch 'jpochyla:master' into Improve-views
SO9010 Sep 3, 2024
8f9d6be
Homepage and artist init
Sep 5, 2024
9d04db2
Merge branch 'Improve-views' of https://github.com/SO9010/psst into I…
Sep 5, 2024
a17c6b8
VERY ROUGH start, currently only processing made for you in the custo…
Sep 11, 2024
a075bfb
Update to be more dynamic
Sep 12, 2024
47be312
Rearrange & Lint
Sep 12, 2024
e69a39c
Update hompage
Sep 12, 2024
3725ecf
Fix
Sep 12, 2024
8db4b7a
Sanitize html in descriptions, truncate to 65 chars, make playlist & …
jacksongoode Sep 12, 2024
09d8681
Grab the homepage things
Sep 13, 2024
d628e8d
Grab shows and show them, next to get is artist, album, new_episodes …
Sep 14, 2024
933b2b0
Start adding jump back in
Sep 14, 2024
01712ee
Implement the jump back in section, then I NEED to clean up the code!
Sep 14, 2024
ffcfd19
Neaten code for show and playlist, the rest will come soon!
Sep 16, 2024
c412161
Finish condensing views code, get the user data from a simple api call
Sep 17, 2024
d2e7241
Remove comments
Sep 17, 2024
d6db64d
Code neatness
Sep 17, 2024
41ef4bc
Make album widget small for library
Sep 18, 2024
ef49f93
Rearage Loaded resulst widget to make it look nicer!
Sep 19, 2024
6890856
Neaten code, match widgets with original ones!
Sep 21, 2024
8244562
Lint and remove hack to build on my machine
Sep 21, 2024
9149122
Cache user info
Sep 23, 2024
199c04e
Revert to spotube hash
Sep 23, 2024
34652d1
Unify widgets
Sep 23, 2024
08983dd
revert linebreak mode
Sep 23, 2024
cc3eacb
Home icon
Sep 23, 2024
409d432
Filled home with fixed sizing
jacksongoode Sep 23, 2024
15c888e
Filled house icon, vertical space in title separators, trim more char…
jacksongoode Sep 23, 2024
63fb9e0
Update name
jacksongoode Sep 23, 2024
7d5c5c7
Lift size by one to encounter scroll bar hight
Sep 23, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ cache
*.iml
rust-toolchain
*.ico
psst-gui/src/ui/artist.rs
psst-gui/src/ui/search.rs
psst-gui/src/webapi/client.rs
SO9010 marked this conversation as resolved.
Show resolved Hide resolved
30 changes: 23 additions & 7 deletions psst-gui/src/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub use crate::data::{
show::{Episode, EpisodeId, EpisodeLink, Show, ShowDetail, ShowEpisodes, ShowLink},
slider_scroll_scale::SliderScrollScale,
track::{AudioAnalysis, Track, TrackId},
user::UserProfile,
user::{UserProfile, PublicUser},
utils::{Cached, Float64, Image, Page},
};

Expand All @@ -79,7 +79,7 @@ pub struct AppState {
pub show_detail: ShowDetail,
pub library: Arc<Library>,
pub common_ctx: Arc<CommonCtx>,
pub personalized: Personalized,
pub home_detail: HomeDetail,
pub alerts: Vector<Alert>,
pub finder: Finder,
pub added_queue: Vector<QueueEntry>,
Expand Down Expand Up @@ -131,6 +131,13 @@ impl AppState {
knobs: Default::default(),
results: Promise::Empty,
},
home_detail: HomeDetail {
made_for_you: Promise::Empty,
user_top_mixes: Promise::Empty,
jump_back_in: Promise::Empty,
user_top_tracks: Promise::Empty,
user_top_artists: Promise::Empty,
},
album_detail: AlbumDetail {
album: Promise::Empty,
},
Expand All @@ -150,9 +157,6 @@ impl AppState {
},
library,
common_ctx,
personalized: Personalized {
made_for_you: Promise::Empty,
},
alerts: Vector::new(),
finder: Finder::new(),
}
Expand Down Expand Up @@ -512,8 +516,20 @@ impl CommonCtx {
pub type WithCtx<T> = Ctx<Arc<CommonCtx>, T>;

#[derive(Clone, Data, Lens)]
pub struct Personalized {
pub made_for_you: Promise<Vector<Playlist>>,
pub struct HomeDetail {
pub made_for_you: Promise<MixedView>,
pub user_top_mixes: Promise<MixedView>,
pub jump_back_in: Promise<MixedView>,
pub user_top_tracks: Promise<Vector<Arc<Track>>>,
pub user_top_artists: Promise<Vector<Artist>>,
}

#[derive(Clone, Data, Lens)]
pub struct MixedView {
pub playlists: Vector<Playlist>,
pub artists: Vector<Artist>,
pub albums: Vector<Album>,
pub shows: Vector<Show>,
}

static ALERT_ID: AtomicUsize = AtomicUsize::new(0);
Expand Down
3 changes: 3 additions & 0 deletions psst-gui/src/data/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ impl NowPlaying {

#[derive(Clone, Debug, Data)]
pub enum PlaybackOrigin {
Home,
Library,
Album(AlbumLink),
Artist(ArtistLink),
Expand All @@ -119,6 +120,7 @@ pub enum PlaybackOrigin {
impl PlaybackOrigin {
pub fn to_nav(&self) -> Nav {
match &self {
PlaybackOrigin::Home => Nav::Home,
PlaybackOrigin::Library => Nav::SavedTracks,
PlaybackOrigin::Album(link) => Nav::AlbumDetail(link.clone()),
PlaybackOrigin::Artist(link) => Nav::ArtistDetail(link.clone()),
Expand All @@ -133,6 +135,7 @@ impl PlaybackOrigin {
impl fmt::Display for PlaybackOrigin {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self {
PlaybackOrigin::Home => f.write_str("Home"),
SO9010 marked this conversation as resolved.
Show resolved Hide resolved
PlaybackOrigin::Library => f.write_str("Saved Tracks"),
PlaybackOrigin::Album(link) => link.name.fmt(f),
PlaybackOrigin::Artist(link) => link.name.fmt(f),
Expand Down
65 changes: 60 additions & 5 deletions psst-gui/src/ui/artist.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use druid::{
im::Vector,
kurbo::Circle,
widget::{CrossAxisAlignment, Flex, Label, LabelText, LineBreaking, List},
Data, Insets, LensExt, LocalizedString, Menu, MenuItem, Selector, Widget, WidgetExt,
im::Vector, kurbo::Circle, widget::{CrossAxisAlignment, Flex, Label, LabelText, LineBreaking, List, Scroll}, Data, Insets, LensExt, LocalizedString, Menu, MenuItem, Selector, Size, Widget, WidgetExt
};

use crate::{
Expand All @@ -21,10 +18,26 @@ pub const LOAD_DETAIL: Selector<ArtistLink> = Selector::new("app.artist.load-det

pub fn detail_widget() -> impl Widget<AppState> {
Flex::column()
.with_child(async_main_artist_widget())
.with_child(async_top_tracks_widget())
.with_child(async_albums_widget().padding((theme::grid(1.0), 0.0)))
.with_child(async_related_widget().padding((theme::grid(1.0), 0.0)))
}
//WebApi::global().get_musicbrainz_artist(&d.url()),
fn async_main_artist_widget() -> impl Widget<AppState> {
Async::new(
utils::spinner_widget,
artist_widget,
utils::error_widget,
)
.lens(AppState::artist_detail.then(ArtistDetail::artist))
.on_command_async(
LOAD_DETAIL,
|d| WebApi::global().get_artist(&d.id),
|_, data, d| data.artist_detail.artist.defer(d),
|_, data, r| data.artist_detail.artist.update(r),
)
}

fn async_top_tracks_widget() -> impl Widget<AppState> {
Async::new(
Expand Down Expand Up @@ -83,6 +96,39 @@ fn async_related_widget() -> impl Widget<AppState> {
}

pub fn artist_widget() -> impl Widget<Artist> {
let artist_image = artist_cover_widget(theme::grid(21.0));
Flex::row()
.with_child(artist_image)
.with_child(
Scroll::new(
Label::new(
"Coldplay are a British rock band formed in London in 1997, consisting of vocalist and pianist Chris Martin, lead guitarist Jonny Buckland, bassist Guy Berryman, drummer and percussionist Will Champion, and manager Phil Harvey. They are best known for their live performances, having also impacted popular culture with their artistry, advocacy and achievements. \n The members of the band initially met at University College London, calling themselves Big Fat Noises and changing to Starfish, before settling on the current name. After releasing Safety (1998) independently, Coldplay signed with Parlophone in 1999 and wrote their debut album, Parachutes (2000). It featured breakthrough single \"Yellow\" and received a Brit Award for British Album of the Year and a Grammy Award for Best Alternative Music Album. The group's follow-up, A Rush of Blood to the Head (2002), won the same accolades. X&Y (2005) later saw the completion of what they considered a trilogy, being nominated for Best Rock Album as well. Its successor, Viva la Vida or Death and All His Friends (2008), prevailed in the category. Both albums were the best-selling of their years, topping the charts in over 30 countries. Viva la Vida's title track also became the first British act single to lead the Billboard Hot 100 and UK Singles Chart simultaneously in the 21st century."
SO9010 marked this conversation as resolved.
Show resolved Hide resolved
)
.with_line_break_mode(LineBreaking::WordWrap)
.fix_width(theme::grid(35.0))
)
.fix_size(theme::grid(35.0), theme::grid(21.0))
)
.context_menu(|artist| artist_menu(&artist.link()))
}
pub fn horizontal_recommended_artist_widget() -> impl Widget<Artist> {
let artist_image = cover_widget(theme::grid(21.0));
let artist_label = Label::raw()
.with_font(theme::UI_FONT_MEDIUM)
.lens(Artist::name);
let artist = Flex::column()
.with_child(artist_image)
.with_default_spacer()
.with_child(artist_label);
artist
.padding(theme::grid(0.5))
.link()
.on_left_click(|ctx, _, artist, _| {
ctx.submit_command(cmd::NAVIGATE.with(Nav::ArtistDetail(artist.link())));
})
.context_menu(|artist| artist_menu(&artist.link()))
}
pub fn recommended_artist_widget() -> impl Widget<Artist> {
let artist_image = cover_widget(theme::grid(7.0));
let artist_label = Label::raw()
.with_font(theme::UI_FONT_MEDIUM)
Expand Down Expand Up @@ -112,6 +158,14 @@ pub fn link_widget() -> impl Widget<ArtistLink> {
.context_menu(artist_menu)
}

pub fn artist_cover_widget(size: f64) -> impl Widget<Artist> {
RemoteImage::new(utils::placeholder_widget(), move |artist: &Artist, _| {
artist.image(size, size).map(|image| image.url.clone())
})
.fix_size(size, size)
.clip(Size::new(size, size).to_rounded_rect(4.0))
}

pub fn cover_widget(size: f64) -> impl Widget<Artist> {
let radius = size / 2.0;
RemoteImage::new(utils::placeholder_widget(), move |artist: &Artist, _| {
Expand All @@ -127,6 +181,7 @@ fn top_tracks_widget() -> impl Widget<WithCtx<ArtistTracks>> {
title: true,
album: true,
popularity: true,
cover: true,
..track::Display::empty()
},
})
Expand All @@ -149,7 +204,7 @@ fn related_widget() -> impl Widget<Cached<Vector<Artist>>> {
Flex::column()
.cross_axis_alignment(CrossAxisAlignment::Start)
.with_child(header_widget("Related Artists"))
.with_child(List::new(artist_widget))
.with_child(List::new(recommended_artist_widget))
.lens(Cached::data)
}

Expand Down
Loading
Loading