-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Bring TextTheme into alignment with the current Material spec #22330
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
Conversation
|
Please document the exceptions in the I understand that we can't do everything and don't want to break devs, but we need to document. Thanks! |
|
I don't think we should do this. I think we should push back on Material and ask them to keep using the old set, even if they change the style a bit when the developer wants Material 2.0 mode. It's going to be hugely confusing to have this many different text styles. |
|
@Hixie can you clarify "this" in your first sentence? Hans' work in general, this PR, the new typography categories, or the changed values? |
|
Just adding the 13 new TextStyles increases TextTheme's bulk from 11 to 24. If we don't adopt the new letter spacing values by default, then it would be possible to only increase the total to 17 by mapping old names to new ones when they're otherwise identical and leaving button and caption alone, since they're already the same modulo letter spacing: That leaves the old The old With all of those mappings in place we're at the minimum, in terms of the new typography spec, of 13 TextStyles. To enable one to create theme where the typography exactly matches the current Material spec, in terms of letterSpacing, font sizes ( |
|
@ajsecord I mean having a whole new set of names. @HansMuller that seems reasonable. We already allow ThemeData to take TextThemes, right? Can we provide named variants for the origanal set of styles and today's set of styles, rather than asking for a version number? Then you would just pass the TextTheme you want (or more likely, pass your own custom TextTheme). |
|
(I'm not sure what names we'd use, the two sets seem very similar and it's not clear what the purposes of each of the different styles are.) |
204cd59 to
69162b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we should go even further and just not have "headline1" in our API. We should IMHO just have a table in the class API docs that has the mapping from the names in the spec to the names in our API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(mostly i'm worried that this won't scale. Two years from now, if we have a third set of names, do we add those too? What if they overlap?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we'll ever be able to get rid of the old names although we can eliminate their use in the Flutter implementation. It seems reasonable, albeit painful, to sync up with the new names once. But never again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Matches my predilection for ^u^n in emacs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a breaking change (since they're expected to implement this, not call it)... but more importantly, i don't think this API change makes much sense. app devs aren't going to care what version it is, they're just going to provide their text theme for their localizations.
but I don't have a good alternative, assuming that we do still want to have different font sizes for each part of the text theme in different locales...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 3 script categories are defined here:
https://material.io/design/typography/language-support.html#language-categories-reference
The adjustments to dense and tall scripts are based on:
Type sizes smaller than title styles should make adjustments to the Latin type scale.
In our tall and dense themes the smaller than "title" font sizes have been increased by one.
For tall scripts:
Use regular weight, as medium weight is unavailable in Noto. Avoid using the bold weight, as bold is too heavy.
We replaced the medium weights in the tall theme: FontWeight.w500 with FontWeight.w400.
The dense text theme uses TextBaseline.ideographic instead of TextBaseline.alphabetic.
|
@Hixie it sounds like you're not on board with any of these changes? I might be reading your comments wrong...but comments in Hans' code isn't the right place to clarify, so I'll follow up offline. Tactically, these names changed ~5 months ago at Google I/O 2018 to better match actual usage in the wild. My ultimate preference would be to have the APIs match the spec so developers can move faster with less confusion. My suggestion, in decreasing order of desirability:
I believe Hans already implemented the second option in this PR, it's a reasonable compromise if changing the names is impossible. |
69162b9 to
e74a924
Compare
|
I think #1 is a non-starter, #2 would likely be really confusing (especially since the names overlap), and #3 is probably the easiest since I expect most Flutter developers will only use the Flutter API docs and not look at the Material documentation (so not need the mapping at all). There's also #4 which would be for the Material documentation to change the names to match the previous set of names so that there's no need for confusion. :-) Re the "version" thing in the API, @HansMuller and I chatted earlier and one option might be to pass through a BuildContext to the localization code so that it can look something up (not sure what exactly, but at least then it would have all the context it needs). The problem is that there's two inputs and both control things (locale and version, there's six possible sets of text styles just considering the defaults). |
cb78f4d to
0d4aea1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: urls can contain dots, and mean something different with them at the end than without.
a few workarounds:
three language categories defined in: https//example.comthree language categories defined in <https//example.com>.[three language categories](https//example.com).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I've fixed up the naked URLs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this means "the spec now calls body1 and body2 paragraph1 and paragraph2"?
Since those aren't the only names that changed, might be easier just to say "This API was first created with an earlier version of the material design specifications that used different names. For this reason, the names above are not used by this API. The names used in this API correspond to the names used above in the manner described in the table below." or some such.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's what I came up with:
/// The [TextTheme] API is based on the original material (2014)
/// design spec, which used different text style names. For backwards
/// compatability's sake, this API continues to use the original
/// names. The table below should help with understanding the API in
/// terms of the 2018 material spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have not changed from what? you never mention the earlier spec, just that the new spec "changed".
If you use the text I suggested above, you'll have to tweak this to read better too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I went with:
/// Each of the [TextTheme] text styles corresponds to one of the
/// styles from 2018 spec. By default, the font sizes, font weights
/// and letter spacings have not changed from their original,
/// 2014, values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indent is off (the display4 and display3 should line up)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented out code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that. Removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mountain View ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/correspond the current spec/correspond to the second iteration of the specification/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe have a constructor that does this automatically, like Typography.defaultsFor2018(platform)? (If you add this, also add ``Typography.defaultsFor2014`, for consistency.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
txt->text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please be explicit about the platforms rather than using default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provides, or should provide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point: should provide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for the assert false here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: switch isn't a method call, so there should be a space after the keyword
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @a14n if you would like an easy lint to add... if(, while(, for(, switch( -- none of these are method calls, so all should have a space between the keyword and the expression to distinguish them visually from method calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, we mostly use dynamic but a few use Object. We really should change them all to Object. Not in this PR, obviously...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for consistency the 2014 ones should say 2014 in their debugLabels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
9069887 to
9eb82e4
Compare
…flutter#22330)" This reverts commit 8bfb4b3.
For G3 Roll: * Revert "MaterialButton must honor its minWidth and height parameters (#22919)" This reverts commit a023323. * Revert "Update uses of ButtonTheme.bar: pass along the current Theme's colorScheme (#22827)" This reverts commit 655bf6a. * Revert "ButtonTheme.of().colorScheme defers to Theme (#22880)" This reverts commit a590940. * Revert "Bring TextTheme into alignment with the current Material spec (#22330)" This reverts commit 8bfb4b3. * Revert "Added ColorScheme, updated ThemeData, ButtonTheme, material buttons (#22013)" This reverts commit eea3465. * Manual adjustments to fix reversion issues.
TextTheme no longer matches https://material.io/design/typography/#type-scale
To sync things up, I've added
subtextandoverlineto TextTheme and documented the correspondence between the names in the new spec and the existing TextTheme style names.By default, the font sizes, font weights and letter spacing have not changed. To create a theme that uses the new sizes, weights, and spacing, configure a Theme with ThemeData.typography set to:
This PR includes incompatible changes: