Skip to content

Conversation

@LongCatIsLooong
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong commented Jan 18, 2024

Remove more textScaleFactor references from flutter/flutter.

  • Some changes are related to label scaling: the padding EdgeInsets values of some chip subclasses scale linearly between predetermined "max" padding values and "min" padding values. Before they scale with the textScaleFactor scalar, now they scale with the font size and are still capped at the original "max" and "min" values.
  • The rest of them are tests or size heuristics that depend on textScaleFactor, these are replaced by an effective text scale factor computed using a default font size (which is determined in a pretty random fashion, but it will only make a difference on Android 14+).

No API changes in this batch. There are still some references left that I intend to remove in a different batch that would introduce API changes.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

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

@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. f: cupertino flutter/packages/flutter/cupertino repository labels Jan 18, 2024
@LongCatIsLooong LongCatIsLooong marked this pull request as ready for review January 19, 2024 18:30
Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

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

I'm starting to wonder if there shouldn't be a getter for effective scale on TextScaler.

Something like below to avoid bugs like I commented on:

double getEffectiveScale(double fontSize) => scale(fontSize)/fontSize;

)!;
EdgeInsetsGeometry? get labelPadding {
final double defaultFontSize = labelStyle?.fontSize ?? 14.0;
final double effectiveTextScale = MediaQuery.textScalerOf(context).scale(defaultFontSize) / 14.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't that be divided by the defaultFontSize?

Copy link
Contributor Author

@LongCatIsLooong LongCatIsLooong Jan 19, 2024

Choose a reason for hiding this comment

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

Ah I think in this case I meant to scale the padding with the actual font size, since the threshold padding values seem to be empirical values that work well with the default font size, so making the font size larger should scale the padding the same way as increasing the text scale. I'll add comments in the code and update the PR description.

)!;
EdgeInsetsGeometry? get labelPadding {
final double defaultFontSize = labelStyle?.fontSize ?? 14.0;
final double effectiveTextScale = MediaQuery.textScalerOf(context).scale(defaultFontSize) / 14.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't that be divided by the defaultFontSize?

)!;
EdgeInsetsGeometry? get labelPadding {
final double defaultFontSize = labelStyle?.fontSize ?? 14.0;
final double effectiveTextScale = MediaQuery.textScalerOf(context).scale(defaultFontSize) / 14.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't that be divided by the defaultFontSize?

)!;
EdgeInsetsGeometry? get labelPadding {
final double defaultFontSize = labelStyle?.fontSize ?? 14.0;
final double effectiveTextScale = MediaQuery.textScalerOf(context).scale(defaultFontSize) / 14.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't that be divided by the defaultFontSize?

visualDensity = VisualDensity(vertical: visualDensity.vertical);
}
final double defaultFontSize = Theme.of(context).textTheme.labelLarge?.fontSize ?? 14.0;
final double effectiveTextScale = MediaQuery.textScalerOf(context).scale(defaultFontSize) / 14.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't that be divided by the defaultFontSize?

Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

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

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

@LongCatIsLooong LongCatIsLooong added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 20, 2024
@auto-submit auto-submit bot merged commit 5892a00 into flutter:master Jan 20, 2024
@LongCatIsLooong LongCatIsLooong deleted the remove-text-scale-factor-ref branch January 20, 2024 00:29
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 20, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jan 20, 2024
flutter/flutter@684247a...ddf60fb

2024-01-20 [email protected] Roll Flutter Engine from 1385f76018ab to 704ef3399012 (1 revision) (flutter/flutter#141932)
2024-01-20 [email protected] Roll Flutter Engine from 6f6649bdfef2 to 1385f76018ab (1 revision) (flutter/flutter#141926)
2024-01-20 [email protected] Roll Flutter Engine from 4d67f267b115 to 6f6649bdfef2 (1 revision) (flutter/flutter#141920)
2024-01-20 [email protected] Roll Flutter Engine from 53a2436cf75c to 4d67f267b115 (1 revision) (flutter/flutter#141917)
2024-01-20 [email protected] Roll Flutter Engine from a9b87c6288d2 to 53a2436cf75c (1 revision) (flutter/flutter#141916)
2024-01-20 [email protected] Roll Flutter Engine from d00e55f7f8ed to a9b87c6288d2 (3 revisions) (flutter/flutter#141914)
2024-01-20 [email protected] Remove more textScaleFactor references (flutter/flutter#141816)
2024-01-19 [email protected] Roll Flutter Engine from 517fc2bbfa51 to d00e55f7f8ed (1 revision) (flutter/flutter#141909)
2024-01-19 [email protected] Roll Flutter Engine from f2b441a26416 to 517fc2bbfa51 (2 revisions) (flutter/flutter#141904)
2024-01-19 [email protected] Fix "Delete" tooltip is shown disabled on chips with `onDeleted` callback (flutter/flutter#141770)
2024-01-19 [email protected] Run module_test_ios on arm and x64 (flutter/flutter#141815)
2024-01-19 [email protected] `SearchAnchor` search view clear button only shows up when text input is not empty (flutter/flutter#141755)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems autosubmit Merge PR when tree becomes green via auto submit App f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants