💫 Optimize the notification animation
This commit is contained in:
@@ -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,18 +116,23 @@ 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,
|
||||||
child: Padding(
|
axis: Axis.vertical,
|
||||||
padding: isDesktop
|
axisAlignment: -1.0,
|
||||||
? const EdgeInsets.only(bottom: 12, right: 16)
|
child: SlideTransition(
|
||||||
: const EdgeInsets.only(bottom: 12, left: 16, right: 16),
|
position: slideTween.animate(curvedAnimation),
|
||||||
child: NotificationItemWidget(
|
child: Padding(
|
||||||
item: item,
|
padding: isDesktop
|
||||||
isDesktop: isDesktop,
|
? const EdgeInsets.only(bottom: 12, right: 16)
|
||||||
onDismiss: () {},
|
: const EdgeInsets.only(bottom: 12, left: 16, right: 16),
|
||||||
progress: progressAnimation,
|
child: NotificationItemWidget(
|
||||||
).width(itemWidth),
|
item: item,
|
||||||
|
isDesktop: isDesktop,
|
||||||
|
onDismiss: () {},
|
||||||
|
progress: progressAnimation,
|
||||||
|
).width(itemWidth),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user