Initial commit
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PageTransitions {
|
||||
PageTransitions._();
|
||||
|
||||
static const Duration detailForward = Duration(milliseconds: 280);
|
||||
static const Duration detailReverse = Duration(milliseconds: 220);
|
||||
static const Duration shellFade = Duration(milliseconds: 200);
|
||||
|
||||
static Duration get playerForward =>
|
||||
defaultTargetPlatform == TargetPlatform.android
|
||||
? Duration.zero
|
||||
: detailForward;
|
||||
|
||||
static Duration get playerReverse =>
|
||||
defaultTargetPlatform == TargetPlatform.android
|
||||
? Duration.zero
|
||||
: detailReverse;
|
||||
|
||||
|
||||
static Widget fade(
|
||||
BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child,
|
||||
) => FadeTransition(opacity: animation, child: child);
|
||||
|
||||
|
||||
static Widget slideRight(
|
||||
BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child,
|
||||
) {
|
||||
final offset = Tween<Offset>(begin: const Offset(0.05, 0), end: Offset.zero)
|
||||
.animate(
|
||||
CurvedAnimation(
|
||||
parent: animation,
|
||||
curve: Curves.easeOut,
|
||||
reverseCurve: Curves.easeIn,
|
||||
),
|
||||
);
|
||||
return SlideTransition(
|
||||
position: offset,
|
||||
child: FadeTransition(opacity: animation, child: child),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
static Widget slideRightFull(
|
||||
BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child,
|
||||
) {
|
||||
final offset = Tween<Offset>(begin: const Offset(1, 0), end: Offset.zero)
|
||||
.animate(
|
||||
CurvedAnimation(
|
||||
parent: animation,
|
||||
curve: Curves.easeOutCubic,
|
||||
reverseCurve: Curves.easeInCubic,
|
||||
),
|
||||
);
|
||||
return SlideTransition(
|
||||
position: offset,
|
||||
|
||||
|
||||
child: ClipRect(child: RepaintBoundary(child: child)),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
static Widget player(
|
||||
BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child,
|
||||
) {
|
||||
if (defaultTargetPlatform == TargetPlatform.android) return child;
|
||||
return slideRightFull(context, animation, secondaryAnimation, child);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user