mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-21 03:15:14 +08:00
73 lines
1.9 KiB
Dart
73 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class PublishRoute<T> extends PopupRoute<T> {
|
|
PublishRoute({
|
|
required RoutePageBuilder pageBuilder,
|
|
bool barrierDismissible = true,
|
|
String? barrierLabel,
|
|
Color barrierColor = const Color(0x80000000),
|
|
Duration transitionDuration = const Duration(milliseconds: 500),
|
|
RouteTransitionsBuilder? transitionBuilder,
|
|
super.settings,
|
|
}) : widget = pageBuilder,
|
|
_barrierDismissible = barrierDismissible,
|
|
_barrierLabel = barrierLabel,
|
|
_barrierColor = barrierColor,
|
|
_transitionDuration = transitionDuration,
|
|
_transitionBuilder = transitionBuilder;
|
|
|
|
final RoutePageBuilder widget;
|
|
|
|
@override
|
|
bool get barrierDismissible => _barrierDismissible;
|
|
final bool _barrierDismissible;
|
|
|
|
@override
|
|
String? get barrierLabel => _barrierLabel;
|
|
final String? _barrierLabel;
|
|
|
|
@override
|
|
Color get barrierColor => _barrierColor;
|
|
final Color _barrierColor;
|
|
|
|
@override
|
|
Duration get transitionDuration => _transitionDuration;
|
|
final Duration _transitionDuration;
|
|
|
|
final RouteTransitionsBuilder? _transitionBuilder;
|
|
|
|
@override
|
|
Widget buildPage(
|
|
BuildContext context,
|
|
Animation<double> animation,
|
|
Animation<double> secondaryAnimation,
|
|
) {
|
|
return Semantics(
|
|
scopesRoute: true,
|
|
explicitChildNodes: true,
|
|
child: widget(context, animation, secondaryAnimation),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget buildTransitions(
|
|
BuildContext context,
|
|
Animation<double> animation,
|
|
Animation<double> secondaryAnimation,
|
|
Widget child,
|
|
) {
|
|
if (_transitionBuilder != null) {
|
|
return _transitionBuilder(context, animation, secondaryAnimation, child);
|
|
}
|
|
return SlideTransition(
|
|
position: animation.drive(
|
|
Tween<Offset>(
|
|
begin: const Offset(0.0, 1.0),
|
|
end: Offset.zero,
|
|
).chain(CurveTween(curve: Curves.linear)),
|
|
),
|
|
child: child,
|
|
);
|
|
}
|
|
}
|