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 // ====== New Architecture ===== | 5 // ====== New Architecture ===== |
6 // = This code is only used in the new iOS Chrome architecture. = | 6 // = This code is only used in the new iOS Chrome architecture. = |
7 // ============================================================================ | 7 // ============================================================================ |
8 | 8 |
9 #import "ios/clean/chrome/browser/ui/tools/menu_view_controller.h" | 9 #import "ios/clean/chrome/browser/ui/tools/menu_view_controller.h" |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... | |
38 @synthesize action = _action; | 38 @synthesize action = _action; |
39 @end | 39 @end |
40 | 40 |
41 @interface MenuViewController () | 41 @interface MenuViewController () |
42 @property(nonatomic, readonly) NSArray<MenuItem*>* menuItems; | 42 @property(nonatomic, readonly) NSArray<MenuItem*>* menuItems; |
43 @property(nonatomic, strong) | 43 @property(nonatomic, strong) |
44 MenuOverflowControlsStackView* toolbarOverflowStackView; | 44 MenuOverflowControlsStackView* toolbarOverflowStackView; |
45 @end | 45 @end |
46 | 46 |
47 @implementation MenuViewController | 47 @implementation MenuViewController |
48 @synthesize dispatcher = _dispatcher; | |
48 @synthesize menuItems = _menuItems; | 49 @synthesize menuItems = _menuItems; |
49 @synthesize toolbarOverflowStackView = _toolbarOverflowStackView; | 50 @synthesize toolbarOverflowStackView = _toolbarOverflowStackView; |
50 | 51 |
51 - (instancetype)init { | 52 - (instancetype)init { |
52 if ((self = [super init])) { | 53 if ((self = [super init])) { |
53 _menuItems = @[ | 54 _menuItems = @[ |
54 [[MenuItem alloc] init], [[MenuItem alloc] init], [[MenuItem alloc] init], | 55 [[MenuItem alloc] init], [[MenuItem alloc] init], [[MenuItem alloc] init], |
55 [[MenuItem alloc] init], [[MenuItem alloc] init], [[MenuItem alloc] init], | 56 [[MenuItem alloc] init], [[MenuItem alloc] init], [[MenuItem alloc] init], |
56 [[MenuItem alloc] init], [[MenuItem alloc] init], [[MenuItem alloc] init], | 57 [[MenuItem alloc] init], [[MenuItem alloc] init], [[MenuItem alloc] init], |
57 [[MenuItem alloc] init], [[MenuItem alloc] init] | 58 [[MenuItem alloc] init], [[MenuItem alloc] init] |
58 ]; | 59 ]; |
59 | 60 |
60 _menuItems[0].title = @"New Tab"; | 61 _menuItems[0].title = @"New Tab"; |
61 | 62 |
62 _menuItems[1].title = @"New Incognito Tab"; | 63 _menuItems[1].title = @"New Incognito Tab"; |
63 | 64 |
64 _menuItems[2].title = @"Bookmarks"; | 65 _menuItems[2].title = @"Bookmarks"; |
65 | 66 |
66 _menuItems[3].title = @"Reading List"; | 67 _menuItems[3].title = @"Reading List"; |
67 | 68 |
68 _menuItems[4].title = @"Recent Tabs"; | 69 _menuItems[4].title = @"Recent Tabs"; |
69 | 70 |
70 _menuItems[5].title = @"History"; | 71 _menuItems[5].title = @"History"; |
71 | 72 |
72 _menuItems[6].title = @"Report an Issue"; | 73 _menuItems[6].title = @"Report an Issue"; |
73 | 74 |
74 _menuItems[7].title = @"Find in Page…"; | 75 _menuItems[7].title = @"Find in Page…"; |
76 _menuItems[7].action = @selector(showFindInPage); | |
75 | 77 |
76 _menuItems[8].title = @"Request Desktop Site"; | 78 _menuItems[8].title = @"Request Desktop Site"; |
77 | 79 |
78 _menuItems[9].title = @"Settings"; | 80 _menuItems[9].title = @"Settings"; |
79 _menuItems[9].action = @selector(showSettings:); | 81 _menuItems[9].action = @selector(showSettings:); |
80 | 82 |
81 _menuItems[10].title = @"Help"; | 83 _menuItems[10].title = @"Help"; |
82 } | 84 } |
83 return self; | 85 return self; |
84 } | 86 } |
(...skipping 18 matching lines...) Expand all Loading... | |
103 menuButton.tintColor = [UIColor blackColor]; | 105 menuButton.tintColor = [UIColor blackColor]; |
104 [menuButton setTitle:item.title forState:UIControlStateNormal]; | 106 [menuButton setTitle:item.title forState:UIControlStateNormal]; |
105 [menuButton setContentEdgeInsets:UIEdgeInsetsMakeDirected(0, 10.0f, 0, 0)]; | 107 [menuButton setContentEdgeInsets:UIEdgeInsetsMakeDirected(0, 10.0f, 0, 0)]; |
106 [menuButton.titleLabel | 108 [menuButton.titleLabel |
107 setFont:[[MDFRobotoFontLoader sharedInstance] regularFontOfSize:16]]; | 109 setFont:[[MDFRobotoFontLoader sharedInstance] regularFontOfSize:16]]; |
108 [menuButton.titleLabel setTextAlignment:NSTextAlignmentNatural]; | 110 [menuButton.titleLabel setTextAlignment:NSTextAlignmentNatural]; |
109 [menuButton addTarget:nil | 111 [menuButton addTarget:nil |
110 action:@selector(closeToolsMenu:) | 112 action:@selector(closeToolsMenu:) |
111 forControlEvents:UIControlEventTouchUpInside]; | 113 forControlEvents:UIControlEventTouchUpInside]; |
112 if (item.action) { | 114 if (item.action) { |
113 [menuButton addTarget:nil | 115 id target = (item.action == @selector(showFindInPage)) ? self : nil; |
116 [menuButton addTarget:target | |
114 action:item.action | 117 action:item.action |
115 forControlEvents:UIControlEventTouchUpInside]; | 118 forControlEvents:UIControlEventTouchUpInside]; |
116 } | 119 } |
117 [buttons addObject:menuButton]; | 120 [buttons addObject:menuButton]; |
118 } | 121 } |
119 | 122 |
120 // Placeholder stack view to hold menu contents. | 123 // Placeholder stack view to hold menu contents. |
121 UIStackView* menu = [[UIStackView alloc] initWithArrangedSubviews:buttons]; | 124 UIStackView* menu = [[UIStackView alloc] initWithArrangedSubviews:buttons]; |
122 menu.translatesAutoresizingMaskIntoConstraints = NO; | 125 menu.translatesAutoresizingMaskIntoConstraints = NO; |
123 menu.axis = UILayoutConstraintAxisVertical; | 126 menu.axis = UILayoutConstraintAxisVertical; |
(...skipping 22 matching lines...) Expand all Loading... | |
146 | 149 |
147 [self.view addSubview:menu]; | 150 [self.view addSubview:menu]; |
148 [NSLayoutConstraint activateConstraints:@[ | 151 [NSLayoutConstraint activateConstraints:@[ |
149 [menu.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor], | 152 [menu.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor], |
150 [menu.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor], | 153 [menu.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor], |
151 [menu.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor], | 154 [menu.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor], |
152 [menu.topAnchor constraintEqualToAnchor:self.view.topAnchor], | 155 [menu.topAnchor constraintEqualToAnchor:self.view.topAnchor], |
153 ]]; | 156 ]]; |
154 } | 157 } |
155 | 158 |
159 - (void)showFindInPage { | |
160 [self.dispatcher showFindInPage]; | |
rohitrao (ping after 24h)
2017/03/14 01:10:37
13) Starting to convert the tools menu over to the
| |
161 } | |
162 | |
156 @end | 163 @end |
OLD | NEW |