From c20a7a803a00172fd79bdfe67528a33671e4460c Mon Sep 17 00:00:00 2001 From: jane400 Date: Wed, 2 Oct 2024 17:42:13 +0200 Subject: [PATCH] fix: visual improvements for other states --- paket/src/bin/paket.rs | 48 ++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/paket/src/bin/paket.rs b/paket/src/bin/paket.rs index ff0c5c3..7c8992d 100644 --- a/paket/src/bin/paket.rs +++ b/paket/src/bin/paket.rs @@ -56,31 +56,41 @@ impl AsyncComponent for App { #[wrap(Some)] set_content = &adw::ViewStack { #[name = "page_loading"] - add = &adw::Bin { + add = &adw::ToolbarView { + add_top_bar = &adw::HeaderBar {}, + #[wrap(Some)] - set_child = &adw::Spinner {} + set_content = &adw::Bin { + #[wrap(Some)] + set_child = &adw::Spinner {} + } }, #[local_ref] add = page_login -> adw::Bin {}, - + #[local_ref] - add = page_ready -> adw::Bin {}, + add = page_ready -> adw::NavigationView {}, #[name = "page_error"] - add = &adw::Bin { - #[name = "page_error_status"] + add = &adw::ToolbarView { + add_top_bar = &adw::HeaderBar {}, + #[wrap(Some)] - set_child = &adw::StatusPage {} + set_content = &adw::Bin { + #[name = "page_error_status"] + #[wrap(Some)] + set_child = &adw::StatusPage {} + } }, #[track(model.changed(App::state()))] set_visible_child: { - let page: &adw::Bin = match model.state { - AppState::Loading => page_loading.as_ref(), - AppState::RequiresLogin => page_login.as_ref(), - AppState::Ready => page_ready.as_ref(), - AppState::Error => page_error.as_ref(), + let page = match model.state { + AppState::Loading => page_loading.widget_ref(), + AppState::RequiresLogin => page_login.widget_ref(), + AppState::Ready => page_ready.widget_ref(), + AppState::Error => page_error.widget_ref(), }; page } @@ -130,8 +140,8 @@ impl AsyncComponent for App { self.reset(); match message { AppInput::AddBreakpoint(breakpoint) => { - root.add_breakpoint(breakpoint); - }, + root.add_breakpoint(breakpoint); + } AppInput::SwitchToLoading => { self.set_state(AppState::Loading); } @@ -155,8 +165,14 @@ fn convert_login_response(response: LoginOutput) -> AppInput { match response { LoginOutput::RequiresLogin => AppInput::SwitchToLogin, LoginOutput::RequiresLoading => AppInput::SwitchToLoading, - LoginOutput::Error(library_error) => AppInput::FatalErr(AppError { short: "Unhandled API error".to_string(), long: library_error.to_string() }), - LoginOutput::KeyringError(error) => AppInput::FatalErr(AppError { short: "Keyring usage failed".to_string(), long: error.to_string() }), + LoginOutput::Error(library_error) => AppInput::FatalErr(AppError { + short: "Unhandled API error".to_string(), + long: library_error.to_string(), + }), + LoginOutput::KeyringError(error) => AppInput::FatalErr(AppError { + short: "Keyring usage failed".to_string(), + long: error.to_string(), + }), } }