Skip to content

Commit bfa272a

Browse files
authored
Revert "✨ Android Q transition by default (#98559)" (#100799)
This reverts commit c82ddd3.
1 parent c82ddd3 commit bfa272a

9 files changed

+100
-254
lines changed

packages/flutter/lib/src/material/page.dart

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,19 @@ class MaterialPageRoute<T> extends PageRoute<T> with MaterialRouteTransitionMixi
6363
/// A mixin that provides platform-adaptive transitions for a [PageRoute].
6464
///
6565
/// {@template flutter.material.materialRouteTransitionMixin}
66-
/// For Android, the entrance transition for the page zooms in and fades in
67-
/// while the exiting page zooms out and fades out. The exit transition is similar,
68-
/// but in reverse.
69-
///
70-
/// For iOS, the page slides in from the right and exits in reverse. The page
71-
/// also shifts to the left in parallax when another page enters to cover it.
72-
/// (These directions are flipped in environments with a right-to-left reading
73-
/// direction.)
66+
/// For Android, the entrance transition for the page slides the route upwards
67+
/// and fades it in. The exit transition is the same, but in reverse.
68+
///
69+
/// The transition is adaptive to the platform and on iOS, the route slides in
70+
/// from the right and exits in reverse. The route also shifts to the left in
71+
/// parallax when another page enters to cover it. (These directions are flipped
72+
/// in environments with a right-to-left reading direction.)
7473
/// {@endtemplate}
7574
///
7675
/// See also:
7776
///
7877
/// * [PageTransitionsTheme], which defines the default page transitions used
7978
/// by the [MaterialRouteTransitionMixin.buildTransitions].
80-
/// * [ZoomPageTransitionsBuilder], which is the default page transition used
81-
/// by the [PageTransitionsTheme].
82-
/// * [CupertinoPageTransitionsBuilder], which is the default page transition
83-
/// for iOS and macOS.
8479
mixin MaterialRouteTransitionMixin<T> on PageRoute<T> {
8580
/// Builds the primary contents of the route.
8681
@protected

packages/flutter/lib/src/material/page_transitions_theme.dart

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import 'colors.dart';
99
import 'theme.dart';
1010

1111
// Slides the page upwards and fades it in, starting from 1/4 screen
12-
// below the top. The transition is intended to match the default for
13-
// Android O.
12+
// below the top.
1413
class _FadeUpwardsPageTransition extends StatelessWidget {
1514
_FadeUpwardsPageTransition({
1615
Key? key,
@@ -147,7 +146,7 @@ class _OpenUpwardsPageTransition extends StatelessWidget {
147146
}
148147

149148
// Zooms and fades a new page in, zooming out the previous page. This transition
150-
// is designed to match the Android Q activity transition.
149+
// is designed to match the Android 10 activity transition.
151150
class _ZoomPageTransition extends StatelessWidget {
152151
/// Creates a [_ZoomPageTransition].
153152
///
@@ -292,16 +291,16 @@ class _ZoomEnterTransition extends StatelessWidget {
292291
@override
293292
Widget build(BuildContext context) {
294293
double opacity = 0;
295-
// The transition's scrim opacity only increases on the forward transition.
296-
// In the reverse transition, the opacity should always be 0.0.
294+
// The transition's scrim opacity only increases on the forward transition. In the reverse
295+
// transition, the opacity should always be 0.0.
297296
//
298-
// Therefore, we need to only apply the scrim opacity animation when
299-
// the transition is running forwards.
297+
// Therefore, we need to only apply the scrim opacity animation when the transition
298+
// is running forwards.
300299
//
301-
// The reason that we check that the animation's status is not `completed`
302-
// instead of checking that it is `forward` is that this allows
303-
// the interrupted reversal of the forward transition to smoothly fade
304-
// the scrim away. This prevents a disjointed removal of the scrim.
300+
// The reason that we check that the animation's status is not `completed` instead
301+
// of checking that it is `forward` is that this allows the interrupted reversal of the
302+
// forward transition to smoothly fade the scrim away. This prevents a disjointed
303+
// removal of the scrim.
305304
if (!reverse && animation.status != AnimationStatus.completed) {
306305
opacity = _scrimOpacityTween.evaluate(animation)!;
307306
}
@@ -318,14 +317,17 @@ class _ZoomEnterTransition extends StatelessWidget {
318317
return AnimatedBuilder(
319318
animation: animation,
320319
builder: (BuildContext context, Widget? child) {
321-
return ColoredBox(
320+
return Container(
322321
color: Colors.black.withOpacity(opacity),
323322
child: child,
324323
);
325324
},
326325
child: FadeTransition(
327326
opacity: fadeTransition,
328-
child: ScaleTransition(scale: scaleTransition, child: child),
327+
child: ScaleTransition(
328+
scale: scaleTransition,
329+
child: child,
330+
),
329331
),
330332
);
331333
}
@@ -372,7 +374,10 @@ class _ZoomExitTransition extends StatelessWidget {
372374

373375
return FadeTransition(
374376
opacity: fadeTransition,
375-
child: ScaleTransition(scale: scaleTransition, child: child),
377+
child: ScaleTransition(
378+
scale: scaleTransition,
379+
child: child,
380+
),
376381
);
377382
}
378383
}
@@ -386,12 +391,11 @@ class _ZoomExitTransition extends StatelessWidget {
386391
///
387392
/// See also:
388393
///
389-
/// * [FadeUpwardsPageTransitionsBuilder], which defines a page transition
390-
/// that's similar to the one provided by Android O.
394+
/// * [FadeUpwardsPageTransitionsBuilder], which defines a default page transition.
391395
/// * [OpenUpwardsPageTransitionsBuilder], which defines a page transition
392396
/// that's similar to the one provided by Android P.
393-
/// * [ZoomPageTransitionsBuilder], which defines the default page transition
394-
/// that's similar to the one provided in Android Q.
397+
/// * [ZoomPageTransitionsBuilder], which defines a page transition similar
398+
/// to the one provided in Android 10.
395399
/// * [CupertinoPageTransitionsBuilder], which defines a horizontal page
396400
/// transition that matches native iOS page transitions.
397401
abstract class PageTransitionsBuilder {
@@ -415,19 +419,18 @@ abstract class PageTransitionsBuilder {
415419
);
416420
}
417421

418-
/// Used by [PageTransitionsTheme] to define a vertically fading
419-
/// [MaterialPageRoute] page transition animation that looks like
420-
/// the default page transition used on Android O.
422+
/// Used by [PageTransitionsTheme] to define a default [MaterialPageRoute] page
423+
/// transition animation.
421424
///
422-
/// The animation fades the new page in while translating it upwards,
425+
/// The default animation fades the new page in while translating it upwards,
423426
/// starting from about 25% below the top of the screen.
424427
///
425428
/// See also:
426429
///
427430
/// * [OpenUpwardsPageTransitionsBuilder], which defines a page transition
428431
/// that's similar to the one provided by Android P.
429-
/// * [ZoomPageTransitionsBuilder], which defines the default page transition
430-
/// that's similar to the one provided in Android Q.
432+
/// * [ZoomPageTransitionsBuilder], which defines a page transition similar
433+
/// to the one provided in Android 10.
431434
/// * [CupertinoPageTransitionsBuilder], which defines a horizontal page
432435
/// transition that matches native iOS page transitions.
433436
class FadeUpwardsPageTransitionsBuilder extends PageTransitionsBuilder {
@@ -452,10 +455,9 @@ class FadeUpwardsPageTransitionsBuilder extends PageTransitionsBuilder {
452455
///
453456
/// See also:
454457
///
455-
/// * [FadeUpwardsPageTransitionsBuilder], which defines a page transition
456-
/// that's similar to the one provided by Android O.
457-
/// * [ZoomPageTransitionsBuilder], which defines the default page transition
458-
/// that's similar to the one provided in Android Q.
458+
/// * [FadeUpwardsPageTransitionsBuilder], which defines a default page transition.
459+
/// * [ZoomPageTransitionsBuilder], which defines a page transition similar
460+
/// to the one provided in Android 10.
459461
/// * [CupertinoPageTransitionsBuilder], which defines a horizontal page
460462
/// transition that matches native iOS page transitions.
461463
class OpenUpwardsPageTransitionsBuilder extends PageTransitionsBuilder {
@@ -481,19 +483,18 @@ class OpenUpwardsPageTransitionsBuilder extends PageTransitionsBuilder {
481483

482484
/// Used by [PageTransitionsTheme] to define a zooming [MaterialPageRoute] page
483485
/// transition animation that looks like the default page transition used on
484-
/// Android Q.
486+
/// Android 10.
485487
///
486488
/// See also:
487489
///
488-
/// * [FadeUpwardsPageTransitionsBuilder], which defines a page transition
489-
/// that's similar to the one provided by Android O.
490+
/// * [FadeUpwardsPageTransitionsBuilder], which defines a default page transition.
490491
/// * [OpenUpwardsPageTransitionsBuilder], which defines a page transition
491-
/// that's similar to the one provided by Android P.
492+
/// similar to the one provided by Android P.
492493
/// * [CupertinoPageTransitionsBuilder], which defines a horizontal page
493494
/// transition that matches native iOS page transitions.
494495
class ZoomPageTransitionsBuilder extends PageTransitionsBuilder {
495496
/// Constructs a page transition animation that matches the transition used on
496-
/// Android Q.
497+
/// Android 10.
497498
const ZoomPageTransitionsBuilder();
498499

499500
@override
@@ -517,12 +518,11 @@ class ZoomPageTransitionsBuilder extends PageTransitionsBuilder {
517518
///
518519
/// See also:
519520
///
520-
/// * [FadeUpwardsPageTransitionsBuilder], which defines a page transition
521-
/// that's similar to the one provided by Android O.
521+
/// * [FadeUpwardsPageTransitionsBuilder], which defines a default page transition.
522522
/// * [OpenUpwardsPageTransitionsBuilder], which defines a page transition
523523
/// that's similar to the one provided by Android P.
524-
/// * [ZoomPageTransitionsBuilder], which defines the default page transition
525-
/// that's similar to the one provided in Android Q.
524+
/// * [ZoomPageTransitionsBuilder], which defines a page transition similar
525+
/// to the one provided in Android 10.
526526
class CupertinoPageTransitionsBuilder extends PageTransitionsBuilder {
527527
/// Constructs a page transition animation that matches the iOS transition.
528528
const CupertinoPageTransitionsBuilder();
@@ -553,35 +553,34 @@ class CupertinoPageTransitionsBuilder extends PageTransitionsBuilder {
553553
///
554554
/// * [ThemeData.pageTransitionsTheme], which defines the default page
555555
/// transitions for the overall theme.
556-
/// * [FadeUpwardsPageTransitionsBuilder], which defines a page transition
557-
/// that's similar to the one provided by Android O.
556+
/// * [FadeUpwardsPageTransitionsBuilder], which defines a default page transition.
558557
/// * [OpenUpwardsPageTransitionsBuilder], which defines a page transition
559558
/// that's similar to the one provided by Android P.
560-
/// * [ZoomPageTransitionsBuilder], which defines the default page transition
561-
/// that's similar to the one provided by Android Q.
562559
/// * [CupertinoPageTransitionsBuilder], which defines a horizontal page
563560
/// transition that matches native iOS page transitions.
564561
@immutable
565562
class PageTransitionsTheme with Diagnosticable {
566563
/// Constructs an object that selects a transition based on the platform.
567564
///
568-
/// By default the list of builders is: [ZoomPageTransitionsBuilder]
565+
/// By default the list of builders is: [FadeUpwardsPageTransitionsBuilder]
569566
/// for [TargetPlatform.android], and [CupertinoPageTransitionsBuilder] for
570567
/// [TargetPlatform.iOS] and [TargetPlatform.macOS].
571568
const PageTransitionsTheme({ Map<TargetPlatform, PageTransitionsBuilder> builders = _defaultBuilders }) : _builders = builders;
572569

573570
static const Map<TargetPlatform, PageTransitionsBuilder> _defaultBuilders = <TargetPlatform, PageTransitionsBuilder>{
574-
TargetPlatform.android: ZoomPageTransitionsBuilder(),
571+
TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(),
575572
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
573+
TargetPlatform.linux: FadeUpwardsPageTransitionsBuilder(),
576574
TargetPlatform.macOS: CupertinoPageTransitionsBuilder(),
575+
TargetPlatform.windows: FadeUpwardsPageTransitionsBuilder(),
577576
};
578577

579578
/// The [PageTransitionsBuilder]s supported by this theme.
580579
Map<TargetPlatform, PageTransitionsBuilder> get builders => _builders;
581580
final Map<TargetPlatform, PageTransitionsBuilder> _builders;
582581

583582
/// Delegates to the builder for the current [ThemeData.platform]
584-
/// or [ZoomPageTransitionsBuilder].
583+
/// or [FadeUpwardsPageTransitionsBuilder].
585584
///
586585
/// [MaterialPageRoute.buildTransitions] delegates to this method.
587586
Widget buildTransitions<T>(
@@ -597,7 +596,7 @@ class PageTransitionsTheme with Diagnosticable {
597596
platform = TargetPlatform.iOS;
598597

599598
final PageTransitionsBuilder matchingBuilder =
600-
builders[platform] ?? const ZoomPageTransitionsBuilder();
599+
builders[platform] ?? const FadeUpwardsPageTransitionsBuilder();
601600
return matchingBuilder.buildTransitions<T>(route, context, animation, secondaryAnimation, child);
602601
}
603602

packages/flutter/test/material/bottom_navigation_bar_theme_test.dart

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -151,27 +151,13 @@ void main() {
151151
),
152152
);
153153

154-
final Finder findACTransform = find.descendant(
155-
of: find.byType(BottomNavigationBar),
156-
matching: find.ancestor(
157-
of: find.text('AC'),
158-
matching: find.byType(Transform),
159-
),
160-
);
161-
final Finder findAlarmTransform = find.descendant(
162-
of: find.byType(BottomNavigationBar),
163-
matching: find.ancestor(
164-
of: find.text('Alarm'),
165-
matching: find.byType(Transform),
166-
),
167-
);
168154
final TextStyle selectedFontStyle = tester.renderObject<RenderParagraph>(find.text('AC')).text.style!;
169155
final TextStyle selectedIcon = _iconStyle(tester, Icons.ac_unit);
170156
final TextStyle unselectedIcon = _iconStyle(tester, Icons.access_alarm);
171157
expect(selectedFontStyle.fontSize, selectedFontStyle.fontSize);
172158
// Unselected label has a font size of 22 but is scaled down to be font size 21.
173159
expect(
174-
tester.firstWidget<Transform>(findAlarmTransform).transform,
160+
tester.firstWidget<Transform>(find.ancestor(of: find.text('Alarm'), matching: find.byType(Transform))).transform,
175161
equals(Matrix4.diagonal3(Vector3.all(unselectedTextStyle.fontSize! / selectedTextStyle.fontSize!))),
176162
);
177163
expect(selectedIcon.color, equals(selectedItemColor));
@@ -193,8 +179,14 @@ void main() {
193179
expect(_material(tester).elevation, equals(elevation));
194180
expect(_material(tester).color, equals(backgroundColor));
195181

196-
final Offset selectedBarItem = tester.getCenter(findACTransform);
197-
final Offset unselectedBarItem = tester.getCenter(findAlarmTransform);
182+
final Offset selectedBarItem = tester.getCenter(
183+
find.ancestor(of: find.text('AC'),
184+
matching: find.byType(Transform))
185+
);
186+
final Offset unselectedBarItem = tester.getCenter(
187+
find.ancestor(of: find.text('Alarm'),
188+
matching: find.byType(Transform))
189+
);
198190
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
199191
await gesture.addPointer();
200192
addTearDown(gesture.removePointer);
@@ -278,27 +270,13 @@ void main() {
278270
),
279271
);
280272

281-
Finder findDescendantOfBottomNavigationBar(Finder finder) {
282-
return find.descendant(
283-
of: find.byType(BottomNavigationBar),
284-
matching: finder,
285-
);
286-
}
287-
288273
final TextStyle selectedFontStyle = tester.renderObject<RenderParagraph>(find.text('AC')).text.style!;
289274
final TextStyle selectedIcon = _iconStyle(tester, Icons.ac_unit);
290275
final TextStyle unselectedIcon = _iconStyle(tester, Icons.access_alarm);
291276
expect(selectedFontStyle.fontSize, selectedFontStyle.fontSize);
292277
// Unselected label has a font size of 22 but is scaled down to be font size 21.
293278
expect(
294-
tester.firstWidget<Transform>(
295-
findDescendantOfBottomNavigationBar(
296-
find.ancestor(
297-
of: find.text('Alarm'),
298-
matching: find.byType(Transform),
299-
),
300-
),
301-
).transform,
279+
tester.firstWidget<Transform>(find.ancestor(of: find.text('Alarm'), matching: find.byType(Transform))).transform,
302280
equals(Matrix4.diagonal3(Vector3.all(unselectedTextStyle.fontSize! / selectedTextStyle.fontSize!))),
303281
);
304282
expect(selectedIcon.color, equals(selectedItemColor));
@@ -307,24 +285,22 @@ void main() {
307285
expect(unselectedIcon.fontSize, equals(unselectedIconTheme.size));
308286
// There should not be any [Opacity] or [FadeTransition] widgets
309287
// since showUnselectedLabels and showSelectedLabels are true.
310-
final Finder findOpacity = findDescendantOfBottomNavigationBar(
311-
find.byType(Opacity),
288+
final Finder findOpacity = find.descendant(
289+
of: find.byType(BottomNavigationBar),
290+
matching: find.byType(Opacity),
312291
);
313-
final Finder findFadeTransition = findDescendantOfBottomNavigationBar(
314-
find.byType(FadeTransition),
292+
final Finder findFadeTransition = find.descendant(
293+
of: find.byType(BottomNavigationBar),
294+
matching: find.byType(FadeTransition),
315295
);
316296
expect(findOpacity, findsNothing);
317297
expect(findFadeTransition, findsNothing);
318298
expect(_material(tester).elevation, equals(elevation));
319299
expect(_material(tester).color, equals(backgroundColor));
320300

321301
final Offset barItem = tester.getCenter(
322-
findDescendantOfBottomNavigationBar(
323-
find.ancestor(
324-
of: find.text('AC'),
325-
matching: find.byType(Transform),
326-
),
327-
),
302+
find.ancestor(of: find.text('AC'),
303+
matching: find.byType(Transform))
328304
);
329305
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
330306
await gesture.addPointer();

0 commit comments

Comments
 (0)