fix: visual improvements for other states

This commit is contained in:
jane400 2024-10-02 17:42:13 +02:00 committed by jane400
parent b6e0ef7638
commit c20a7a803a

View file

@ -56,31 +56,41 @@ impl AsyncComponent for App {
#[wrap(Some)] #[wrap(Some)]
set_content = &adw::ViewStack { set_content = &adw::ViewStack {
#[name = "page_loading"] #[name = "page_loading"]
add = &adw::Bin { add = &adw::ToolbarView {
add_top_bar = &adw::HeaderBar {},
#[wrap(Some)]
set_content = &adw::Bin {
#[wrap(Some)] #[wrap(Some)]
set_child = &adw::Spinner {} set_child = &adw::Spinner {}
}
}, },
#[local_ref] #[local_ref]
add = page_login -> adw::Bin {}, add = page_login -> adw::Bin {},
#[local_ref] #[local_ref]
add = page_ready -> adw::Bin {}, add = page_ready -> adw::NavigationView {},
#[name = "page_error"] #[name = "page_error"]
add = &adw::Bin { add = &adw::ToolbarView {
add_top_bar = &adw::HeaderBar {},
#[wrap(Some)]
set_content = &adw::Bin {
#[name = "page_error_status"] #[name = "page_error_status"]
#[wrap(Some)] #[wrap(Some)]
set_child = &adw::StatusPage {} set_child = &adw::StatusPage {}
}
}, },
#[track(model.changed(App::state()))] #[track(model.changed(App::state()))]
set_visible_child: { set_visible_child: {
let page: &adw::Bin = match model.state { let page = match model.state {
AppState::Loading => page_loading.as_ref(), AppState::Loading => page_loading.widget_ref(),
AppState::RequiresLogin => page_login.as_ref(), AppState::RequiresLogin => page_login.widget_ref(),
AppState::Ready => page_ready.as_ref(), AppState::Ready => page_ready.widget_ref(),
AppState::Error => page_error.as_ref(), AppState::Error => page_error.widget_ref(),
}; };
page page
} }
@ -131,7 +141,7 @@ impl AsyncComponent for App {
match message { match message {
AppInput::AddBreakpoint(breakpoint) => { AppInput::AddBreakpoint(breakpoint) => {
root.add_breakpoint(breakpoint); root.add_breakpoint(breakpoint);
}, }
AppInput::SwitchToLoading => { AppInput::SwitchToLoading => {
self.set_state(AppState::Loading); self.set_state(AppState::Loading);
} }
@ -155,8 +165,14 @@ fn convert_login_response(response: LoginOutput) -> AppInput {
match response { match response {
LoginOutput::RequiresLogin => AppInput::SwitchToLogin, LoginOutput::RequiresLogin => AppInput::SwitchToLogin,
LoginOutput::RequiresLoading => AppInput::SwitchToLoading, LoginOutput::RequiresLoading => AppInput::SwitchToLoading,
LoginOutput::Error(library_error) => AppInput::FatalErr(AppError { short: "Unhandled API error".to_string(), long: library_error.to_string() }), LoginOutput::Error(library_error) => AppInput::FatalErr(AppError {
LoginOutput::KeyringError(error) => AppInput::FatalErr(AppError { short: "Keyring usage failed".to_string(), long: error.to_string() }), 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(),
}),
} }
} }