From 6530f2c57d36a7cb10c6cda50f49c0a9f8363ff1 Mon Sep 17 00:00:00 2001 From: nyne Date: Wed, 29 Jan 2025 21:22:46 +0800 Subject: [PATCH] Improve animation --- lib/components/page_route.dart | 56 +++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/lib/components/page_route.dart b/lib/components/page_route.dart index 1657137..24337b8 100644 --- a/lib/components/page_route.dart +++ b/lib/components/page_route.dart @@ -121,8 +121,13 @@ mixin _AppRouteTransitionMixin on PageRoute { @override Widget buildTransitions(BuildContext context, Animation animation, Animation secondaryAnimation, Widget child) { + child = ColoredBox( + color: FluentTheme.of(context).micaBackgroundColor, + child: child, + ); + if (isRoot) { - return EntrancePageTransition( + child = EntrancePageTransition( animation: CurvedAnimation( parent: animation, curve: FluentTheme.of(context).animationCurve, @@ -135,21 +140,25 @@ mixin _AppRouteTransitionMixin on PageRoute { child: child) : child, ); + } else { + child = DrillInPageTransition( + animation: CurvedAnimation( + parent: animation, + curve: FluentTheme + .of(context) + .animationCurve, + ), + child: enableIOSGesture && App.isIOS + ? IOSBackGestureDetector( + gestureWidth: _kBackGestureWidth, + enabledCallback: () => _isPopGestureEnabled(this), + onStartPopGesture: () => _startPopGesture(this), + child: child) + : child, + ); } - return DrillInPageTransition( - animation: CurvedAnimation( - parent: animation, - curve: FluentTheme.of(context).animationCurve, - ), - child: enableIOSGesture && App.isIOS - ? IOSBackGestureDetector( - gestureWidth: _kBackGestureWidth, - enabledCallback: () => _isPopGestureEnabled(this), - onStartPopGesture: () => _startPopGesture(this), - child: child) - : child, - ); + return child; } IOSBackGestureController _startPopGesture(PageRoute route) { @@ -427,17 +436,14 @@ class EntrancePageTransition extends StatelessWidget { @override Widget build(BuildContext context) { - return ColoredBox( - color: FluentTheme.of(context).micaBackgroundColor, - child: SlideTransition( - position: Tween( - begin: const Offset(0, 0.1), - end: Offset.zero, - ).animate(animation), - child: FadeTransition( - opacity: animation, - child: child, - ), + return SlideTransition( + position: Tween( + begin: const Offset(0, 0.1), + end: Offset.zero, + ).animate(animation), + child: FadeTransition( + opacity: animation, + child: child, ), ); }