exit_confirm_dialog: Add open/close animation

This commit is contained in:
Ivan Molodetskikh
2025-08-22 08:50:52 +03:00
parent 9d3beb4931
commit 210d5e90fe
4 changed files with 159 additions and 21 deletions
+46
View File
@@ -1109,6 +1109,8 @@ pub struct Animations {
#[knuffel(child, default)]
pub config_notification_open_close: ConfigNotificationOpenCloseAnim,
#[knuffel(child, default)]
pub exit_confirmation_open_close: ExitConfirmationOpenCloseAnim,
#[knuffel(child, default)]
pub screenshot_ui_open: ScreenshotUiOpenAnim,
#[knuffel(child, default)]
pub overview_open_close: OverviewOpenCloseAnim,
@@ -1126,6 +1128,7 @@ impl Default for Animations {
window_close: Default::default(),
window_resize: Default::default(),
config_notification_open_close: Default::default(),
exit_confirmation_open_close: Default::default(),
screenshot_ui_open: Default::default(),
overview_open_close: Default::default(),
}
@@ -1260,6 +1263,22 @@ impl Default for ConfigNotificationOpenCloseAnim {
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct ExitConfirmationOpenCloseAnim(pub Animation);
impl Default for ExitConfirmationOpenCloseAnim {
fn default() -> Self {
Self(Animation {
off: false,
kind: AnimationKind::Spring(SpringParams {
damping_ratio: 0.6,
stiffness: 500,
epsilon: 0.01,
}),
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct ScreenshotUiOpenAnim(pub Animation);
@@ -3338,6 +3357,21 @@ where
}
}
impl<S> knuffel::Decode<S> for ExitConfirmationOpenCloseAnim
where
S: knuffel::traits::ErrorSpan,
{
fn decode_node(
node: &knuffel::ast::SpannedNode<S>,
ctx: &mut knuffel::decode::Context<S>,
) -> Result<Self, DecodeError<S>> {
let default = Self::default().0;
Ok(Self(Animation::decode_node(node, ctx, default, |_, _| {
Ok(false)
})?))
}
}
impl<S> knuffel::Decode<S> for ScreenshotUiOpenAnim
where
S: knuffel::traits::ErrorSpan,
@@ -5148,6 +5182,18 @@ mod tests {
),
},
),
exit_confirmation_open_close: ExitConfirmationOpenCloseAnim(
Animation {
off: false,
kind: Spring(
SpringParams {
damping_ratio: 0.6,
stiffness: 500,
epsilon: 0.01,
},
),
},
),
screenshot_ui_open: ScreenshotUiOpenAnim(
Animation {
off: false,