[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route informed animation 2 #150031

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Trim unnecessary code
  • Loading branch information
MitchellGoodwin committed Jun 11, 2024
commit 0c2862957cf0fd621f393fccec387b7e869ee57a
26 changes: 24 additions & 2 deletions packages/flutter/lib/src/cupertino/route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,17 @@ mixin CupertinoRouteTransitionMixin<T> on PageRoute<T> {
@override
bool canTransitionTo(TransitionRoute<dynamic> nextRoute) {
// Don't perform outgoing animation if the next route is a fullscreen dialog.
// For MBS: we need to allow for transitioning to a route that will provide a secondary animation to use.
// This always plays the transition, but it would be better to check if the next route provides a delegated
// transition.
return nextRoute is ModalRoute || nextRoute is CupertinoRouteTransitionMixin && !nextRoute.fullscreenDialog;
// return !(nextRoute is CupertinoRouteTransitionMixin && nextRoute.fullscreenDialog);
}

@override
bool canTransitionFrom(TransitionRoute<dynamic> previousRoute) {
if (previousRoute is ModalRoute<T> && navigator != null) {
navigator!.delegateTransitionBuilder = previousRoute.delegatedTransition;
previousRoute.navigator!.delegateTransitionBuilder = delegatedTransition;
// navigator!.delegateTransitionBuilder = previousRoute.delegatedTransition;
}
return previousRoute is ModalRoute || previousRoute is CupertinoRouteTransitionMixin && !previousRoute.fullscreenDialog;
}
Expand Down Expand Up @@ -489,6 +492,25 @@ class CupertinoPageTransition extends StatefulWidget {
/// Used to precisely track back gesture drags.
final bool linearTransition;


/// The delegated transition.
static Widget delegateTransition(BuildContext context, Widget? child, Animation<double> secondaryAnimation) {
final Animation<Offset> delegatedPositionAnimation =
CurvedAnimation(
parent: secondaryAnimation,
curve: Curves.linearToEaseOut,
reverseCurve: Curves.easeInToLinear,
).drive(_kMiddleLeftTween);
assert(debugCheckHasDirectionality(context));
final TextDirection textDirection = Directionality.of(context);
return SlideTransition(
position: delegatedPositionAnimation,
textDirection: textDirection,
transformHitTests: false,
child: child,
);
}

@override
State<CupertinoPageTransition> createState() => _CupertinoPageTransitionState();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ mixin MaterialRouteTransitionMixin<T> on PageRoute<T> {
@override
bool canTransitionFrom(TransitionRoute<dynamic> previousRoute) {
if (previousRoute is ModalRoute<T> && navigator != null) {
navigator!.delegateTransitionBuilder = previousRoute.delegatedTransition;
previousRoute.navigator!.delegateTransitionBuilder = delegatedTransition;
}
return previousRoute is PageRoute;
}
Expand Down
5 changes: 0 additions & 5 deletions packages/flutter/lib/src/material/page_transitions_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -655,11 +655,6 @@ class OpenUpwardsPageTransitionsBuilder extends PageTransitionsBuilder {
/// Android P.
const OpenUpwardsPageTransitionsBuilder();

/// Delegate animation
static Widget delegateTransition(BuildContext context, Widget? child, Animation<double> secondaryAnimation) {
return _OpenUpwardsPageTransition.delegateTransition(context, child, secondaryAnimation);
}

@override
Widget buildTransitions<T>(
PageRoute<T>? route,
Expand Down