2022-12-08 18:50:27 -07:00
|
|
|
import 'package:flutter/cupertino.dart';
|
2022-08-29 20:38:28 -06:00
|
|
|
|
|
|
|
class PageRoutes {
|
|
|
|
static const Duration kDefaultDuration = Duration(milliseconds: 300);
|
|
|
|
|
2022-12-19 13:43:30 -07:00
|
|
|
static Route<T> dialog<T>(Widget child, {Duration duration = kDefaultDuration, bool opaque = false}) {
|
2022-12-08 18:50:27 -07:00
|
|
|
// Use cupertino routes for all dialogs so we get the 'swipe right to go back' behavior
|
2022-12-19 13:43:30 -07:00
|
|
|
if (opaque) {
|
|
|
|
return CupertinoPageRoute(builder: (_) => child);
|
|
|
|
}
|
2022-12-08 18:50:27 -07:00
|
|
|
|
2022-12-12 11:50:24 -07:00
|
|
|
// SB: Removed this in favor of Cupertino routes, we could restore with a `useFade` option
|
2022-12-19 13:43:30 -07:00
|
|
|
return PageRouteBuilder<T>(
|
|
|
|
transitionDuration: duration,
|
|
|
|
reverseTransitionDuration: duration,
|
|
|
|
pageBuilder: (context, animation, secondaryAnimation) => child,
|
|
|
|
opaque: opaque,
|
|
|
|
fullscreenDialog: true,
|
|
|
|
transitionsBuilder: (context, animation, secondaryAnimation, child) =>
|
|
|
|
FadeTransition(opacity: animation, child: child),
|
|
|
|
);
|
2022-08-29 20:38:28 -06:00
|
|
|
}
|
|
|
|
}
|