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)]
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(),
}),
}
}