Unverified Commit 9984ebba authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[framework] use ImageFilter for zoom page transition (#101786)

parent 91242870
......@@ -325,7 +325,11 @@ class _ZoomEnterTransition extends StatelessWidget {
},
child: FadeTransition(
opacity: fadeTransition,
child: ScaleTransition(scale: scaleTransition, child: child),
child: ScaleTransition(
scale: scaleTransition,
filterQuality: FilterQuality.none,
child: child,
),
),
);
}
......@@ -372,7 +376,11 @@ class _ZoomExitTransition extends StatelessWidget {
return FadeTransition(
opacity: fadeTransition,
child: ScaleTransition(scale: scaleTransition, child: child),
child: ScaleTransition(
scale: scaleTransition,
filterQuality: FilterQuality.none,
child: child,
),
);
}
}
......
......@@ -5,6 +5,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
......@@ -220,4 +221,61 @@ void main() {
await tester.pumpAndSettle();
expect(builtCount, 1);
}, variant: TargetPlatformVariant.only(TargetPlatform.android));
testWidgets('_ZoomPageTransition uses a FilterQuality while animating', (WidgetTester tester) async {
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (BuildContext context) => Material(
child: TextButton(
child: const Text('push'),
onPressed: () { Navigator.of(context).pushNamed('/b'); },
),
),
'/b': (BuildContext context) => StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return TextButton(
child: const Text('pop'),
onPressed: () { Navigator.pop(context); },
);
},
),
};
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(
pageTransitionsTheme: const PageTransitionsTheme(
builders: <TargetPlatform, PageTransitionsBuilder>{
TargetPlatform.android: ZoomPageTransitionsBuilder(), // creates a _ZoomPageTransition
},
),
),
routes: routes,
),
);
expect(tester.layers, isNot(contains(isA<ImageFilterLayer>())));
await tester.tap(find.text('push'));
await tester.pump();
await tester.pump();
expect(tester.layers, contains(isA<ImageFilterLayer>()));
expect(tester.layers.whereType<ImageFilterLayer>(), hasLength(1));
await tester.pumpAndSettle();
expect(tester.layers, isNot(contains(isA<ImageFilterLayer>())));
await tester.tap(find.text('pop'));
await tester.pump();
await tester.pump();
expect(tester.layers, contains(isA<ImageFilterLayer>()));
// exiting requires two different zooms.
expect(tester.layers.whereType<ImageFilterLayer>(), hasLength(2));
await tester.pumpAndSettle();
expect(tester.layers, isNot(contains(isA<ImageFilterLayer>())));
}, variant: TargetPlatformVariant.only(TargetPlatform.android));
}
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