|
|
|
|
|
|
Animation<float> animation, |
|
|
|
Animation<float> secondaryAnimation, |
|
|
|
Widget child) { |
|
|
|
|
|
|
|
CurvedAnimation fadeAnimation = new CurvedAnimation( |
|
|
|
parent: animation, |
|
|
|
curve: Curves.easeInOut |
|
|
|
|
|
|
barrierColor: CupertinoDynamicColor.resolve(_kModalBarrierColor, context), |
|
|
|
transitionDuration: TimeSpan.FromMilliseconds(250), |
|
|
|
pageBuilder: (BuildContext context1, Animation<float> animation, Animation<float> secondaryAnimation)=> { |
|
|
|
return builder(context1); |
|
|
|
}, |
|
|
|
transitionBuilder: _buildCupertinoDialogTransitions, |
|
|
|
useRootNavigator: useRootNavigator, |
|
|
|
routeSettings: routeSettings |
|
|
|
); |
|
|
|
return builder(context1); |
|
|
|
}, |
|
|
|
transitionBuilder: _buildCupertinoDialogTransitions, |
|
|
|
useRootNavigator: useRootNavigator, |
|
|
|
routeSettings: routeSettings |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
string title = "", |
|
|
|
bool maintainState = true, |
|
|
|
bool fullscreenDialog = false |
|
|
|
) : |
|
|
|
base(settings: settings, fullscreenDialog: fullscreenDialog) { |
|
|
|
) : base(settings: settings, fullscreenDialog: fullscreenDialog) { |
|
|
|
D.assert(builder != null); |
|
|
|
D.assert(opaque); |
|
|
|
this.builder = builder; |
|
|
|
|
|
|
public override bool maintainState { get; } |
|
|
|
|
|
|
|
public override TimeSpan transitionDuration { |
|
|
|
get { return new TimeSpan(0, 0, 0, 0, 400); } |
|
|
|
get { return TimeSpan.FromMilliseconds(400); } |
|
|
|
} |
|
|
|
|
|
|
|
public override Color barrierColor { |
|
|
|
|
|
|
get { return null; } |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*public override bool canTransitionFrom(TransitionRoute<object> previousRoute) { |
|
|
|
return previousRoute is CupertinoPageRoute<object>; |
|
|
|
}*/ |
|
|
|
|
|
|
|
/*public override bool canTransitionTo(TransitionRoute<object> nextRoute) { |
|
|
|
return nextRoute is CupertinoPageRoute<object> && !((CupertinoPageRoute<object>) nextRoute).fullscreenDialog; |
|
|
|
}*/ |
|
|
|
public override bool canTransitionTo(TransitionRoute nextRoute) { |
|
|
|
return nextRoute is CupertinoPageRoute && !((CupertinoPageRoute) nextRoute).fullscreenDialog; |
|
|
|
} |
|
|
|
|
|
|
|
static bool isPopGestureInProgress(PageRoute route) { |
|
|
|
return route.navigator.userGestureInProgress; |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override Widget buildPage(BuildContext context, Animation<float> animation, |
|
|
|
Animation<float> secondaryAnimation) { |
|
|
|
public override Widget buildPage(BuildContext context, Animation<float> animation, Animation<float> secondaryAnimation) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
D.assert(() => { |
|
|
|
D.assert(() =>{ |
|
|
|
throw new UIWidgetsError( |
|
|
|
$"The builder for route {settings.name} returned null.\nRoute builders must never return null."); |
|
|
|
throw new UIWidgetsError(new List<DiagnosticsNode>{ |
|
|
|
new ErrorSummary($"The builder for route \"{settings.name}\" returned null."), |
|
|
|
new ErrorDescription("Route builders must never return null."), |
|
|
|
}); |
|
|
|
|
|
|
|
return true; |
|
|
|
}); |
|
|
|
return result; |
|
|
|
|
|
|
bool linearTransition = isPopGestureInProgress(route); |
|
|
|
if (route.fullscreenDialog) { |
|
|
|
return new CupertinoFullscreenDialogTransition( |
|
|
|
//animation: animation,
|
|
|
|
//child: child
|
|
|
|
primaryRouteAnimation: animation, |
|
|
|
secondaryRouteAnimation: secondaryAnimation, |
|
|
|
child: child, |
|
|
|
|
|
|
|
|
|
|
class CupertinoPageTransition : StatelessWidget { |
|
|
|
public CupertinoPageTransition( |
|
|
|
Animation<float> primaryRouteAnimation, |
|
|
|
Animation<float> secondaryRouteAnimation, |
|
|
|
Widget child, |
|
|
|
Animation<float> primaryRouteAnimation = null, |
|
|
|
Animation<float> secondaryRouteAnimation = null, |
|
|
|
Widget child = null, |
|
|
|
Key key = null |
|
|
|
) : base(key: key) { |
|
|
|
_primaryPositionAnimation = |
|
|
|
|
|
|
Animation<float> primaryRouteAnimation = null, |
|
|
|
Animation<float> secondaryRouteAnimation = null, |
|
|
|
Widget child = null, |
|
|
|
bool linearTransition =false |
|
|
|
bool linearTransition = false |
|
|
|
|
|
|
|
) : base(key: key) { |
|
|
|
_positionAnimation = new CurvedAnimation( |
|
|
|
|
|
|
_CupertinoBackGestureController _backGestureController; |
|
|
|
HorizontalDragGestureRecognizer _recognizer; |
|
|
|
|
|
|
|
|
|
|
|
public override void initState() { |
|
|
|
base.initState(); |
|
|
|
_recognizer = new HorizontalDragGestureRecognizer(debugOwner: this); |
|
|
|
|
|
|
void _handleDragEnd(DragEndDetails details) { |
|
|
|
D.assert(mounted); |
|
|
|
D.assert(_backGestureController != null); |
|
|
|
_backGestureController.dragEnd( |
|
|
|
_convertToLogical(details.velocity.pixelsPerSecond.dx / context.size.width) ?? 0); |
|
|
|
_backGestureController.dragEnd(_convertToLogical(details.velocity.pixelsPerSecond.dx / context.size.width) ?? 0); |
|
|
|
_backGestureController = null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
animateForward = velocity <= 0; |
|
|
|
} |
|
|
|
else { |
|
|
|
animateForward = controller.value > 0.5; |
|
|
|
animateForward = controller.value > 0.5f; |
|
|
|
} |
|
|
|
if (animateForward) { |
|
|
|
int droppedPageForwardAnimationTime = Mathf.Min( |
|
|
|