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

Side by Side Diff: ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.mm

Issue 2785213003: [ios] Use dispatcher for ToolsMenu commands. (Closed)
Patch Set: Rebase 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/toolbar/toolbar_view_controller.h" 5 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.h"
6 6
7 #import "base/mac/foundation_util.h" 7 #import "base/mac/foundation_util.h"
8 #import "ios/clean/chrome/browser/ui/actions/tab_grid_actions.h" 8 #import "ios/clean/chrome/browser/ui/actions/tab_grid_actions.h"
9 #import "ios/clean/chrome/browser/ui/actions/tab_strip_actions.h" 9 #import "ios/clean/chrome/browser/ui/actions/tab_strip_actions.h"
10 #import "ios/clean/chrome/browser/ui/actions/tools_menu_actions.h"
11 #import "ios/clean/chrome/browser/ui/commands/navigation_commands.h" 10 #import "ios/clean/chrome/browser/ui/commands/navigation_commands.h"
12 #import "ios/clean/chrome/browser/ui/commands/toolbar_commands.h" 11 #import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h"
13 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_button+factory.h" 12 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_button+factory.h"
14 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_component_options.h" 13 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_component_options.h"
15 14
16 #if !defined(__has_feature) || !__has_feature(objc_arc) 15 #if !defined(__has_feature) || !__has_feature(objc_arc)
17 #error "This file requires ARC support." 16 #error "This file requires ARC support."
18 #endif 17 #endif
19 18
20 namespace { 19 namespace {
21 // Stackview Vertical Margin. 20 // Stackview Vertical Margin.
22 CGFloat kVerticalMargin = 5.0f; 21 CGFloat kVerticalMargin = 5.0f;
23 // Stackview Horizontal Margin. 22 // Stackview Horizontal Margin.
24 CGFloat kHorizontalMargin = 8.0f; 23 CGFloat kHorizontalMargin = 8.0f;
25 } // namespace 24 } // namespace
26 25
27 @interface ToolbarViewController ()<ToolsMenuActions> 26 @interface ToolbarViewController ()
28 @property(nonatomic, strong) UITextField* omnibox; 27 @property(nonatomic, strong) UITextField* omnibox;
29 @property(nonatomic, strong) UIStackView* stackView; 28 @property(nonatomic, strong) UIStackView* stackView;
30 @property(nonatomic, strong) ToolbarButton* backButton; 29 @property(nonatomic, strong) ToolbarButton* backButton;
31 @property(nonatomic, strong) ToolbarButton* forwardButton; 30 @property(nonatomic, strong) ToolbarButton* forwardButton;
32 @property(nonatomic, strong) ToolbarButton* tabSwitchStripButton; 31 @property(nonatomic, strong) ToolbarButton* tabSwitchStripButton;
33 @property(nonatomic, strong) ToolbarButton* tabSwitchGridButton; 32 @property(nonatomic, strong) ToolbarButton* tabSwitchGridButton;
34 @property(nonatomic, strong) ToolbarButton* toolsMenuButton; 33 @property(nonatomic, strong) ToolbarButton* toolsMenuButton;
35 @property(nonatomic, strong) ToolbarButton* shareButton; 34 @property(nonatomic, strong) ToolbarButton* shareButton;
36 @property(nonatomic, strong) ToolbarButton* reloadButton; 35 @property(nonatomic, strong) ToolbarButton* reloadButton;
37 @property(nonatomic, strong) ToolbarButton* stopButton; 36 @property(nonatomic, strong) ToolbarButton* stopButton;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 ToolbarComponentVisibilityRegularWidth; 131 ToolbarComponentVisibilityRegularWidth;
133 [self.tabSwitchGridButton addTarget:nil 132 [self.tabSwitchGridButton addTarget:nil
134 action:@selector(showTabGrid:) 133 action:@selector(showTabGrid:)
135 forControlEvents:UIControlEventTouchUpInside]; 134 forControlEvents:UIControlEventTouchUpInside];
136 self.tabSwitchGridButton.hiddenInCurrentState = YES; 135 self.tabSwitchGridButton.hiddenInCurrentState = YES;
137 136
138 // Tools menu button. 137 // Tools menu button.
139 self.toolsMenuButton = [ToolbarButton toolsMenuToolbarButton]; 138 self.toolsMenuButton = [ToolbarButton toolsMenuToolbarButton];
140 self.toolsMenuButton.visibilityMask = ToolbarComponentVisibilityCompactWidth | 139 self.toolsMenuButton.visibilityMask = ToolbarComponentVisibilityCompactWidth |
141 ToolbarComponentVisibilityRegularWidth; 140 ToolbarComponentVisibilityRegularWidth;
142 [self.toolsMenuButton addTarget:nil 141 [self.toolsMenuButton addTarget:self
143 action:@selector(showToolsMenu:) 142 action:@selector(showToolsMenu:)
144 forControlEvents:UIControlEventTouchUpInside]; 143 forControlEvents:UIControlEventTouchUpInside];
145 144
146 // Share button. 145 // Share button.
147 self.shareButton = [ToolbarButton shareToolbarButton]; 146 self.shareButton = [ToolbarButton shareToolbarButton];
148 self.shareButton.visibilityMask = ToolbarComponentVisibilityRegularWidth; 147 self.shareButton.visibilityMask = ToolbarComponentVisibilityRegularWidth;
149 [self.shareButton addTarget:nil 148 [self.shareButton addTarget:self
150 action:@selector(showShareMenu:) 149 action:@selector(showShareMenu:)
151 forControlEvents:UIControlEventTouchUpInside]; 150 forControlEvents:UIControlEventTouchUpInside];
152 151
153 // Reload button. 152 // Reload button.
154 self.reloadButton = [ToolbarButton reloadToolbarButton]; 153 self.reloadButton = [ToolbarButton reloadToolbarButton];
155 self.reloadButton.visibilityMask = ToolbarComponentVisibilityRegularWidth; 154 self.reloadButton.visibilityMask = ToolbarComponentVisibilityRegularWidth;
156 [self.reloadButton addTarget:self 155 [self.reloadButton addTarget:self
157 action:@selector(reload:) 156 action:@selector(reload:)
158 forControlEvents:UIControlEventTouchUpInside]; 157 forControlEvents:UIControlEventTouchUpInside];
159 158
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 [self updateAllButtonsVisibility]; 199 [self updateAllButtonsVisibility];
201 } 200 }
202 201
203 #pragma mark - ZoomTransitionDelegate 202 #pragma mark - ZoomTransitionDelegate
204 203
205 - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view { 204 - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view {
206 return [view convertRect:self.toolsMenuButton.bounds 205 return [view convertRect:self.toolsMenuButton.bounds
207 fromView:self.toolsMenuButton]; 206 fromView:self.toolsMenuButton];
208 } 207 }
209 208
210 #pragma mark - ToolsMenuActions 209 #pragma mark - Private Methods
211 210
212 - (void)showToolsMenu:(id)sender { 211 - (void)showToolsMenu:(id)sender {
213 [self.dispatcher showToolsMenu]; 212 [self.dispatcher showToolsMenu];
214 } 213 }
215 214
216 - (void)closeToolsMenu:(id)sender { 215 - (void)closeToolsMenu:(id)sender {
217 [self.dispatcher closeToolsMenu]; 216 [self.dispatcher closeToolsMenu];
218 } 217 }
219 218
220 #pragma mark - NavigationActions 219 - (void)showShareMenu:(id)sender {
220 [self.dispatcher showShareMenu];
221 }
221 222
222 - (void)goBack:(id)sender { 223 - (void)goBack:(id)sender {
223 [self.dispatcher goBack]; 224 [self.dispatcher goBack];
224 } 225 }
225 226
226 - (void)goForward:(id)sender { 227 - (void)goForward:(id)sender {
227 [self.dispatcher goForward]; 228 [self.dispatcher goForward];
228 } 229 }
229 230
230 - (void)stop:(id)sender { 231 - (void)stop:(id)sender {
(...skipping 13 matching lines...) Expand all
244 } 245 }
245 246
246 - (void)tabStripDidHide:(id)sender { 247 - (void)tabStripDidHide:(id)sender {
247 self.tabSwitchStripButton.hiddenInCurrentState = NO; 248 self.tabSwitchStripButton.hiddenInCurrentState = NO;
248 self.tabSwitchGridButton.hiddenInCurrentState = YES; 249 self.tabSwitchGridButton.hiddenInCurrentState = YES;
249 [self updateAllButtonsVisibility]; 250 [self updateAllButtonsVisibility];
250 } 251 }
251 252
252 #pragma mark - Helper Methods 253 #pragma mark - Helper Methods
253 254
254 // PLACEHOLDER: We are not sure yet how WebState changes will affect Toolbar
255 // Buttons, but the VC will eventually set the flag on the ToolbarButton
256 // indicating it could or not it should be hidden. Once this is done we will
257 // update all the ToolbarButtons visibility.
258 // Updates all Buttons visibility to match any recent WebState change. 255 // Updates all Buttons visibility to match any recent WebState change.
259 - (void)updateAllButtonsVisibility { 256 - (void)updateAllButtonsVisibility {
260 for (UIView* view in self.stackView.arrangedSubviews) { 257 for (UIView* view in self.stackView.arrangedSubviews) {
261 if ([view isKindOfClass:[ToolbarButton class]]) { 258 if ([view isKindOfClass:[ToolbarButton class]]) {
262 ToolbarButton* button = base::mac::ObjCCastStrict<ToolbarButton>(view); 259 ToolbarButton* button = base::mac::ObjCCastStrict<ToolbarButton>(view);
263 [button setHiddenForCurrentStateAndSizeClass]; 260 [button setHiddenForCurrentStateAndSizeClass];
264 } 261 }
265 } 262 }
266 } 263 }
267 264
268 @end 265 @end
OLDNEW
« no previous file with comments | « ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.h ('k') | ios/clean/chrome/browser/ui/tools/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698