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

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

Issue 2737563006: [ios] Adds support for Find in Page to the new architecture. (Closed)
Patch Set: Fix GN. Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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"
11 #import "ios/clean/chrome/browser/ui/commands/find_in_page_visibility_commands.h "
11 #import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h" 12 #import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h"
12 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_button.h" 13 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_button.h"
13 #import "ios/clean/chrome/browser/ui/tools/menu_overflow_controls_stackview.h" 14 #import "ios/clean/chrome/browser/ui/tools/menu_overflow_controls_stackview.h"
15 #import "ios/clean/chrome/browser/ui/tools/tools_actions.h"
14 #import "ios/clean/chrome/browser/ui/tools/tools_menu_item.h" 16 #import "ios/clean/chrome/browser/ui/tools/tools_menu_item.h"
15 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" 17 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
16 18
17 #if !defined(__has_feature) || !__has_feature(objc_arc) 19 #if !defined(__has_feature) || !__has_feature(objc_arc)
18 #error "This file requires ARC support." 20 #error "This file requires ARC support."
19 #endif 21 #endif
20 22
21 namespace { 23 namespace {
22 const CGFloat kMenuWidth = 250; 24 const CGFloat kMenuWidth = 250;
23 const CGFloat kMenuItemHeight = 48; 25 const CGFloat kMenuItemHeight = 48;
24 } 26 }
25 27
26 @interface MenuViewController () 28 @interface MenuViewController ()<ToolsActions>
27 @property(nonatomic, strong) NSArray<ToolsMenuItem*>* menuItems; 29 @property(nonatomic, strong) NSArray<ToolsMenuItem*>* menuItems;
28 @property(nonatomic, strong) 30 @property(nonatomic, strong)
29 MenuOverflowControlsStackView* toolbarOverflowStackView; 31 MenuOverflowControlsStackView* toolbarOverflowStackView;
30 @end 32 @end
31 33
32 @implementation MenuViewController 34 @implementation MenuViewController
35 @synthesize dispatcher = _dispatcher;
33 @synthesize menuItems = _menuItems; 36 @synthesize menuItems = _menuItems;
34 @synthesize toolbarOverflowStackView = _toolbarOverflowStackView; 37 @synthesize toolbarOverflowStackView = _toolbarOverflowStackView;
35 @synthesize dispatcher = _dispatcher;
36 38
37 - (void)loadView { 39 - (void)loadView {
38 CGRect frame; 40 CGRect frame;
39 frame.size = CGSizeMake(kMenuWidth, kMenuItemHeight * _menuItems.count); 41 frame.size = CGSizeMake(kMenuWidth, kMenuItemHeight * _menuItems.count);
40 frame.origin = CGPointZero; 42 frame.origin = CGPointZero;
41 self.view = [[UIView alloc] initWithFrame:frame]; 43 self.view = [[UIView alloc] initWithFrame:frame];
42 self.view.backgroundColor = [UIColor whiteColor]; 44 self.view.backgroundColor = [UIColor whiteColor];
43 self.view.autoresizingMask = UIViewAutoresizingNone; 45 self.view.autoresizingMask = UIViewAutoresizingNone;
44 self.view.layer.borderColor = [UIColor clearColor].CGColor; 46 self.view.layer.borderColor = [UIColor clearColor].CGColor;
45 } 47 }
46 48
47 - (void)viewDidLoad { 49 - (void)viewDidLoad {
48 NSMutableArray<UIButton*>* buttons = 50 NSMutableArray<UIButton*>* buttons =
49 [[NSMutableArray alloc] initWithCapacity:_menuItems.count]; 51 [[NSMutableArray alloc] initWithCapacity:_menuItems.count];
50 52
51 for (ToolsMenuItem* item in _menuItems) { 53 for (ToolsMenuItem* item in _menuItems) {
52 UIButton* menuButton = [UIButton buttonWithType:UIButtonTypeSystem]; 54 UIButton* menuButton = [UIButton buttonWithType:UIButtonTypeSystem];
53 menuButton.translatesAutoresizingMaskIntoConstraints = NO; 55 menuButton.translatesAutoresizingMaskIntoConstraints = NO;
54 menuButton.tintColor = [UIColor blackColor]; 56 menuButton.tintColor = [UIColor blackColor];
55 [menuButton setTitle:item.title forState:UIControlStateNormal]; 57 [menuButton setTitle:item.title forState:UIControlStateNormal];
56 [menuButton setContentEdgeInsets:UIEdgeInsetsMakeDirected(0, 10.0f, 0, 0)]; 58 [menuButton setContentEdgeInsets:UIEdgeInsetsMakeDirected(0, 10.0f, 0, 0)];
57 [menuButton.titleLabel setFont:[MDCTypography subheadFont]]; 59 [menuButton.titleLabel setFont:[MDCTypography subheadFont]];
58 [menuButton.titleLabel setTextAlignment:NSTextAlignmentNatural]; 60 [menuButton.titleLabel setTextAlignment:NSTextAlignmentNatural];
59 [menuButton addTarget:self 61 [menuButton addTarget:self
60 action:@selector(closeToolsMenu:) 62 action:@selector(closeToolsMenu:)
61 forControlEvents:UIControlEventTouchUpInside]; 63 forControlEvents:UIControlEventTouchUpInside];
62 if (item.action) { 64 if (item.action) {
63 [menuButton addTarget:nil 65 id target = (item.action == @selector(showFindInPage)) ? self : nil;
66 [menuButton addTarget:target
64 action:item.action 67 action:item.action
65 forControlEvents:UIControlEventTouchUpInside]; 68 forControlEvents:UIControlEventTouchUpInside];
66 } 69 }
67 [buttons addObject:menuButton]; 70 [buttons addObject:menuButton];
68 } 71 }
69 72
70 // Placeholder stack view to hold menu contents. 73 // Placeholder stack view to hold menu contents.
71 UIStackView* menu = [[UIStackView alloc] initWithArrangedSubviews:buttons]; 74 UIStackView* menu = [[UIStackView alloc] initWithArrangedSubviews:buttons];
72 menu.translatesAutoresizingMaskIntoConstraints = NO; 75 menu.translatesAutoresizingMaskIntoConstraints = NO;
73 menu.axis = UILayoutConstraintAxisVertical; 76 menu.axis = UILayoutConstraintAxisVertical;
(...skipping 28 matching lines...) Expand all
102 [menu.topAnchor constraintEqualToAnchor:self.view.topAnchor], 105 [menu.topAnchor constraintEqualToAnchor:self.view.topAnchor],
103 ]]; 106 ]];
104 } 107 }
105 108
106 #pragma mark - ToolsMenuCommands 109 #pragma mark - ToolsMenuCommands
107 110
108 - (void)closeToolsMenu:(id)sender { 111 - (void)closeToolsMenu:(id)sender {
109 [self.dispatcher closeToolsMenu]; 112 [self.dispatcher closeToolsMenu];
110 } 113 }
111 114
115 - (void)showFindInPage {
116 [self.dispatcher showFindInPage];
117 }
118
112 #pragma mark - Tools Consumer 119 #pragma mark - Tools Consumer
113 120
114 - (void)setToolsMenuItems:(NSArray*)menuItems { 121 - (void)setToolsMenuItems:(NSArray*)menuItems {
115 _menuItems = menuItems; 122 _menuItems = menuItems;
116 } 123 }
117 124
118 @end 125 @end
OLDNEW
« no previous file with comments | « ios/clean/chrome/browser/ui/tools/menu_view_controller.h ('k') | ios/clean/chrome/browser/ui/tools/tools_actions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698