| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_button.h" | 5 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_button.h" |
| 6 | 6 |
| 7 #if !defined(__has_feature) || !__has_feature(objc_arc) | 7 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 8 #error "This file requires ARC support." | 8 #error "This file requires ARC support." |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 @implementation ToolbarButton | 11 @implementation ToolbarButton |
| 12 @synthesize visibilityMask = _visibilityMask; | 12 @synthesize visibilityMask = _visibilityMask; |
| 13 @synthesize hiddenInCurrentSizeClass = _hiddenInCurrentSizeClass; | 13 @synthesize hiddenInCurrentSizeClass = _hiddenInCurrentSizeClass; |
| 14 @synthesize hiddenInCurrentState = _hiddenInCurrentState; | 14 @synthesize hiddenInCurrentState = _hiddenInCurrentState; |
| 15 | 15 |
| 16 + (instancetype)toolbarButtonWithImageForNormalState:(UIImage*)normalImage | 16 + (instancetype)toolbarButtonWithImageForNormalState:(UIImage*)normalImage |
| 17 imageForHighlightedState:(UIImage*)highlightedImage | 17 imageForHighlightedState:(UIImage*)highlightedImage |
| 18 imageForDisabledState:(UIImage*)disabledImage { | 18 imageForDisabledState:(UIImage*)disabledImage { |
| 19 ToolbarButton* button = [[self class] buttonWithType:UIButtonTypeSystem]; | 19 ToolbarButton* button = [[self class] buttonWithType:UIButtonTypeSystem]; |
| 20 [button setImage:normalImage forState:UIControlStateNormal]; | 20 [button setImage:normalImage forState:UIControlStateNormal]; |
| 21 [button setImage:highlightedImage forState:UIControlStateHighlighted]; | 21 [button setImage:highlightedImage forState:UIControlStateHighlighted]; |
| 22 [button setImage:disabledImage forState:UIControlStateDisabled]; | 22 [button setImage:disabledImage forState:UIControlStateDisabled]; |
| 23 button.translatesAutoresizingMaskIntoConstraints = NO; | 23 button.translatesAutoresizingMaskIntoConstraints = NO; |
| 24 [button | |
| 25 setContentCompressionResistancePriority:UILayoutPriorityRequired | |
| 26 forAxis:UILayoutConstraintAxisHorizontal]; | |
| 27 [button setContentHuggingPriority:UILayoutPriorityRequired | |
| 28 forAxis:UILayoutConstraintAxisHorizontal]; | |
| 29 return button; | 24 return button; |
| 30 } | 25 } |
| 31 | 26 |
| 32 #pragma mark - Public Methods | 27 #pragma mark - Public Methods |
| 33 | 28 |
| 34 - (void)updateHiddenInCurrentSizeClass { | 29 - (void)updateHiddenInCurrentSizeClass { |
| 35 BOOL newHiddenValue = YES; | 30 BOOL newHiddenValue = YES; |
| 36 switch (self.traitCollection.horizontalSizeClass) { | 31 switch (self.traitCollection.horizontalSizeClass) { |
| 37 case UIUserInterfaceSizeClassRegular: | 32 case UIUserInterfaceSizeClassRegular: |
| 38 newHiddenValue = | 33 newHiddenValue = |
| (...skipping 17 matching lines...) Expand all Loading... |
| 56 self.hiddenInCurrentSizeClass = newHiddenValue; | 51 self.hiddenInCurrentSizeClass = newHiddenValue; |
| 57 [self setHiddenForCurrentStateAndSizeClass]; | 52 [self setHiddenForCurrentStateAndSizeClass]; |
| 58 } | 53 } |
| 59 } | 54 } |
| 60 | 55 |
| 61 - (void)setHiddenForCurrentStateAndSizeClass { | 56 - (void)setHiddenForCurrentStateAndSizeClass { |
| 62 self.hidden = self.hiddenInCurrentState || self.hiddenInCurrentSizeClass; | 57 self.hidden = self.hiddenInCurrentState || self.hiddenInCurrentSizeClass; |
| 63 } | 58 } |
| 64 | 59 |
| 65 @end | 60 @end |
| OLD | NEW |