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

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

Issue 2908623004: [ios clean] Toolbar displays total number of tabs. (Closed)
Patch Set: Minor comment changes. Created 3 years, 7 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/chrome/browser/ui/uikit_ui_util.h"
8 #import "ios/clean/chrome/browser/ui/actions/tab_strip_actions.h" 9 #import "ios/clean/chrome/browser/ui/actions/tab_strip_actions.h"
9 #import "ios/clean/chrome/browser/ui/commands/navigation_commands.h" 10 #import "ios/clean/chrome/browser/ui/commands/navigation_commands.h"
10 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" 11 #import "ios/clean/chrome/browser/ui/commands/tab_grid_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+factory.h" 13 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_button+factory.h"
13 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_component_options.h" 14 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_component_options.h"
14 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_constants.h" 15 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_constants.h"
15 #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"
16 17
17 #if !defined(__has_feature) || !__has_feature(objc_arc) 18 #if !defined(__has_feature) || !__has_feature(objc_arc)
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 self.tabSwitchStripButton = [ToolbarButton tabSwitcherStripToolbarButton]; 156 self.tabSwitchStripButton = [ToolbarButton tabSwitcherStripToolbarButton];
156 self.tabSwitchStripButton.visibilityMask = 157 self.tabSwitchStripButton.visibilityMask =
157 ToolbarComponentVisibilityCompactWidth | 158 ToolbarComponentVisibilityCompactWidth |
158 ToolbarComponentVisibilityRegularWidth; 159 ToolbarComponentVisibilityRegularWidth;
159 [buttonConstraints 160 [buttonConstraints
160 addObject:[self.tabSwitchStripButton.widthAnchor 161 addObject:[self.tabSwitchStripButton.widthAnchor
161 constraintEqualToConstant:kToolbarButtonWidth]]; 162 constraintEqualToConstant:kToolbarButtonWidth]];
162 [self.tabSwitchStripButton addTarget:nil 163 [self.tabSwitchStripButton addTarget:nil
163 action:@selector(showTabStrip:) 164 action:@selector(showTabStrip:)
164 forControlEvents:UIControlEventTouchUpInside]; 165 forControlEvents:UIControlEventTouchUpInside];
166 [self.tabSwitchStripButton
167 setTitleColor:[UIColor colorWithWhite:kToolbarButtonTitleNormalColor
168 alpha:1.0]
169 forState:UIControlStateNormal];
170 [self.tabSwitchStripButton
171 setTitleColor:UIColorFromRGB(kToolbarButtonTitleHighlightedColor, 1.0)
marq (ping after 24h) 2017/05/29 11:04:37 I think you can omit the alpha (1.0) parameter if
sczs 2017/05/30 00:18:21 Done.
172 forState:UIControlStateHighlighted];
165 173
166 // Tab switcher Grid button. 174 // Tab switcher Grid button.
167 self.tabSwitchGridButton = [ToolbarButton tabSwitcherGridToolbarButton]; 175 self.tabSwitchGridButton = [ToolbarButton tabSwitcherGridToolbarButton];
168 self.tabSwitchGridButton.visibilityMask = 176 self.tabSwitchGridButton.visibilityMask =
169 ToolbarComponentVisibilityCompactWidth | 177 ToolbarComponentVisibilityCompactWidth |
170 ToolbarComponentVisibilityRegularWidth; 178 ToolbarComponentVisibilityRegularWidth;
171 [buttonConstraints 179 [buttonConstraints
172 addObject:[self.tabSwitchGridButton.widthAnchor 180 addObject:[self.tabSwitchGridButton.widthAnchor
173 constraintEqualToConstant:kToolbarButtonWidth]]; 181 constraintEqualToConstant:kToolbarButtonWidth]];
174 [self.tabSwitchGridButton addTarget:self 182 [self.tabSwitchGridButton addTarget:self
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 self.reloadButton.hiddenInCurrentState = isLoading; 324 self.reloadButton.hiddenInCurrentState = isLoading;
317 self.stopButton.hiddenInCurrentState = !isLoading; 325 self.stopButton.hiddenInCurrentState = !isLoading;
318 [self.progressBar setHidden:!isLoading animated:YES completion:nil]; 326 [self.progressBar setHidden:!isLoading animated:YES completion:nil];
319 [self updateAllButtonsVisibility]; 327 [self updateAllButtonsVisibility];
320 } 328 }
321 329
322 - (void)setLoadingProgress:(double)progress { 330 - (void)setLoadingProgress:(double)progress {
323 [self.progressBar setProgress:progress animated:YES completion:nil]; 331 [self.progressBar setProgress:progress animated:YES completion:nil];
324 } 332 }
325 333
334 - (void)setNumberOfTabs:(int)numberOfTabs {
335 [self.tabSwitchStripButton
336 setTitle:[NSString stringWithFormat:@"%d", numberOfTabs]
marq (ping after 24h) 2017/05/29 11:04:37 Duplicate or refactor the logic from [ToolbarContr
sczs 2017/05/30 00:18:21 Done.
337 forState:UIControlStateNormal];
338 }
339
326 #pragma mark - ZoomTransitionDelegate 340 #pragma mark - ZoomTransitionDelegate
327 341
328 - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view { 342 - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view {
329 return [view convertRect:self.toolsMenuButton.bounds 343 return [view convertRect:self.toolsMenuButton.bounds
330 fromView:self.toolsMenuButton]; 344 fromView:self.toolsMenuButton];
331 } 345 }
332 346
333 #pragma mark - Private Methods 347 #pragma mark - Private Methods
334 348
335 - (void)showToolsMenu:(id)sender { 349 - (void)showToolsMenu:(id)sender {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // Sets the priority for an array of constraints and activates them. 407 // Sets the priority for an array of constraints and activates them.
394 - (void)activateConstraints:(NSArray*)constraintsArray 408 - (void)activateConstraints:(NSArray*)constraintsArray
395 withPriority:(UILayoutPriority)priority { 409 withPriority:(UILayoutPriority)priority {
396 for (NSLayoutConstraint* constraint in constraintsArray) { 410 for (NSLayoutConstraint* constraint in constraintsArray) {
397 constraint.priority = priority; 411 constraint.priority = priority;
398 } 412 }
399 [NSLayoutConstraint activateConstraints:constraintsArray]; 413 [NSLayoutConstraint activateConstraints:constraintsArray];
400 } 414 }
401 415
402 @end 416 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698