Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 360230236
  • Loading branch information
jverkoey authored and material-automation committed Mar 1, 2021
1 parent 9926ef2 commit b64b0ec
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 70 deletions.
Expand Up @@ -65,10 +65,7 @@ - (void)viewDidLoad {
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.featureHighlightView.mdc_adjustsFontForContentSizeCategory =
_mdc_adjustsFontForContentSizeCategory;
if (@available(iOS 10.0, *)) {
self.featureHighlightView.adjustsFontForContentSizeCategory =
_adjustsFontForContentSizeCategory;
}
self.featureHighlightView.adjustsFontForContentSizeCategory = _adjustsFontForContentSizeCategory;
self.featureHighlightView.mdc_legacyFontScaling = _mdc_legacyFontScaling;

__weak MDCFeatureHighlightViewController *weakSelf = self;
Expand Down
Expand Up @@ -21,8 +21,6 @@
static NSString *const kExampleDetailText =
@"Pellentesque non quam ornare, porta urna sed, malesuada felis. Praesent at gravida felis, "
"non facilisis enim. Proin dapibus laoreet lorem, in viverra leo dapibus a.";
static const CGFloat kSmallestCellHeight = 40;
static const CGFloat kSmallArbitraryCellWidth = 100;

@implementation CollectionListCellExampleTypicalUse {
NSMutableArray *_content;
Expand All @@ -35,11 +33,7 @@ - (instancetype)init {
flowLayout.minimumInteritemSpacing = 0;
flowLayout.minimumLineSpacing = 1;
flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
if (@available(iOS 10.0, *)) {
flowLayout.estimatedItemSize = UICollectionViewFlowLayoutAutomaticSize;
} else {
flowLayout.estimatedItemSize = CGSizeMake(kSmallArbitraryCellWidth, kSmallestCellHeight);
}
flowLayout.estimatedItemSize = UICollectionViewFlowLayoutAutomaticSize;
return [self initWithCollectionViewLayout:flowLayout];
}

Expand Down
8 changes: 3 additions & 5 deletions components/Tabs/src/private/MDCItemBarCell.m
Expand Up @@ -228,11 +228,9 @@ - (void)updateWithItem:(UITabBarItem *)item
self.selectedImage = item.selectedImage;
self.image = item.image;
self.badgeValue = item.badgeValue;
if (@available(iOS 10.0, *)) {
if (item.badgeColor) {
self.style.badgeColor = item.badgeColor;
self.badge.badgeColor = item.badgeColor;
}
if (item.badgeColor) {
self.style.badgeColor = item.badgeColor;
self.badge.badgeColor = item.badgeColor;
}
self.accessibilityIdentifier = item.accessibilityIdentifier;
self.accessibilityLabel = item.accessibilityLabel;
Expand Down
Expand Up @@ -131,23 +131,18 @@ - (void)decreaseContentSizeForChildViewController:(UIViewController *)childViewC

- (void)setContentSizeCategory:(UIContentSizeCategory)contentSizeCategory
onChildViewController:(UIViewController *)viewController {
if (@available(iOS 10.0, *)) {
UITraitCollection *contentSizeCategoryTraitCollection =
[UITraitCollection traitCollectionWithPreferredContentSizeCategory:contentSizeCategory];
UITraitCollection *currentTraitCollection = viewController.traitCollection;
NSArray *traitCollections = @[ currentTraitCollection, contentSizeCategoryTraitCollection ];
UITraitCollection *traitCollection =
[UITraitCollection traitCollectionWithTraitsFromCollections:traitCollections];
[self setOverrideTraitCollection:traitCollection forChildViewController:viewController];
[self.view setNeedsLayout];
}
UITraitCollection *contentSizeCategoryTraitCollection =
[UITraitCollection traitCollectionWithPreferredContentSizeCategory:contentSizeCategory];
UITraitCollection *currentTraitCollection = viewController.traitCollection;
NSArray *traitCollections = @[ currentTraitCollection, contentSizeCategoryTraitCollection ];
UITraitCollection *traitCollection =
[UITraitCollection traitCollectionWithTraitsFromCollections:traitCollections];
[self setOverrideTraitCollection:traitCollection forChildViewController:viewController];
[self.view setNeedsLayout];
}

- (UIContentSizeCategory)contentSizeCategoryForViewController:(UIViewController *)viewController {
if (@available(iOS 10.0, *)) {
return viewController.traitCollection.preferredContentSizeCategory;
}
return nil;
return viewController.traitCollection.preferredContentSizeCategory;
}

- (void)setContainerScheme:(id<MDCContainerScheming>)containerScheme {
Expand Down
Expand Up @@ -144,10 +144,7 @@ - (MDCButton *)createContentSizeButtonWithTitle:(NSString *)title selector:(SEL)
[button addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside];
[button applyContainedThemeWithScheme:self.containerScheme];
[button sizeToFit];
button.enabled = NO;
if (@available(iOS 10.0, *)) {
button.enabled = YES;
}
button.enabled = YES;
return button;
}

Expand Down
Expand Up @@ -147,20 +147,18 @@ - (void)resizeScrollViewSubviews {
- (void)enforcePreferredFonts {
[super enforcePreferredFonts];

if (@available(iOS 10.0, *)) {
[self.allTextAreas
enumerateObjectsUsingBlock:^(MDCBaseTextArea *textArea, NSUInteger idx, BOOL *stop) {
textArea.textView.adjustsFontForContentSizeCategory = YES;
textArea.textView.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody
compatibleWithTraitCollection:textArea.traitCollection];
textArea.leadingAssistiveLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption2
compatibleWithTraitCollection:textArea.traitCollection];
textArea.trailingAssistiveLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption2
compatibleWithTraitCollection:textArea.traitCollection];
}];
}
[self.allTextAreas
enumerateObjectsUsingBlock:^(MDCBaseTextArea *textArea, NSUInteger idx, BOOL *stop) {
textArea.textView.adjustsFontForContentSizeCategory = YES;
textArea.textView.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody
compatibleWithTraitCollection:textArea.traitCollection];
textArea.leadingAssistiveLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption2
compatibleWithTraitCollection:textArea.traitCollection];
textArea.trailingAssistiveLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption2
compatibleWithTraitCollection:textArea.traitCollection];
}];
}

- (void)handleResignFirstResponderTapped {
Expand Down
Expand Up @@ -172,20 +172,18 @@ - (void)resizeScrollViewSubviews {
- (void)enforcePreferredFonts {
[super enforcePreferredFonts];

if (@available(iOS 10.0, *)) {
[self.allTextFields
enumerateObjectsUsingBlock:^(MDCBaseTextField *textField, NSUInteger idx, BOOL *stop) {
textField.adjustsFontForContentSizeCategory = YES;
textField.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody
compatibleWithTraitCollection:textField.traitCollection];
textField.leadingAssistiveLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption2
compatibleWithTraitCollection:textField.traitCollection];
textField.trailingAssistiveLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption2
compatibleWithTraitCollection:textField.traitCollection];
}];
}
[self.allTextFields
enumerateObjectsUsingBlock:^(MDCBaseTextField *textField, NSUInteger idx, BOOL *stop) {
textField.adjustsFontForContentSizeCategory = YES;
textField.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody
compatibleWithTraitCollection:textField.traitCollection];
textField.leadingAssistiveLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption2
compatibleWithTraitCollection:textField.traitCollection];
textField.trailingAssistiveLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption2
compatibleWithTraitCollection:textField.traitCollection];
}];
}

- (void)handleResignFirstResponderTapped {
Expand Down
12 changes: 4 additions & 8 deletions components/TextControls/src/BaseTextAreas/MDCBaseTextArea.m
Expand Up @@ -398,14 +398,10 @@ - (CGFloat)numberOfLinesOfVisibleText {
#pragma mark Dynamic Type

- (void)setAdjustsFontForContentSizeCategory:(BOOL)adjustsFontForContentSizeCategory {
if (@available(iOS 10.0, *)) {
_adjustsFontForContentSizeCategory = adjustsFontForContentSizeCategory;
self.textView.adjustsFontForContentSizeCategory = adjustsFontForContentSizeCategory;
self.leadingAssistiveLabel.adjustsFontForContentSizeCategory =
adjustsFontForContentSizeCategory;
self.trailingAssistiveLabel.adjustsFontForContentSizeCategory =
adjustsFontForContentSizeCategory;
}
_adjustsFontForContentSizeCategory = adjustsFontForContentSizeCategory;
self.textView.adjustsFontForContentSizeCategory = adjustsFontForContentSizeCategory;
self.leadingAssistiveLabel.adjustsFontForContentSizeCategory = adjustsFontForContentSizeCategory;
self.trailingAssistiveLabel.adjustsFontForContentSizeCategory = adjustsFontForContentSizeCategory;
}

#pragma mark MDCTextControlState
Expand Down

0 comments on commit b64b0ec

Please sign in to comment.