implement tab loading indicator

This commit is contained in:
yggverse 2024-10-11 07:29:09 +03:00
parent 5f47253057
commit 472aadb9d3
2 changed files with 20 additions and 7 deletions

View File

@ -85,7 +85,11 @@ impl Item {
}
pub fn update(&self) {
// Update child components
self.page.update();
// Update tab loading indicator
self.widget.gobject().set_loading(self.page.is_loading());
}
pub fn clean(

View File

@ -447,22 +447,31 @@ impl Page {
}
pub fn update(&self) {
// Update components
self.navigation.update(self.progress_fraction());
// @TODO self.content.update();
}
// Getters
pub fn progress_fraction(&self) -> Option<f64> {
// Interpret status to progress fraction
let progress_fraction = match self.meta.borrow().status {
match self.meta.borrow().status {
Some(Status::Prepare | Status::Reload) => Some(0.0),
Some(Status::Connect) => Some(0.25),
Some(Status::Request) => Some(0.50),
Some(Status::Response) => Some(0.75),
Some(Status::Failure | Status::Redirect | Status::Success) => Some(1.0),
_ => None,
};
// Update components
self.navigation.update(progress_fraction);
// @TODO self.content.update();
}
}
pub fn is_loading(&self) -> bool {
match self.progress_fraction() {
Some(progress_fraction) => progress_fraction < 1.0,
None => false,
}
}
// Getters
pub fn meta_title(&self) -> Option<GString> {
self.meta.borrow().title.clone()
}