Unverified Commit 4e16b9db authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Attempt a less invasive way to disable fading. (#13733)

Hopefully this will fix the performance regression in https://github.com/flutter/flutter/pull/13680 but with an easier way to flip the switch.
parent b3cfa785
...@@ -18,16 +18,17 @@ final Tween<Offset> _kBottomUpTween = new Tween<Offset>( ...@@ -18,16 +18,17 @@ final Tween<Offset> _kBottomUpTween = new Tween<Offset>(
class _MountainViewPageTransition extends StatelessWidget { class _MountainViewPageTransition extends StatelessWidget {
_MountainViewPageTransition({ _MountainViewPageTransition({
Key key, Key key,
@required bool fade,
@required Animation<double> routeAnimation, @required Animation<double> routeAnimation,
@required this.child, @required this.child,
}) : _positionAnimation = _kBottomUpTween.animate(new CurvedAnimation( }) : _positionAnimation = _kBottomUpTween.animate(new CurvedAnimation(
parent: routeAnimation, // The route's linear 0.0 - 1.0 animation. parent: routeAnimation, // The route's linear 0.0 - 1.0 animation.
curve: Curves.fastOutSlowIn, curve: Curves.fastOutSlowIn,
)), )),
_opacityAnimation = new CurvedAnimation( _opacityAnimation = fade ? new CurvedAnimation(
parent: routeAnimation, parent: routeAnimation,
curve: Curves.easeIn, // Eyeballed from other Material apps. curve: Curves.easeIn, // Eyeballed from other Material apps.
), ) : const AlwaysStoppedAnimation<double>(1.0),
super(key: key); super(key: key);
final Animation<Offset> _positionAnimation; final Animation<Offset> _positionAnimation;
...@@ -83,6 +84,14 @@ class MaterialPageRoute<T> extends PageRoute<T> { ...@@ -83,6 +84,14 @@ class MaterialPageRoute<T> extends PageRoute<T> {
assert(opaque); assert(opaque);
} }
/// Turns on the fading of routes during page transitions.
///
/// This is currently disabled by default because of performance issues on
/// low-end phones. Eventually these issues will be resolved and this flag
/// will be removed.
@Deprecated('This flag will eventually be removed once the performance issues are resolved. See: https://github.com/flutter/flutter/issues/13736')
static bool debugEnableFadingRoutes = false;
/// Builds the primary contents of the route. /// Builds the primary contents of the route.
final WidgetBuilder builder; final WidgetBuilder builder;
...@@ -159,6 +168,7 @@ class MaterialPageRoute<T> extends PageRoute<T> { ...@@ -159,6 +168,7 @@ class MaterialPageRoute<T> extends PageRoute<T> {
return new _MountainViewPageTransition( return new _MountainViewPageTransition(
routeAnimation: animation, routeAnimation: animation,
child: child, child: child,
fade: debugEnableFadingRoutes, // ignore: deprecated_member_use
); );
} }
} }
......
...@@ -40,7 +40,7 @@ void main() { ...@@ -40,7 +40,7 @@ void main() {
// Animation begins 3/4 of the way up the page. // Animation begins 3/4 of the way up the page.
expect(widget2TopLeft.dy < widget2Size.height / 4.0, true); expect(widget2TopLeft.dy < widget2Size.height / 4.0, true);
// Animation starts with page 2 being near transparent. // Animation starts with page 2 being near transparent.
expect(widget2Opacity.opacity < 0.01, true); expect(widget2Opacity.opacity < 0.01, MaterialPageRoute.debugEnableFadingRoutes); // ignore: deprecated_member_use
await tester.pump(const Duration(milliseconds: 300)); await tester.pump(const Duration(milliseconds: 300));
...@@ -59,7 +59,7 @@ void main() { ...@@ -59,7 +59,7 @@ void main() {
// Page 2 starts to move down. // Page 2 starts to move down.
expect(widget1TopLeft.dy < widget2TopLeft.dy, true); expect(widget1TopLeft.dy < widget2TopLeft.dy, true);
// Page 2 starts to lose opacity. // Page 2 starts to lose opacity.
expect(widget2Opacity.opacity < 1.0, true); expect(widget2Opacity.opacity < 1.0, MaterialPageRoute.debugEnableFadingRoutes); // ignore: deprecated_member_use
await tester.pump(const Duration(milliseconds: 300)); await tester.pump(const Duration(milliseconds: 300));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment