Chromium Code Reviews| Index: ios/clean/chrome/browser/ui/tools/menu_view_controller.mm |
| diff --git a/ios/clean/chrome/browser/ui/tools/menu_view_controller.mm b/ios/clean/chrome/browser/ui/tools/menu_view_controller.mm |
| index 7fb262d42fad482111b70b4745d54b4f0d0c7818..21fffa4d034474a9721a2b1a7fcbfc3bb9d511fd 100644 |
| --- a/ios/clean/chrome/browser/ui/tools/menu_view_controller.mm |
| +++ b/ios/clean/chrome/browser/ui/tools/menu_view_controller.mm |
| @@ -13,6 +13,8 @@ |
| #import "base/macros.h" |
| #import "ios/clean/chrome/browser/ui/actions/settings_actions.h" |
| #import "ios/clean/chrome/browser/ui/actions/tools_menu_actions.h" |
| +#import "ios/clean/chrome/browser/ui/toolbar/toolbar_button.h" |
| +#import "ios/clean/chrome/browser/ui/tools/menu_overflow_controls_stackview.h" |
| #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoFontLoader.h" |
| #if !defined(__has_feature) || !__has_feature(objc_arc) |
| @@ -37,10 +39,13 @@ const CGFloat kMenuItemHeight = 48; |
| @interface MenuViewController () |
| @property(nonatomic, readonly) NSArray<MenuItem*>* menuItems; |
| +@property(nonatomic, strong) |
| + MenuOverflowControlsStackView* toolbarOverflowStackView; |
| @end |
| @implementation MenuViewController |
| @synthesize menuItems = _menuItems; |
| +@synthesize toolbarOverflowStackView = _toolbarOverflowStackView; |
| - (instancetype)init { |
| if ((self = [super init])) { |
| @@ -96,6 +101,7 @@ const CGFloat kMenuItemHeight = 48; |
| menuButton.translatesAutoresizingMaskIntoConstraints = NO; |
| menuButton.tintColor = [UIColor blackColor]; |
| [menuButton setTitle:item.title forState:UIControlStateNormal]; |
| + [menuButton setContentEdgeInsets:UIEdgeInsetsMake(0, 10.0f, 0, 0)]; |
|
marq (ping after 24h)
2017/02/16 10:54:42
Since you are setting different left and right ins
|
| [menuButton.titleLabel |
| setFont:[[MDFRobotoFontLoader sharedInstance] regularFontOfSize:16]]; |
| [menuButton.titleLabel setTextAlignment:NSTextAlignmentNatural]; |
| @@ -117,16 +123,32 @@ const CGFloat kMenuItemHeight = 48; |
| menu.distribution = UIStackViewDistributionFillEqually; |
| menu.alignment = UIStackViewAlignmentLeading; |
| + // Stack view to hold overflow ToolbarButtons. |
| + if (self.traitCollection.horizontalSizeClass == |
| + UIUserInterfaceSizeClassCompact) { |
| + self.toolbarOverflowStackView = |
| + [[MenuOverflowControlsStackView alloc] init]; |
| + // PLACEHOLDER: ToolsMenuButton might end up being part of the MenuVC's view |
| + // instead of the StackView. We are waiting confirmation on this. |
| + [self.toolbarOverflowStackView.toolsMenuButton |
| + addTarget:nil |
| + action:@selector(closeToolsMenu:) |
| + forControlEvents:UIControlEventTouchUpInside]; |
| + [menu insertArrangedSubview:self.toolbarOverflowStackView atIndex:0]; |
| + [NSLayoutConstraint activateConstraints:@[ |
| + [self.toolbarOverflowStackView.leadingAnchor |
| + constraintEqualToAnchor:menu.leadingAnchor], |
| + [self.toolbarOverflowStackView.trailingAnchor |
| + constraintEqualToAnchor:menu.trailingAnchor], |
| + ]]; |
| + } |
| + |
| [self.view addSubview:menu]; |
| [NSLayoutConstraint activateConstraints:@[ |
| - [menu.leadingAnchor |
| - constraintEqualToAnchor:self.view.layoutMarginsGuide.leadingAnchor], |
| - [menu.trailingAnchor |
| - constraintEqualToAnchor:self.view.layoutMarginsGuide.trailingAnchor], |
| - [menu.bottomAnchor |
| - constraintEqualToAnchor:self.view.layoutMarginsGuide.bottomAnchor], |
| - [menu.topAnchor |
| - constraintEqualToAnchor:self.view.layoutMarginsGuide.topAnchor], |
| + [menu.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor], |
| + [menu.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor], |
| + [menu.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor], |
| + [menu.topAnchor constraintEqualToAnchor:self.view.topAnchor], |
| ]]; |
| } |