From 71f20c0e532ec8af6bc11d8e1610c37225cd5fdb Mon Sep 17 00:00:00 2001 From: Samuel Oldham Date: Wed, 25 Sep 2024 17:29:13 +0100 Subject: [PATCH 1/2] Show empty on error for home --- psst-gui/src/ui/home.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/psst-gui/src/ui/home.rs b/psst-gui/src/ui/home.rs index 91022290..9fc83a57 100644 --- a/psst-gui/src/ui/home.rs +++ b/psst-gui/src/ui/home.rs @@ -49,7 +49,7 @@ fn simple_title_label(title: &str) -> impl Widget { } pub fn made_for_you() -> impl Widget { - Async::new(spinner_widget, loaded_results_widget, error_widget) + Async::new(spinner_widget, loaded_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx, @@ -66,7 +66,7 @@ pub fn made_for_you() -> impl Widget { } pub fn recommended_stations() -> impl Widget { - Async::new(spinner_widget, loaded_results_widget, error_widget) + Async::new(spinner_widget, loaded_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx, @@ -83,7 +83,7 @@ pub fn recommended_stations() -> impl Widget { } pub fn uniquely_yours() -> impl Widget { - Async::new(spinner_widget, loaded_results_widget, error_widget) + Async::new(spinner_widget, loaded_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx, @@ -100,7 +100,7 @@ pub fn uniquely_yours() -> impl Widget { } pub fn user_top_mixes() -> impl Widget { - Async::new(spinner_widget, loaded_results_widget, error_widget) + Async::new(spinner_widget, loaded_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx, @@ -117,7 +117,7 @@ pub fn user_top_mixes() -> impl Widget { } pub fn best_of_artists() -> impl Widget { - Async::new(spinner_widget, loaded_results_widget, error_widget) + Async::new(spinner_widget, loaded_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx, @@ -134,7 +134,7 @@ pub fn best_of_artists() -> impl Widget { } pub fn your_shows() -> impl Widget { - Async::new(spinner_widget, loaded_results_widget, error_widget) + Async::new(spinner_widget, loaded_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx, @@ -151,7 +151,7 @@ pub fn your_shows() -> impl Widget { } pub fn jump_back_in() -> impl Widget { - Async::new(spinner_widget, loaded_results_widget, error_widget) + Async::new(spinner_widget, loaded_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx, @@ -168,7 +168,7 @@ pub fn jump_back_in() -> impl Widget { } pub fn shows_that_you_might_like() -> impl Widget { - Async::new(spinner_widget, loaded_results_widget, error_widget) + Async::new(spinner_widget, loaded_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx, From 8b86146375f56c69f2522095c5f25f4a1938decf Mon Sep 17 00:00:00 2001 From: Samuel Oldham Date: Wed, 25 Sep 2024 18:34:09 +0100 Subject: [PATCH 2/2] Move where the uniquely yours --- psst-gui/src/ui/home.rs | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/psst-gui/src/ui/home.rs b/psst-gui/src/ui/home.rs index 9fc83a57..8ea7d916 100644 --- a/psst-gui/src/ui/home.rs +++ b/psst-gui/src/ui/home.rs @@ -27,25 +27,23 @@ pub fn home_widget() -> impl Widget { .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 { - 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 { @@ -82,8 +80,29 @@ pub fn recommended_stations() -> impl Widget { ) } +fn uniquely_yours_results_widget() -> impl Widget> { + Either::new( + |results: &WithCtx, _| { + 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 { - Async::new(spinner_widget, loaded_results_widget, || {Empty}) + Async::new(spinner_widget, uniquely_yours_results_widget, || {Empty}) .lens( Ctx::make( AppState::common_ctx,