Material Components v80.0.0 Release Notes
-
๐ This major release introduces Dynamic Type support for Typography Schemes as well as โ UIFontMetrics-like support for Dynamic Type for Material Typography. It also includes snapshot tests for additional components and less-restrictive badging for Tabs.
๐ฅ Breaking changes
MDCTypographyScheming
has a new non-optional API,mdc_adjustsFontForContentSizeCategory
that isYES
if the returned fonts should use the new Dynamic Type APIs available from Material Typography. Existing implementations may wish to migrate (at least initially) by returningNO
as a read-only ๐ value until support can be added.- (void)mdc_adjustsFontForContentSizeCategory { return NO; }
public var mdc_adjustsFontForContentSizeCategory: Bool { return false; }
๐ New features
๐ Improved Dynamic Type Support
โก๏ธ The Typography and TypographyScheme components have been updated for improved Dynamic Type support. ๐ Most clients will make use of this support through MDCTypographyScheme, though it is possible to create scalable fonts manually via MDCFontScaler within Typography. The new scaling curves have โก๏ธ been updated for last year's refresh of Material Design typography and font values.
Objective-C
// Typography Scheme is the most typical way to receive scalable fonts. MDCTypographyScheme *typographyScheme = [[MDCTypographyScheme alloc] initWithDefaults:MDCTypographySchemeDefaultsMaterial201902]; UIFont *scaledBody1Font = [typographyScheme.body1 mdc_scaledFontForCurrentSizeCategory]; // If Typography Schemes aren't used, it's possible to create the fonts manually. // Initial set-up to apply scaling curves to a base UIFont. UIFont *baseFont = [UIFont systemFontOfSize:18.0]; MDCFontScaler *body2Scaler = [[MDCFontScaler alloc] initForMaterialTextStyle:MDCTextStyleBody2]; UIFont *scalableFont = [body2Scaler scaledFontWithFont:baseFont]; // Now UIFonts appropriate for Dynamic Type size categories can be created anywhere. UIFont *baseFontScaledToDefault = [scalableFont mdc_scaledFontAtDefaultSize]; UIFont *baseFontScaledForExtraLarge = [scalableFont mdc_scaledFontForSizeCategory:UIContentSizeCategoryExtraLarge]; UIFont *baseFontScaledForCurrentSizeCategory = [scalableFont mdc_scaledFontForCurrentSizeCategory];
Swift
// Typography Scheme is the most typical way to receive scalable fonts. let typographyScheme = MDCTypographyScheme(defaults: .material201902) let scaledBody1Font = typographyScheme.body1.mdc_scaledFontForCurrentSizeCategory() // If Typography Schemes aren't used, it's possible to create the fonts manually. // Initial set-up to apply scaling curves to a base UIFont. let baseFont = UIFont.systemFont(ofSize: 18) let body2Scaler = MDCFontScaler(forMaterialTextStyle: .body2) let scalableFont = body2Scaler.scaledFont(with: baseFont) // Now UIFonts appropriate for Dynamic Type size categories can be created anywhere. let baseFontScaledToDefault = scalableFont.mdc_scaledFontAtDefaultSize() let baseFontScaledForExtraLarge = scalableFont.mdc_scaledFont(forSizeCategory: .extraLarge) let baseFontScaledForCurrentSizeCategory = scalableFont.mdc_scaledFontForCurrentSizeCategory()
API changes
Typography
๐ MDCTextStyleButton
๐ new constant:
MDCTextStyleButton
๐ MDCTextStyleCaption
๐ new constant:
MDCTextStyleCaption
๐ MDCTextStyleSubtitle2
๐ new constant:
MDCTextStyleSubtitle2
๐ MDCTextStyleSubtitle1
๐ new constant:
MDCTextStyleSubtitle1
๐ MDCTextStyleBody1
๐ new constant:
MDCTextStyleBody1
UIFont(MaterialScalable)
๐ new method:
-mdc_scaledFontForCurrentSizeCategory
inUIFont(MaterialScalable)
๐ new method:
-mdc_scaledFontAtDefaultSize
inUIFont(MaterialScalable)
๐ new method:
-mdc_scaledFontForSizeCategory:
inUIFont(MaterialScalable)
๐ new category:
UIFont(MaterialScalable)
๐ new property:
mdc_scalingCurve
inUIFont(MaterialScalable)
MDCFontScaler
๐ new class method:
+scalerForMaterialTextStyle:
inMDCFontScaler
๐ new method:
-scaledValueForValue:
inMDCFontScaler
๐ new class:
MDCFontScaler
๐ new method:
-init
inMDCFontScaler
๐ new method:
-initForMaterialTextStyle:
inMDCFontScaler
๐ new method:
-scaledFontWithFont:
inMDCFontScaler
๐ MDCTextStyleHeadline4
๐ new constant:
MDCTextStyleHeadline4
๐ MDCTextStyleHeadline3
๐ new constant:
MDCTextStyleHeadline3
๐ MDCTextStyleHeadline2
๐ new constant:
MDCTextStyleHeadline2
๐ MDCTextStyleHeadline6
๐ new constant:
MDCTextStyleHeadline6
๐ MDCTextStyleBody2
๐ new constant:
MDCTextStyleBody2
๐ MDCTextStyle
๐ new typedef:
MDCTextStyle
๐ MDCTextStyleOverline
๐ new constant:
MDCTextStyleOverline
๐ MDCTextStyleHeadline1
๐ new constant:
MDCTextStyleHeadline1
๐ MDCTextStyleHeadline5
๐ new constant:
MDCTextStyleHeadline5
TypographyScheme
0๏ธโฃ MDCTypographySchemeDefaults
๐ new enum value:
MDCTypographySchemeDefaultsMaterial201902
inMDCTypographySchemeDefaults
MDCTypographyScheme
๐ new property:
mdc_adjustsFontForContentSizeCategory
inMDCTypographyScheme
MDCTypographyScheming
๐ new property:
mdc_adjustsFontForContentSizeCategory
inMDCTypographyScheming
Component changes
๐ Changes
ActivityIndicator
- โ Deflake snapshot tests. (#6934) (Robert Moore)
AppBar
- Fix README code snippet (#6969) (Robert Moore)
- ๐จ Refactor AppBar example table views (#6974) (Brian Moore)
Buttons
- Fix
accessibilityTraits
in init. (#6948) (Robert Moore)
HeaderStackView
- โ Add basic Snapshot tests. (#6923) (Robert Moore)
Ripple
- ๐ Remove manipulation of clipping for the ripple's superview (#6977) (Yarden Eitan)
ShapeLibrary
- โ Add basic Snapshot tests. (#6918) (Robert Moore)
Shapes
- โ Add basic Snapshot tests. (#6919) (Robert Moore)
Tabs
- Do not truncate badge text on MDCItemBarCell (#6916) (Andrew Overton)
Typography
- Add Font Scaler (#6871) (ianegordon)
schemes/Typography