freezer/lib/page_routes/fade.dart

51 lines
1.3 KiB
Dart
Raw Normal View History

2023-07-29 02:17:26 +00:00
import 'package:flutter/cupertino.dart';
import 'package:freezer/page_routes/basic_page_route.dart';
import 'package:freezer/ui/animated_blur.dart';
class FadePageRoute<T> extends BasicPageRoute<T> {
@override
final bool barrierDismissible;
@override
final Color? barrierColor;
@override
final bool opaque;
2023-07-29 02:17:26 +00:00
final WidgetBuilder builder;
final bool blur;
FadePageRoute({
required this.builder,
this.blur = false,
super.transitionDuration,
super.maintainState,
super.settings,
this.barrierColor,
this.barrierDismissible = false,
this.opaque = true,
});
2023-07-29 02:17:26 +00:00
@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 baseTransition = FadeTransition(
opacity: animation,
child: child,
);
if (blur) {
return Stack(children: [
Positioned.fill(
child: AnimatedBlur(
animation: animation,
multiplier: 10.0,
child: const SizedBox())),
baseTransition,
]);
}
return baseTransition;
}
}