Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Text scale Cupertino nav bar large title and search field #167313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

victorsanni
Copy link
Contributor

@victorsanni victorsanni commented Apr 16, 2025

Fixes Cupertino nav bars should respect accessibility text scaling
Fixes Title jumps during a CupertinoNavigationBar -> CupertinoNavigationBar hero transition

Before

Regular Scaled
Image Image

After

Regular Scaled
flutter nav bar unscaled flutter after 2 textscale

Native

Regular Scaled
Image Image

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: cupertino flutter/packages/flutter/cupertino repository labels Apr 16, 2025
@victorsanni
Copy link
Contributor Author

Related: #38593, #35199

final double largeHeight = persistentHeight + _kNavBarLargeTitleHeightExtension;
final double largeHeight =
persistentHeight +
MediaQuery.textScalerOf(context).scale(_kNavBarLargeTitleHeightExtension);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, we shouldn't scale the whole navbar up linearly according to the text scale factor, since that will also scale up the gap in space between the navbar large title and the backbutton/tool bar icons, which is unnecessary to grow as large.

If you look at your native example, the top of "Settings" in the scaled up app is above "Settings" in the non-scaled app. But in your Flutter app "Lists" drifts further downwards when scaled up. This is because the space above is growing too much. Which can be a pain point for accessibility because when all the text on the screen is scaled larger, empty space is at a premium, and too much of it can cause text to overflow.

Can we find a ratio to apply to the text scale factor, when it's above 1.0, to limit this growth?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title text between the large and middle version do look to me like they don't scale to the full amount, but they also aren't clamped. So they grow for the whole range but at a smaller degree.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might have to just clamp, it's not clear to me how to modify the scale factor directly with the TextScaler API and the textScaleFactor deprecation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can still get the textScaleFactor, you just have to do it in a roundabout way, and we do that in places in the code:

It's kinda tedious.

@victorsanni victorsanni marked this pull request as draft April 30, 2025 22:45
@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
2 participants