Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smooth model switch #166

Merged
merged 11 commits into from
Jul 26, 2024
Prev Previous commit
Next Next commit
Make sure loading bar in model selector is visible on start up
jmbejar committed Jul 25, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 51070b296a4c67c0984d947699e7af91e7da5448
4 changes: 1 addition & 3 deletions src/chat/model_selector.rs
Original file line number Diff line number Diff line change
@@ -37,7 +37,6 @@ live_design! {
loading = <ModelSelectorLoading> {
width: Fill,
height: Fill,
visible: false,
}

choose = <View> {
@@ -315,7 +314,7 @@ impl ModelSelector {
self.model_selector_loading(id!(loading))
.show_and_animate(cx);
} else {
self.model_selector_loading(id!(loading)).hide(cx);
self.model_selector_loading(id!(loading)).hide();
}
}

@@ -358,7 +357,6 @@ impl ModelSelector {
let size = format_model_size(&downloaded_file.file.size).unwrap_or("".to_string());
let size_visible = !size.trim().is_empty();

self.model_selector_loading(id!(loading)).hide(cx);
self.view(id!(selected)).apply_over(
cx,
live! {
10 changes: 4 additions & 6 deletions src/chat/model_selector_loading.rs
Original file line number Diff line number Diff line change
@@ -101,15 +101,13 @@ impl Widget for ModelSelectorLoading {

impl ModelSelectorLoading {
pub fn update_animation(&mut self, cx: &mut Cx) {
self.visible = true;
if self.animator_in_state(cx, id!(line.restart)) {
self.visible = true;
self.animator_play(cx, id!(line.run));
self.timer = cx.start_timeout(1.5);
} else {
self.visible = true;
self.animator_play(cx, id!(line.restart));
self.timer = cx.start_timeout(1.5);
}
self.timer = cx.start_timeout(1.5);
}
}

@@ -123,11 +121,11 @@ impl ModelSelectorLoadingRef {
}
}

pub fn hide(&mut self, cx: &mut Cx) {
pub fn hide(&mut self) {
let Some(mut inner) = self.borrow_mut() else {
return;
};
inner.view.visible = false;
inner.visible = false;
inner.timer = Timer::default();
}
}