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

Skip to content

Fix body1/body2 for 2018 Material Design (#38904). #47918

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

Closed
wants to merge 1 commit into from

Conversation

saurik
Copy link
Contributor

@saurik saurik commented Dec 28, 2019

Description

In 2018, Material Design did a major update to its typography, renaming all of its styles as well as changing all of their default sizes and weights. One notable aspect of this change is that what used to be body1 is best mapped to what is now body2. While Flutter has decided to enshrine for all eternity the old naming scheme, it has provided new TextTheme variants for the 2018 styles. These were, correctly, documented to swap body1 and body2 (which is the same behavior that was used for React Native). However, while as far as I can tell (based on relative sizing), this was done correctly for the "dense" and "tall" variants, the swap was not done for the englishLike variant. Without this swap, the 2018 typography is incompatible with all of the existing code that is using body1 as the default size.

Of course, fixing this will, I would expect, break people who have added one-off adjustments to their font sizes in an attempt to work around this bug, but 1) it was documented correctly (so I would hope that if anything this helps people and fixes things that were slightly broken before), 2) the englishLike variant is the only one that is broken (so workarounds are going to either be crazy or incomplete), 3) workarounds likely would have just further broken existing code (as the existing code would be assuming body1 is the default), and 4) because Flutter has decided to maintain the 2014 styles as the default--despite now being almost two years out of date--it is unlikely that many people even ever discovered that to get the correct/modern sizes they would need to switch to this broken TypeTheme anyway: so, really, anything that would make this path more usable seems like a positive thing to get done ASAP.

Related Issues

Months ago, someone reported this issue as #38904.

Tests

Any test for this would just be a second copy of the same table verifying the data from the first copy, which would be pointless. FWIW, I did run the existing test suites in packages/flutter and examples/flutter_gallery and none of them noticed.

Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

  • No, no existing tests failed, so this is "not a breaking change".

@fluttergithubbot
Copy link
Contributor

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie.

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

@fluttergithubbot fluttergithubbot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Dec 28, 2019
@Zazo032
Copy link
Contributor

Zazo032 commented Dec 28, 2019

Even though no tests failed, this is probably a breaking change as existing apps will look a bit different after this is merged

@saurik
Copy link
Contributor Author

saurik commented Dec 29, 2019

@Zazo032 Hence the quotation marks I added around "not a breaking a change" from the template (which seemed to consider that statement to be an implication) ;P. The issue is that this is a bug which makes this mechanism useless, and as I mentioned it seems like no one is really trying to use it (as it is not obvious that you need to do this... using the 2018 sizes should probably be part of the new project template to ensure anyone actually notices it has to be done)... if nothing else so few people have noticed this bug. Leaving this broken just makes this entire thing even less usable.

@HansMuller
Copy link
Contributor

We're planning to update the TextTheme's text style names per the current Material spec: #45745.

I'm going to close this PR, as the project is already being actively worked on. Thanks for you contribution and for the passionate write-up!

@HansMuller HansMuller closed this Jan 3, 2020
@saurik
Copy link
Contributor Author

saurik commented Jan 5, 2020

@HansMuller I just reviewed the patch and discussion in #45745, and I am concerned that the names are being fixed but the table is not; like; if you want to correctly get Material 2018 using @Hixie's patch (which does correctly flip the names) you also separately need to commit my patch (to make the table put the correct font sizes to the correct entries). Are you sure this isn't going to be forgotten when the table's names are updated?

@Hixie
Copy link
Contributor

Hixie commented Jan 6, 2020

@saurik is right, the numbers in this table are wrong irrespective of #45745.

@Hixie Hixie reopened this Jan 6, 2020
@Hixie
Copy link
Contributor

Hixie commented Jan 6, 2020

We should add a test before landing this, though.

@HansMuller
Copy link
Contributor

@saurik per #47918 (comment)
I'll attempt to update the font size and letter spacing for bodyText1 and bodyText2 (aka body1 and body2) per this PR and #38904, after #48547 lands.

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

It looks like we may have overlapping work here with #51513, @HansMuller was this also a potential breaking change?

@HansMuller
Copy link
Contributor

We haven't pursued this change yet because it will break existing layouts and golden image tests.

@Piinks Piinks added c: API break Backwards-incompatible API changes will affect goldens Changes to golden files labels Feb 27, 2020
@HansMuller
Copy link
Contributor

I'm going to close this in favor of #49756 - which makes the very same change. To my surprise, these changes did not break existing tests (at least not as far as I've been able to tell). I will try and land them now.

@HansMuller HansMuller closed this Mar 6, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: API break Backwards-incompatible API changes f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. will affect goldens Changes to golden files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants