fix: visual improvements for other states
This commit is contained in:
parent
87730dbc43
commit
24d944e377
1 changed files with 32 additions and 16 deletions
|
@ -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_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 {
|
||||
add = &adw::ToolbarView {
|
||||
add_top_bar = &adw::HeaderBar {},
|
||||
|
||||
#[wrap(Some)]
|
||||
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
|
||||
}
|
||||
|
@ -131,7 +141,7 @@ impl AsyncComponent for App {
|
|||
match message {
|
||||
AppInput::AddBreakpoint(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(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue