Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Cupertino navbar ellipsis fix (#118841)
Browse files Browse the repository at this point in the history
* Passdown context

* make transitions ignore preffered text size

* Add test

* Add comment

* Return const constructor
  • Loading branch information
MitchellGoodwin committed Jan 20, 2023
1 parent a07e8a6 commit 3c769ef
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
16 changes: 10 additions & 6 deletions packages/flutter/lib/src/cupertino/nav_bar.dart
Expand Up @@ -1770,12 +1770,16 @@ class _NavigationBarTransition extends StatelessWidget {
// The actual outer box is big enough to contain both the bottom and top
// navigation bars. It's not a direct Rect lerp because some components
// can actually be outside the linearly lerp'ed Rect in the middle of
// the animation, such as the topLargeTitle.
return SizedBox(
height: math.max(heightTween.begin!, heightTween.end!) + MediaQuery.paddingOf(context).top,
width: double.infinity,
child: Stack(
children: children,
// the animation, such as the topLargeTitle. The textScaleFactor is kept
// at 1 to avoid odd transitions between pages.
return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 1),
child: SizedBox(
height: math.max(heightTween.begin!, heightTween.end!) + MediaQuery.paddingOf(context).top,
width: double.infinity,
child: Stack(
children: children,
),
),
);
}
Expand Down
18 changes: 15 additions & 3 deletions packages/flutter/test/cupertino/nav_bar_transition_test.dart
Expand Up @@ -25,14 +25,18 @@ Future<void> startTransitionBetween(
String? toTitle,
TextDirection textDirection = TextDirection.ltr,
CupertinoThemeData? theme,
double textScale = 1.0,
}) async {
await tester.pumpWidget(
CupertinoApp(
theme: theme,
builder: (BuildContext context, Widget? navigator) {
return Directionality(
textDirection: textDirection,
child: navigator!,
return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: textScale),
child: Directionality(
textDirection: textDirection,
child: navigator!,
)
);
},
home: const Placeholder(),
Expand Down Expand Up @@ -1225,6 +1229,14 @@ void main() {
expect(find.text('Page 1'), findsOneWidget);
});

testWidgets('textScaleFactor is set to 1.0 on transition', (WidgetTester tester) async {
await startTransitionBetween(tester, fromTitle: 'Page 1', textScale: 99);

await tester.pump(const Duration(milliseconds: 50));

expect(tester.firstWidget<RichText>(flying(tester, find.byType(RichText))).textScaleFactor, 1);
});

testWidgets('Back swipe gesture cancels properly with transition', (WidgetTester tester) async {
await startTransitionBetween(
tester,
Expand Down

0 comments on commit 3c769ef

Please sign in to comment.