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

Commit 3c769ef

Browse files
Cupertino navbar ellipsis fix (#118841)
* Passdown context * make transitions ignore preffered text size * Add test * Add comment * Return const constructor
1 parent a07e8a6 commit 3c769ef

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

packages/flutter/lib/src/cupertino/nav_bar.dart

+10-6
Original file line numberDiff line numberDiff line change
@@ -1770,12 +1770,16 @@ class _NavigationBarTransition extends StatelessWidget {
17701770
// The actual outer box is big enough to contain both the bottom and top
17711771
// navigation bars. It's not a direct Rect lerp because some components
17721772
// can actually be outside the linearly lerp'ed Rect in the middle of
1773-
// the animation, such as the topLargeTitle.
1774-
return SizedBox(
1775-
height: math.max(heightTween.begin!, heightTween.end!) + MediaQuery.paddingOf(context).top,
1776-
width: double.infinity,
1777-
child: Stack(
1778-
children: children,
1773+
// the animation, such as the topLargeTitle. The textScaleFactor is kept
1774+
// at 1 to avoid odd transitions between pages.
1775+
return MediaQuery(
1776+
data: MediaQuery.of(context).copyWith(textScaleFactor: 1),
1777+
child: SizedBox(
1778+
height: math.max(heightTween.begin!, heightTween.end!) + MediaQuery.paddingOf(context).top,
1779+
width: double.infinity,
1780+
child: Stack(
1781+
children: children,
1782+
),
17791783
),
17801784
);
17811785
}

packages/flutter/test/cupertino/nav_bar_transition_test.dart

+15-3
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@ Future<void> startTransitionBetween(
2525
String? toTitle,
2626
TextDirection textDirection = TextDirection.ltr,
2727
CupertinoThemeData? theme,
28+
double textScale = 1.0,
2829
}) async {
2930
await tester.pumpWidget(
3031
CupertinoApp(
3132
theme: theme,
3233
builder: (BuildContext context, Widget? navigator) {
33-
return Directionality(
34-
textDirection: textDirection,
35-
child: navigator!,
34+
return MediaQuery(
35+
data: MediaQuery.of(context).copyWith(textScaleFactor: textScale),
36+
child: Directionality(
37+
textDirection: textDirection,
38+
child: navigator!,
39+
)
3640
);
3741
},
3842
home: const Placeholder(),
@@ -1225,6 +1229,14 @@ void main() {
12251229
expect(find.text('Page 1'), findsOneWidget);
12261230
});
12271231

1232+
testWidgets('textScaleFactor is set to 1.0 on transition', (WidgetTester tester) async {
1233+
await startTransitionBetween(tester, fromTitle: 'Page 1', textScale: 99);
1234+
1235+
await tester.pump(const Duration(milliseconds: 50));
1236+
1237+
expect(tester.firstWidget<RichText>(flying(tester, find.byType(RichText))).textScaleFactor, 1);
1238+
});
1239+
12281240
testWidgets('Back swipe gesture cancels properly with transition', (WidgetTester tester) async {
12291241
await startTransitionBetween(
12301242
tester,

0 commit comments

Comments
 (0)