-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Migrate TextTheme to 2018 APIs #48547
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
Migrate TextTheme to 2018 APIs #48547
Conversation
59d3fa0
to
abca319
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.
__ ___ ____ __ __
( ) / __)(_ _)( \/ )
)(__( (_-. )( ) (
(____)\___/ (__) (_/\/\_)
This is awesome!
TextStyleItem(name: 'Subheading', style: textTheme.subhead, text: 'Regular 16sp'), | ||
TextStyleItem(name: 'Body 2', style: textTheme.body2, text: 'Medium 14sp'), | ||
TextStyleItem(name: 'Body 1', style: textTheme.body1, text: 'Regular 14sp'), | ||
TextStyleItem(name: 'Headline 1', style: textTheme.headline1, text: 'Light 112sp'), |
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.
Should the typography demo use the 2018 values for font weight and size instead now?
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.
That's a good idea although an update to the typography demo would be probably be best as separate PR
@@ -256,7 +320,7 @@ class Typography extends Diagnosticable { | |||
@override | |||
void debugFillProperties(DiagnosticPropertiesBuilder properties) { | |||
super.debugFillProperties(properties); | |||
final Typography defaultTypography = Typography(); | |||
final Typography defaultTypography = Typography.material2018(); |
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.
Does making the default 2018 here change anything?
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 catch! Currently the default value for is the 2014 text theme.
f2e7f25
to
677d3d0
Compare
TextStyleItem(name: 'Headline 4', style: textTheme.headline4, text: 'Regular 34sp'), | ||
TextStyleItem(name: 'Headline 5', style: textTheme.headline5, text: 'Regular 24sp'), | ||
TextStyleItem(name: 'Headline 6', style: textTheme.headline6, text: 'Medium 20sp'), | ||
TextStyleItem(name: 'Subtitle 1', style: textTheme.subtitle1, text: 'Regular 16sp'), |
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.
Is Subtitle 2
missing here? I don't know if it is necessary, I noticed overline
is also omitted.
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, both of those styles are missing. This is just a simple translation of the existing demo - only the names have changed - I'm going to update to the demo to show the complete set of 2018 text styles in a separate PR.
body1, | ||
body2, |
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.
Would this be bodyText1 and bodyText2?
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!
properties.add(DiagnosticsProperty<TextStyle>('body1', body1, defaultValue: defaultTheme.body1)); | ||
properties.add(DiagnosticsProperty<TextStyle>('body2', body2, defaultValue: defaultTheme.body2)); |
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.
Same comment here for bodyText1 and bodyText2
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!
subtitle1 : TextStyle(debugLabel: 'blackMountainView subtitle1', fontFamily: 'Roboto', inherit: true, color: Colors.black87, decoration: TextDecoration.none), | ||
bodyText1 : TextStyle(debugLabel: 'blackMountainView bodyText1', fontFamily: 'Roboto', inherit: true, color: Colors.black87, decoration: TextDecoration.none), | ||
bodyText2 : TextStyle(debugLabel: 'blackMountainView bodyText2', fontFamily: 'Roboto', inherit: true, color: Colors.black87, decoration: TextDecoration.none), | ||
caption : TextStyle(debugLabel: 'blackMountainView caption', fontFamily: 'Roboto', inherit: true, color: Colors.black54, decoration: TextDecoration.none), |
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.
caption : TextStyle(debugLabel: 'blackMountainView caption', fontFamily: 'Roboto', inherit: true, color: Colors.black54, decoration: TextDecoration.none), | |
caption: TextStyle(debugLabel: 'blackMountainView caption', fontFamily: 'Roboto', inherit: true, color: Colors.black54, decoration: TextDecoration.none), |
Nit: It looks like there is some extra white space on this and a several of the following lines, is this intentional?
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.
Not intentional, thanks for pointing that out.
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.
bodyText2 : TextStyle(debugLabel: 'dense body1 2014', inherit: false, fontSize: 15.0, fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), | ||
caption : TextStyle(debugLabel: 'dense caption 2014', inherit: false, fontSize: 13.0, fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), | ||
button : TextStyle(debugLabel: 'dense button 2014', inherit: false, fontSize: 15.0, fontWeight: FontWeight.w500, textBaseline: TextBaseline.ideographic), | ||
subtitle2 : TextStyle(debugLabel: 'dense subtitle 2014', inherit: false, fontSize: 15.0, fontWeight: FontWeight.w500, textBaseline: TextBaseline.ideographic), |
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.
Uber nit: I noticed on some of these subtitle2
was moved up below subtitle1
and on others not.
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 reordered the typography styles; now they match.
textTheme.headline6, | ||
textTheme.subtitle1, | ||
textTheme.bodyText1, | ||
textTheme.bodyText2, |
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.
Is subtitle(14)/subtitle2(18) missing 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.
This test just checks the original 2014 text styles (still the default). It's now a regression test. Will add a comment to that effect.
677d3d0
to
cb9eb51
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.
subtitle1 : TextStyle(debugLabel: 'blackMountainView subtitle1', fontFamily: 'Roboto', inherit: true, color: Colors.black87, decoration: TextDecoration.none), | ||
bodyText1 : TextStyle(debugLabel: 'blackMountainView bodyText1', fontFamily: 'Roboto', inherit: true, color: Colors.black87, decoration: TextDecoration.none), | ||
bodyText2 : TextStyle(debugLabel: 'blackMountainView bodyText2', fontFamily: 'Roboto', inherit: true, color: Colors.black87, decoration: TextDecoration.none), | ||
caption : TextStyle(debugLabel: 'blackMountainView caption', fontFamily: 'Roboto', inherit: true, color: Colors.black54, decoration: TextDecoration.none), |
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.
TextStyle body2, | ||
@Deprecated( | ||
'This is the term used in the 2014 version of material design. The modern term is bodyText2. ' |
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 "bodyText2" here should be "bodyText1" and vice versa.
This PR is a breaking change. It's described in additional detail here: flutter.dev/go/update-text-theme-api. It's based on an earlier version - #45745.
The TextTheme's styles now have names that match the 2018 Material Design spec. Getters and parameters with the original names are still supported, but they are deprecated.
The text styles called "bodyText1" and "bodyText2" are called body1 and body2 in the spec, H1-H6 are called headline1-headline6 in the TextTheme API:
Note that this PR only changes the names of the TextTheme TextStyles, it does not change the default text style configurations. By default, the text style configurations (the font size, font weight, letter spacing, etc), still match their original 2014 values. Apps can choose to use the 2018 text style configurations instead, by specifying Typography.material2018() as the value for their Theme's typography.