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 #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/chrome/browser/ui/uikit_ui_util.h" | 8 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
9 #import "ios/clean/chrome/browser/ui/actions/tab_strip_actions.h" | |
10 #import "ios/clean/chrome/browser/ui/commands/navigation_commands.h" | 9 #import "ios/clean/chrome/browser/ui/commands/navigation_commands.h" |
11 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" | 10 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" |
11 #import "ios/clean/chrome/browser/ui/commands/tab_strip_commands.h" | |
12 #import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h" | 12 #import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h" |
13 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_button+factory.h" | 13 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_button+factory.h" |
14 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_component_options.h" | 14 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_component_options.h" |
15 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_constants.h" | 15 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_constants.h" |
16 #import "ios/third_party/material_components_ios/src/components/ProgressView/src /MaterialProgressView.h" | 16 #import "ios/third_party/material_components_ios/src/components/ProgressView/src /MaterialProgressView.h" |
17 | 17 |
18 #if !defined(__has_feature) || !__has_feature(objc_arc) | 18 #if !defined(__has_feature) || !__has_feature(objc_arc) |
19 #error "This file requires ARC support." | 19 #error "This file requires ARC support." |
20 #endif | 20 #endif |
21 | 21 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 forControlEvents:UIControlEventTouchUpInside]; | 152 forControlEvents:UIControlEventTouchUpInside]; |
153 | 153 |
154 // Tab switcher Strip button. | 154 // Tab switcher Strip button. |
155 self.tabSwitchStripButton = [ToolbarButton tabSwitcherStripToolbarButton]; | 155 self.tabSwitchStripButton = [ToolbarButton tabSwitcherStripToolbarButton]; |
156 self.tabSwitchStripButton.visibilityMask = | 156 self.tabSwitchStripButton.visibilityMask = |
157 ToolbarComponentVisibilityCompactWidth | | 157 ToolbarComponentVisibilityCompactWidth | |
158 ToolbarComponentVisibilityRegularWidth; | 158 ToolbarComponentVisibilityRegularWidth; |
159 [buttonConstraints | 159 [buttonConstraints |
160 addObject:[self.tabSwitchStripButton.widthAnchor | 160 addObject:[self.tabSwitchStripButton.widthAnchor |
161 constraintEqualToConstant:kToolbarButtonWidth]]; | 161 constraintEqualToConstant:kToolbarButtonWidth]]; |
162 [self.tabSwitchStripButton addTarget:nil | 162 [self.tabSwitchStripButton addTarget:self |
163 action:@selector(showTabStrip:) | 163 action:@selector(showTabStrip:) |
164 forControlEvents:UIControlEventTouchUpInside]; | 164 forControlEvents:UIControlEventTouchUpInside]; |
165 [self.tabSwitchStripButton | 165 [self.tabSwitchStripButton |
166 setTitleColor:UIColorFromRGB(kToolbarButtonTitleNormalColor) | 166 setTitleColor:UIColorFromRGB(kToolbarButtonTitleNormalColor) |
167 forState:UIControlStateNormal]; | 167 forState:UIControlStateNormal]; |
168 [self.tabSwitchStripButton | 168 [self.tabSwitchStripButton |
169 setTitleColor:UIColorFromRGB(kToolbarButtonTitleHighlightedColor) | 169 setTitleColor:UIColorFromRGB(kToolbarButtonTitleHighlightedColor) |
170 forState:UIControlStateHighlighted]; | 170 forState:UIControlStateHighlighted]; |
171 | 171 |
172 // Tab switcher Grid button. | 172 // Tab switcher Grid button. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 [self.tabSwitchStripButton setAccessibilityValue:tabStripButtonValue]; | 368 [self.tabSwitchStripButton setAccessibilityValue:tabStripButtonValue]; |
369 } | 369 } |
370 | 370 |
371 #pragma mark - ZoomTransitionDelegate | 371 #pragma mark - ZoomTransitionDelegate |
372 | 372 |
373 - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view { | 373 - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view { |
374 return [view convertRect:self.toolsMenuButton.bounds | 374 return [view convertRect:self.toolsMenuButton.bounds |
375 fromView:self.toolsMenuButton]; | 375 fromView:self.toolsMenuButton]; |
376 } | 376 } |
377 | 377 |
378 #pragma mark - Private Methods | 378 #pragma mark - Commands |
379 | 379 |
380 - (void)showToolsMenu:(id)sender { | 380 - (void)showToolsMenu:(id)sender { |
381 [self.dispatcher showToolsMenu]; | 381 [self.dispatcher showToolsMenu]; |
382 } | 382 } |
383 | 383 |
384 - (void)closeToolsMenu:(id)sender { | 384 - (void)closeToolsMenu:(id)sender { |
385 [self.dispatcher closeToolsMenu]; | 385 [self.dispatcher closeToolsMenu]; |
386 } | 386 } |
387 | 387 |
388 - (void)showShareMenu:(id)sender { | 388 - (void)showShareMenu:(id)sender { |
389 [self.dispatcher showShareMenu]; | 389 [self.dispatcher showShareMenu]; |
390 } | 390 } |
391 | 391 |
392 - (void)goBack:(id)sender { | 392 - (void)goBack:(id)sender { |
393 [self.dispatcher goBack]; | 393 [self.dispatcher goBack]; |
394 } | 394 } |
395 | 395 |
396 - (void)goForward:(id)sender { | 396 - (void)goForward:(id)sender { |
397 [self.dispatcher goForward]; | 397 [self.dispatcher goForward]; |
398 } | 398 } |
399 | 399 |
400 - (void)stop:(id)sender { | 400 - (void)stop:(id)sender { |
401 [self.dispatcher stopLoadingPage]; | 401 [self.dispatcher stopLoadingPage]; |
402 } | 402 } |
403 | 403 |
404 - (void)reload:(id)sender { | 404 - (void)reload:(id)sender { |
405 [self.dispatcher reloadPage]; | 405 [self.dispatcher reloadPage]; |
406 } | 406 } |
407 | 407 |
408 - (void)showTabStrip:(id)sender { | |
marq (ping after 24h)
2017/06/15 07:35:35
No change, but this block of boilerplate makes me
sczs
2017/06/15 19:56:17
I agree, might was well change it on this CL. Sinc
| |
409 [self.dispatcher showTabStrip]; | |
410 } | |
411 | |
408 - (void)showTabGrid:(id)sender { | 412 - (void)showTabGrid:(id)sender { |
409 [self.dispatcher showTabGrid]; | 413 [self.dispatcher showTabGrid]; |
410 } | 414 } |
411 | 415 |
412 #pragma mark - Helper Methods | 416 #pragma mark - Helper Methods |
413 | 417 |
414 // Updates all Buttons visibility to match any recent WebState change. | 418 // Updates all Buttons visibility to match any recent WebState change. |
415 - (void)updateAllButtonsVisibility { | 419 - (void)updateAllButtonsVisibility { |
416 for (UIView* view in self.stackView.arrangedSubviews) { | 420 for (UIView* view in self.stackView.arrangedSubviews) { |
417 if ([view isKindOfClass:[ToolbarButton class]]) { | 421 if ([view isKindOfClass:[ToolbarButton class]]) { |
418 ToolbarButton* button = base::mac::ObjCCastStrict<ToolbarButton>(view); | 422 ToolbarButton* button = base::mac::ObjCCastStrict<ToolbarButton>(view); |
419 [button setHiddenForCurrentStateAndSizeClass]; | 423 [button setHiddenForCurrentStateAndSizeClass]; |
420 } | 424 } |
421 } | 425 } |
422 } | 426 } |
423 | 427 |
424 // Sets the priority for an array of constraints and activates them. | 428 // Sets the priority for an array of constraints and activates them. |
425 - (void)activateConstraints:(NSArray*)constraintsArray | 429 - (void)activateConstraints:(NSArray*)constraintsArray |
426 withPriority:(UILayoutPriority)priority { | 430 withPriority:(UILayoutPriority)priority { |
427 for (NSLayoutConstraint* constraint in constraintsArray) { | 431 for (NSLayoutConstraint* constraint in constraintsArray) { |
428 constraint.priority = priority; | 432 constraint.priority = priority; |
429 } | 433 } |
430 [NSLayoutConstraint activateConstraints:constraintsArray]; | 434 [NSLayoutConstraint activateConstraints:constraintsArray]; |
431 } | 435 } |
432 | 436 |
433 @end | 437 @end |
OLD | NEW |