45 lines
1.4 KiB
Dart
45 lines
1.4 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
import 'package:freezer/page_routes/basic_page_route.dart';
|
|
import 'package:freezer/ui/animated_blur.dart';
|
|
|
|
class BlurSlidePageRoute<T> extends BasicPageRoute<T> {
|
|
final WidgetBuilder builder;
|
|
final Curve animationCurve;
|
|
final _animationTween = Tween(
|
|
begin: const Offset(0.0, 1.0),
|
|
end: Offset.zero,
|
|
);
|
|
|
|
BlurSlidePageRoute({
|
|
required this.builder,
|
|
this.animationCurve = Curves.linearToEaseOut,
|
|
transitionDuration = const Duration(milliseconds: 300),
|
|
maintainState = true,
|
|
RouteSettings? settings,
|
|
}) : super(
|
|
transitionDuration: transitionDuration,
|
|
maintainState: maintainState,
|
|
settings: settings,
|
|
);
|
|
|
|
@override
|
|
Widget buildPage(BuildContext context, Animation<double> animation,
|
|
Animation<double> secondaryAnimation) =>
|
|
builder(context);
|
|
|
|
@override
|
|
Widget buildTransitions(BuildContext context, Animation<double> _animation,
|
|
Animation<double> secondaryAnimation, Widget child) {
|
|
final animation =
|
|
CurvedAnimation(parent: _animation, curve: animationCurve);
|
|
return Stack(children: [
|
|
Positioned.fill(
|
|
child: AnimatedBlur(
|
|
animation: animation, multiplier: 10.0, child: const SizedBox()),
|
|
),
|
|
SlideTransition(
|
|
position: _animationTween.animate(animation), child: child),
|
|
]);
|
|
}
|
|
}
|