Skip to content

Conversation

@rami-a
Copy link
Contributor

@rami-a rami-a commented Nov 16, 2021

Summary

This change adds the Material 3 text style names to the TextTheme API. It includes renames of all 2018 text styles and the introduction of 2 more styles for a total of 15. The 2018 names will be deprecated later on, once Material 3 is fully implemented.

Part of #89853 (fixes #89853)

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.

@flutter-dashboard flutter-dashboard bot added a: text input Entering text in a text field or keyboard related problems f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Nov 16, 2021
@google-cla google-cla bot added the cla: yes label Nov 16, 2021
@bernaferrari
Copy link
Contributor

Since you are refactoring everything, can you also make them non-nullable? This would be a breaking change I guess, but people are postponing this for a while.

@rami-a rami-a changed the title [WIP][Material 3] Update TextTheme to have M3 names for styles [Material 3] Update TextTheme to have M3 names for styles Nov 22, 2021
@rami-a rami-a marked this pull request as ready for review November 22, 2021 19:03
Copy link
Member

@guidezpl guidezpl left a comment

Choose a reason for hiding this comment

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

  _    ___ _____ __  __ 
 | |  / __|_   _|  \/  |
 | |_| (_ | | | | |\/| |
 |____\___| |_| |_|  |_|
                        

@rami-a
Copy link
Contributor Author

rami-a commented Nov 23, 2021

Since you are refactoring everything, can you also make them non-nullable? This would be a breaking change I guess, but people are postponing this for a while.

Although I'd like to do this, that would be a pretty large breaking change for everyone, so we'll have to defer that for now.

@bernaferrari
Copy link
Contributor

bernaferrari commented Nov 23, 2021

pretty large breaking change for everyone

Technically it wouldn't be a breaking change because AFAIK text just can't be null. It is never null. It was made nullable kind of temporarily until 2014 styles were removed (which already were), and then no one made them non-nullable. But there is nothing they would break, they would just throw warnings everywhere because ! wouldn't be necessary anymore.

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

This looks good modulo the font-size changes that maybe I'm mistaken about?

Although this change is non-breaking, we will need a migration guide that explains what's changing and the rationale for what's changing.

labelLarge = labelLarge ?? button,
labelSmall = labelSmall ?? overline;

/// Large size of the display styles.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we really helping anyone with comments like this? There must be a reason for calling some of the fonts "display". Presumably it has something to do with using them for short standalone text that's not a title (whatever that is). As far as the "large" qualifier goes, it would be worth characterizing this TextStyle as the largest.

Here and below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm yeah its tricky to describe these styles, I copied the descriptions from https://m3.material.io/styles/typography/applying-scaling-type for each category (and put it in the 2nd sentence of each comment) and then I updated to use largest, smallest, etc. Let me know what you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

The descriptions look good.

TextStyle? overline,
}) {
assert(
(displayLarge == null && displayMedium == null && displaySmall == null && headlineMedium == null &&
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize that there's no nice and compact way to format this, but: two-space indent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

displayLarge : TextStyle(debugLabel: 'englishLike displayLarge 2014', inherit: false, fontSize: 112.0, fontWeight: FontWeight.w100, textBaseline: TextBaseline.alphabetic),
displayMedium : TextStyle(debugLabel: 'englishLike displayMedium 2014', inherit: false, fontSize: 56.0, fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
displaySmall : TextStyle(debugLabel: 'englishLike displaySmall 2014', inherit: false, fontSize: 45.0, fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
headlineLarge : TextStyle(debugLabel: 'englishLike headlineLarge 2014', inherit: false, fontSize: 40.0, fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this supposed to be backwards compatible with headline4? The font sizes do not match. Likewise for some of the following text styles

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually headline4 maps to headlineMedium, headlineLarge is a new style with no mapping to an old one (so is labelMedium). The diff is tricky to follow since I had to reorganize some lines to be more readable.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK. The migration guide should make the mapping from old names to new ones clear.

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

LGTM

@fluttergithubbot fluttergithubbot merged commit 1aabe31 into flutter:master Dec 6, 2021
@rami-a rami-a deleted the material3-text-theme branch December 6, 2021 17:17
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 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.

☂️ Update TextTheme to use new Material 3 text styles

5 participants