💫 Optimize the notification animation

This commit is contained in:
2026-01-15 19:34:03 +08:00
parent d5feea52fa
commit e24b1fc135

View File

@@ -81,10 +81,15 @@ class AnimatedNotificationItem extends HookConsumerWidget {
); );
final isDismissed = useState(false); final isDismissed = useState(false);
final curvedAnimation = CurvedAnimation(
parent: animationController,
curve: Curves.easeOutCubic,
);
final slideTween = Tween<Offset>( final slideTween = Tween<Offset>(
begin: isDesktop ? Offset(1.0, 0.0) : Offset(0.0, -1.0), begin: isDesktop ? Offset(1.0, 0.0) : Offset(0.0, -1.0),
end: Offset.zero, end: Offset.zero,
).chain(CurveTween(curve: Curves.easeOutCubic)); );
final progressAnimation = Tween<double>( final progressAnimation = Tween<double>(
begin: 1.0, begin: 1.0,
@@ -111,8 +116,12 @@ class AnimatedNotificationItem extends HookConsumerWidget {
final itemWidth = isDesktop ? 420.0 : MediaQuery.sizeOf(context).width - 40; final itemWidth = isDesktop ? 420.0 : MediaQuery.sizeOf(context).width - 40;
return SlideTransition( return SizeTransition(
position: slideTween.animate(animationController), sizeFactor: curvedAnimation,
axis: Axis.vertical,
axisAlignment: -1.0,
child: SlideTransition(
position: slideTween.animate(curvedAnimation),
child: Padding( child: Padding(
padding: isDesktop padding: isDesktop
? const EdgeInsets.only(bottom: 12, right: 16) ? const EdgeInsets.only(bottom: 12, right: 16)
@@ -124,6 +133,7 @@ class AnimatedNotificationItem extends HookConsumerWidget {
progress: progressAnimation, progress: progressAnimation,
).width(itemWidth), ).width(itemWidth),
), ),
),
); );
} }
} }