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 4272d9a63af461a681f81c564c1970eefdb458fe..99d8d9c74af4f6f0a7a2bd28108878b142f525d6 100644 |
| --- a/ios/clean/chrome/browser/ui/tools/menu_view_controller.mm |
| +++ b/ios/clean/chrome/browser/ui/tools/menu_view_controller.mm |
| @@ -17,25 +17,62 @@ |
| #error "This file requires ARC support." |
| #endif |
| +namespace { |
| +const CGFloat kMenuWidth = 250; |
| +const CGFloat kMenuItemHeight = 44; |
| +} |
| + |
| +// Placeholder model for menu item configuration. |
| +@interface MenuItem : NSObject |
| +@property(nonatomic, copy) NSString* title; |
| +@property(nonatomic) SEL action; |
| +@end |
| + |
| +@implementation MenuItem |
| +@synthesize title = _title; |
| +@synthesize action = _action; |
| +@end |
| + |
| +@interface MenuViewController () |
| +@property(nonatomic, readonly) NSArray<MenuItem*>* menuItems; |
| +@end |
| + |
| @implementation MenuViewController |
| +@synthesize menuItems = _menuItems; |
| -- (void)viewDidLoad { |
| +- (instancetype)init { |
| + if ((self = [super init])) { |
| + _menuItems = @[ |
| + [[MenuItem alloc] init], [[MenuItem alloc] init], [[MenuItem alloc] init], |
| + [[MenuItem alloc] init] |
| + ]; |
| + |
| + _menuItems[0].title = @"New Tab"; |
| + |
| + _menuItems[1].title = @"Find in Page…"; |
| + |
| + _menuItems[2].title = @"Request Desktop Site"; |
| + |
| + _menuItems[3].title = @"Settings"; |
| + _menuItems[3].action = @selector(showSettings:); |
| + } |
| + return self; |
| +} |
| + |
| +- (void)loadView { |
| + CGRect frame; |
| + frame.size = CGSizeMake(kMenuWidth, kMenuItemHeight * _menuItems.count); |
| + frame.origin = CGPointZero; |
| + self.view = [[UIView alloc] initWithFrame:frame]; |
|
lpromero
2017/01/05 14:27:04
How does this work in Showcase, where the view con
marq (ping after 24h)
2017/01/09 12:22:33
It works fine, because containing view controllers
|
| self.view.backgroundColor = [UIColor whiteColor]; |
| - struct MenuItem { |
| - NSString* title; |
| - SEL action; |
| - }; |
| - MenuItem menuItems[] = { |
| - {@"New Tab", nullptr}, |
| - {@"Find in Page…", nullptr}, |
| - {@"Request Desktop Site", nullptr}, |
| - {@"Settings", @selector(showSettings:)}, |
| - }; |
| + self.view.autoresizingMask = UIViewAutoresizingNone; |
| +} |
| + |
| +- (void)viewDidLoad { |
| NSMutableArray<UIButton*>* buttons = |
| - [[NSMutableArray alloc] initWithCapacity:arraysize(menuItems)]; |
| + [[NSMutableArray alloc] initWithCapacity:_menuItems.count]; |
| - for (size_t i = 0; i < arraysize(menuItems); ++i) { |
| - const MenuItem& item = menuItems[i]; |
| + for (MenuItem* item in _menuItems) { |
| UIButton* menuButton = [UIButton buttonWithType:UIButtonTypeSystem]; |
| menuButton.translatesAutoresizingMaskIntoConstraints = NO; |
| [menuButton setTitle:item.title forState:UIControlStateNormal]; |