| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/tools/menu_view_controller.h" | 5 #import "ios/clean/chrome/browser/ui/tools/menu_view_controller.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #import "base/logging.h" | 8 #import "base/logging.h" |
| 9 #import "base/macros.h" | 9 #import "base/macros.h" |
| 10 #import "ios/chrome/browser/ui/rtl_geometry.h" | 10 #import "ios/chrome/browser/ui/rtl_geometry.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 const CGFloat kMenuWidth = 250; | 24 const CGFloat kMenuWidth = 250; |
| 25 const CGFloat kMenuItemHeight = 48; | 25 const CGFloat kMenuItemHeight = 48; |
| 26 } | 26 } |
| 27 | 27 |
| 28 @interface MenuViewController ()<ToolsActions> | 28 @interface MenuViewController ()<ToolsActions> |
| 29 @property(nonatomic, strong) NSArray<ToolsMenuItem*>* menuItems; | 29 @property(nonatomic, strong) NSArray<ToolsMenuItem*>* menuItems; |
| 30 @property(nonatomic, strong) | 30 @property(nonatomic, strong) |
| 31 MenuOverflowControlsStackView* toolbarOverflowStackView; | 31 MenuOverflowControlsStackView* toolbarOverflowStackView; |
| 32 @property(nonatomic, assign) BOOL displayOverflowControls; |
| 32 @end | 33 @end |
| 33 | 34 |
| 34 @implementation MenuViewController | 35 @implementation MenuViewController |
| 35 @synthesize dispatcher = _dispatcher; | 36 @synthesize dispatcher = _dispatcher; |
| 36 @synthesize menuItems = _menuItems; | 37 @synthesize menuItems = _menuItems; |
| 37 @synthesize toolbarOverflowStackView = _toolbarOverflowStackView; | 38 @synthesize toolbarOverflowStackView = _toolbarOverflowStackView; |
| 39 @synthesize displayOverflowControls = _displayOverflowControls; |
| 38 | 40 |
| 39 - (void)loadView { | 41 - (void)loadView { |
| 40 CGRect frame; | 42 CGRect frame; |
| 41 frame.size = CGSizeMake(kMenuWidth, kMenuItemHeight * _menuItems.count); | 43 frame.size = CGSizeMake(kMenuWidth, kMenuItemHeight * _menuItems.count); |
| 42 frame.origin = CGPointZero; | 44 frame.origin = CGPointZero; |
| 43 self.view = [[UIView alloc] initWithFrame:frame]; | 45 self.view = [[UIView alloc] initWithFrame:frame]; |
| 44 self.view.backgroundColor = [UIColor whiteColor]; | 46 self.view.backgroundColor = [UIColor whiteColor]; |
| 45 self.view.autoresizingMask = UIViewAutoresizingNone; | 47 self.view.autoresizingMask = UIViewAutoresizingNone; |
| 46 self.view.layer.borderColor = [UIColor clearColor].CGColor; | 48 self.view.layer.borderColor = [UIColor clearColor].CGColor; |
| 47 } | 49 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 72 | 74 |
| 73 // Placeholder stack view to hold menu contents. | 75 // Placeholder stack view to hold menu contents. |
| 74 UIStackView* menu = [[UIStackView alloc] initWithArrangedSubviews:buttons]; | 76 UIStackView* menu = [[UIStackView alloc] initWithArrangedSubviews:buttons]; |
| 75 menu.translatesAutoresizingMaskIntoConstraints = NO; | 77 menu.translatesAutoresizingMaskIntoConstraints = NO; |
| 76 menu.axis = UILayoutConstraintAxisVertical; | 78 menu.axis = UILayoutConstraintAxisVertical; |
| 77 menu.distribution = UIStackViewDistributionFillEqually; | 79 menu.distribution = UIStackViewDistributionFillEqually; |
| 78 menu.alignment = UIStackViewAlignmentLeading; | 80 menu.alignment = UIStackViewAlignmentLeading; |
| 79 | 81 |
| 80 // Stack view to hold overflow ToolbarButtons. | 82 // Stack view to hold overflow ToolbarButtons. |
| 81 if (self.traitCollection.horizontalSizeClass == | 83 if (self.traitCollection.horizontalSizeClass == |
| 82 UIUserInterfaceSizeClassCompact) { | 84 UIUserInterfaceSizeClassCompact && |
| 85 self.displayOverflowControls) { |
| 83 self.toolbarOverflowStackView = | 86 self.toolbarOverflowStackView = |
| 84 [[MenuOverflowControlsStackView alloc] init]; | 87 [[MenuOverflowControlsStackView alloc] init]; |
| 85 // PLACEHOLDER: ToolsMenuButton might end up being part of the MenuVC's view | 88 // PLACEHOLDER: ToolsMenuButton might end up being part of the MenuVC's view |
| 86 // instead of the StackView. We are waiting confirmation on this. | 89 // instead of the StackView. We are waiting confirmation on this. |
| 87 [self.toolbarOverflowStackView.toolsMenuButton | 90 [self.toolbarOverflowStackView.toolsMenuButton |
| 88 addTarget:nil | 91 addTarget:nil |
| 89 action:@selector(closeToolsMenu:) | 92 action:@selector(closeToolsMenu:) |
| 90 forControlEvents:UIControlEventTouchUpInside]; | 93 forControlEvents:UIControlEventTouchUpInside]; |
| 91 [menu insertArrangedSubview:self.toolbarOverflowStackView atIndex:0]; | 94 [menu insertArrangedSubview:self.toolbarOverflowStackView atIndex:0]; |
| 92 [NSLayoutConstraint activateConstraints:@[ | 95 [NSLayoutConstraint activateConstraints:@[ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 115 - (void)showFindInPage { | 118 - (void)showFindInPage { |
| 116 [self.dispatcher showFindInPage]; | 119 [self.dispatcher showFindInPage]; |
| 117 } | 120 } |
| 118 | 121 |
| 119 #pragma mark - Tools Consumer | 122 #pragma mark - Tools Consumer |
| 120 | 123 |
| 121 - (void)setToolsMenuItems:(NSArray*)menuItems { | 124 - (void)setToolsMenuItems:(NSArray*)menuItems { |
| 122 _menuItems = menuItems; | 125 _menuItems = menuItems; |
| 123 } | 126 } |
| 124 | 127 |
| 128 - (void)displayOverflowControls:(BOOL)displayOverflowControls { |
| 129 self.displayOverflowControls = displayOverflowControls; |
| 130 } |
| 131 |
| 125 @end | 132 @end |
| OLD | NEW |