feat(ui): implement in-overlay toast animation engine and overhaul standalone toasts

This commit is contained in:
katR 2026-10-04 12:12:29 +05:30
parent 605c1792c8
commit a14902dcb0

View file

@ -1270,6 +1270,13 @@ impl ScytheOverlayApp {
} }
pub fn show_hud_notification(&mut self, title: &str, subtitle: &str, icon: crate::overlay::ToastIcon) { pub fn show_hud_notification(&mut self, title: &str, subtitle: &str, icon: crate::overlay::ToastIcon) {
self.in_overlay_toast = Some(InOverlayToast {
title: title.to_string(),
subtitle: subtitle.to_string(),
icon,
created_at: Instant::now(),
duration: Duration::from_millis(2800),
});
self.hud_notification = Some(HudNotification { self.hud_notification = Some(HudNotification {
title: title.to_string(), title: title.to_string(),
subtitle: subtitle.to_string(), subtitle: subtitle.to_string(),
@ -3671,4 +3678,15 @@ mod tests {
assert!(pos_y + modal_h <= screen_h); assert!(pos_y + modal_h <= screen_h);
} }
} }
#[test]
fn test_cubic_ease_out_progress() {
let ease_out = |t: f32| -> f32 {
let inv = 1.0 - t.clamp(0.0, 1.0);
1.0 - inv * inv * inv
};
assert_eq!(ease_out(0.0), 0.0);
assert_eq!(ease_out(1.0), 1.0);
assert!(ease_out(0.5) > 0.5); // Fast start, gentle deceleration
}
} }