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

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

Issue 2588733002: Upstream Chrome on iOS source code [9/11]. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « ios/chrome/browser/ui/tools/menu_view_controller.h ('k') | ios/chrome/browser/ui/tools/tools_coordinator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/tools/menu_view_controller.mm
diff --git a/ios/chrome/browser/ui/tools/menu_view_controller.mm b/ios/chrome/browser/ui/tools/menu_view_controller.mm
new file mode 100644
index 0000000000000000000000000000000000000000..7e147d0d4959f9e9b9714ff3d9979ba7b0810da3
--- /dev/null
+++ b/ios/chrome/browser/ui/tools/menu_view_controller.mm
@@ -0,0 +1,73 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// ====== New Architecture =====
+// = This code is only used in the new iOS Chrome architecture. =
+// ============================================================================
+
+#import "ios/chrome/browser/ui/tools/menu_view_controller.h"
+
+#import "base/logging.h"
+#import "base/macros.h"
+#import "ios/chrome/browser/ui/actions/settings_actions.h"
+#import "ios/chrome/browser/ui/actions/tools_menu_actions.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+@implementation MenuViewController
+
+- (void)viewDidLoad {
+ 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:)},
+ };
+ NSMutableArray<UIButton*>* buttons =
+ [[NSMutableArray alloc] initWithCapacity:arraysize(menuItems)];
+
+ for (size_t i = 0; i < arraysize(menuItems); ++i) {
+ const MenuItem& item = menuItems[i];
+ UIButton* menuButton = [UIButton buttonWithType:UIButtonTypeSystem];
+ menuButton.translatesAutoresizingMaskIntoConstraints = NO;
+ [menuButton setTitle:item.title forState:UIControlStateNormal];
+ [menuButton addTarget:nil
+ action:@selector(closeToolsMenu:)
+ forControlEvents:UIControlEventTouchUpInside];
+ if (item.action) {
+ [menuButton addTarget:nil
+ action:item.action
+ forControlEvents:UIControlEventTouchUpInside];
+ }
+ [buttons addObject:menuButton];
+ }
+
+ // Placeholder stack view to hold menu contents.
+ UIStackView* menu = [[UIStackView alloc] initWithArrangedSubviews:buttons];
+ menu.translatesAutoresizingMaskIntoConstraints = NO;
+ menu.axis = UILayoutConstraintAxisVertical;
+ 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],
+ ]];
+}
+
+@end
« no previous file with comments | « ios/chrome/browser/ui/tools/menu_view_controller.h ('k') | ios/chrome/browser/ui/tools/tools_coordinator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698