Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Unified Diff: ios/clean/chrome/browser/ui/tools/menu_view_controller.mm

Issue 2693043002: [ios clean] Add overflow buttons for ToolsMenu. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..5bb9722f181321ef19a6be54504fefc061b0b3cb 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)];
[menuButton.titleLabel
setFont:[[MDFRobotoFontLoader sharedInstance] regularFontOfSize:16]];
[menuButton.titleLabel setTextAlignment:NSTextAlignmentNatural];
@@ -117,17 +123,34 @@ const CGFloat kMenuItemHeight = 48;
menu.distribution = UIStackViewDistributionFillEqually;
menu.alignment = UIStackViewAlignmentLeading;
- [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],
+ NSMutableArray* constraintsArray = [NSMutableArray new];
edchin 2017/02/15 04:14:50 Use alloc/init instead to be more consistent with
marq (ping after 24h) 2017/02/15 15:06:16 Usage of +new is explicitly disallowed by the Obje
sczs 2017/02/16 00:31:39 Sounds good, will call -activateConstraints twice
+
+ // Stack view to hold overflow ToolbarButtons.
+ if (self.traitCollection.horizontalSizeClass ==
+ UIUserInterfaceSizeClassCompact) {
+ self.toolbarOverflowStackView =
+ [[MenuOverflowControlsStackView alloc] init];
+ [self.toolbarOverflowStackView.toolsMenuButton
+ addTarget:nil
+ action:@selector(closeToolsMenu:)
+ forControlEvents:UIControlEventTouchUpInside];
+ [menu insertArrangedSubview:self.toolbarOverflowStackView atIndex:0];
+ [constraintsArray addObjectsFromArray:@[
+ [self.toolbarOverflowStackView.leadingAnchor
+ constraintEqualToAnchor:menu.leadingAnchor],
+ [self.toolbarOverflowStackView.trailingAnchor
+ constraintEqualToAnchor:menu.trailingAnchor],
+ ]];
+ }
+ [constraintsArray addObjectsFromArray:@[
+ [menu.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
+ [menu.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
+ [menu.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor],
+ [menu.topAnchor constraintEqualToAnchor:self.view.topAnchor],
]];
+
+ [self.view addSubview:menu];
+ [NSLayoutConstraint activateConstraints:constraintsArray];
edchin 2017/02/15 04:14:50 How did the menu work previously without this cons
sczs 2017/02/16 00:31:39 It was creating the array in place, but I changed
}
@end

Powered by Google App Engine
This is Rietveld 408576698