Skip to content

Commit

Permalink
Merge branch 'jpochyla:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
SO9010 authored Sep 26, 2024
2 parents 9c61420 + ecc0115 commit f69b626
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
47 changes: 33 additions & 14 deletions psst-gui/src/ui/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,27 @@ pub fn home_widget() -> impl Widget<AppState> {
.with_child(user_top_mixes())
.with_child(recommended_stations())
.with_child(best_of_artists())
.with_child(simple_title_label("Uniquely yours"))
.with_default_spacer()
.with_child(uniquely_yours())
.with_child(your_shows())
.with_child(shows_that_you_might_like())
.with_child(simple_title_label("Your top artists"))
.with_default_spacer()
.with_child(user_top_artists_widget())
.with_default_spacer()
.with_child(simple_title_label("Your top tracks"))
.with_default_spacer()
.with_child(user_top_tracks_widget())
}

fn simple_title_label(title: &str) -> impl Widget<AppState> {
Label::new(title)
Flex::column()
.with_default_spacer()
.with_child(Label::new(title)
.with_text_size(theme::grid(2.5))
.align_left()
.padding((theme::grid(1.5), 0.0))
)
}

pub fn made_for_you() -> impl Widget<AppState> {
Async::new(spinner_widget, loaded_results_widget, error_widget)
Async::new(spinner_widget, loaded_results_widget, || {Empty})
.lens(
Ctx::make(
AppState::common_ctx,
Expand All @@ -66,7 +64,7 @@ pub fn made_for_you() -> impl Widget<AppState> {
}

pub fn recommended_stations() -> impl Widget<AppState> {
Async::new(spinner_widget, loaded_results_widget, error_widget)
Async::new(spinner_widget, loaded_results_widget, || {Empty})
.lens(
Ctx::make(
AppState::common_ctx,
Expand All @@ -82,8 +80,29 @@ pub fn recommended_stations() -> impl Widget<AppState> {
)
}

fn uniquely_yours_results_widget() -> impl Widget<WithCtx<MixedView>> {
Either::new(
|results: &WithCtx<MixedView>, _| {
results.data.playlists.is_empty()
},
Empty,
Flex::column().with_default_spacer()
.with_child(Label::new("Uniquely yours")
.with_text_size(theme::grid(2.5))
.align_left()
.padding((theme::grid(1.5), 0.0))
).with_child(
Scroll::new(
Flex::row()
.with_child(playlist_results_widget())
)
.align_left(),
),
)
}

pub fn uniquely_yours() -> impl Widget<AppState> {
Async::new(spinner_widget, loaded_results_widget, error_widget)
Async::new(spinner_widget, uniquely_yours_results_widget, || {Empty})
.lens(
Ctx::make(
AppState::common_ctx,
Expand All @@ -100,7 +119,7 @@ pub fn uniquely_yours() -> impl Widget<AppState> {
}

pub fn user_top_mixes() -> impl Widget<AppState> {
Async::new(spinner_widget, loaded_results_widget, error_widget)
Async::new(spinner_widget, loaded_results_widget, || {Empty})
.lens(
Ctx::make(
AppState::common_ctx,
Expand All @@ -117,7 +136,7 @@ pub fn user_top_mixes() -> impl Widget<AppState> {
}

pub fn best_of_artists() -> impl Widget<AppState> {
Async::new(spinner_widget, loaded_results_widget, error_widget)
Async::new(spinner_widget, loaded_results_widget, || {Empty})
.lens(
Ctx::make(
AppState::common_ctx,
Expand All @@ -134,7 +153,7 @@ pub fn best_of_artists() -> impl Widget<AppState> {
}

pub fn your_shows() -> impl Widget<AppState> {
Async::new(spinner_widget, loaded_results_widget, error_widget)
Async::new(spinner_widget, loaded_results_widget, || {Empty})
.lens(
Ctx::make(
AppState::common_ctx,
Expand All @@ -151,7 +170,7 @@ pub fn your_shows() -> impl Widget<AppState> {
}

pub fn jump_back_in() -> impl Widget<AppState> {
Async::new(spinner_widget, loaded_results_widget, error_widget)
Async::new(spinner_widget, loaded_results_widget, || {Empty})
.lens(
Ctx::make(
AppState::common_ctx,
Expand All @@ -168,7 +187,7 @@ pub fn jump_back_in() -> impl Widget<AppState> {
}

pub fn shows_that_you_might_like() -> impl Widget<AppState> {
Async::new(spinner_widget, loaded_results_widget, error_widget)
Async::new(spinner_widget, loaded_results_widget, || {Empty})
.lens(
Ctx::make(
AppState::common_ctx,
Expand Down
1 change: 0 additions & 1 deletion psst-gui/src/ui/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ fn cover_widget(size: f64) -> impl Widget<NowPlaying> {

fn playback_origin_icon(origin: &PlaybackOrigin) -> &'static SvgIcon {
match origin {
// TODO add home widget
PlaybackOrigin::Home => &icons::HOME,
PlaybackOrigin::Library => &icons::HEART,
PlaybackOrigin::Queue => &icons::PLAYLIST,
Expand Down
6 changes: 3 additions & 3 deletions psst-gui/src/webapi/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ impl WebApi {
}

fn put(&self, path: impl Display, base_url: Option<&str>) -> Result<Request, Error> {
self.request("GET", base_url.unwrap_or("api.spotify.com"), path)
self.request("PUT", base_url.unwrap_or("api.spotify.com"), path)
}

fn post(&self, path: impl Display, base_url: Option<&str>) -> Result<Request, Error> {
self.request("GET", base_url.unwrap_or("api.spotify.com"), path)
self.request("POST", base_url.unwrap_or("api.spotify.com"), path)
}

fn delete(&self, path: impl Display, base_url: Option<&str>) -> Result<Request, Error> {
self.request("GET", base_url.unwrap_or("api.spotify.com"), path)
self.request("DELETE", base_url.unwrap_or("api.spotify.com"), path)
}

fn with_retry(f: impl Fn() -> Result<Response, Error>) -> Result<Response, Error> {
Expand Down

0 comments on commit f69b626

Please sign in to comment.