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

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

Issue 2908623004: [ios clean] Toolbar displays total number of tabs. (Closed)
Patch Set: CL Feedback and changes Font to bold. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/clean/chrome/browser/ui/toolbar/toolbar_mediator_unittest.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.mm
diff --git a/ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.mm b/ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.mm
index 39b3093c166d74ef2af040f31d18ac1793c18269..758c4fcd684e9d81684363db8363cf06ac2414d5 100644
--- a/ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.mm
+++ b/ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.mm
@@ -5,6 +5,7 @@
#import "ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.h"
#import "base/mac/foundation_util.h"
+#import "ios/chrome/browser/ui/uikit_ui_util.h"
#import "ios/clean/chrome/browser/ui/actions/tab_strip_actions.h"
#import "ios/clean/chrome/browser/ui/commands/navigation_commands.h"
#import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h"
@@ -60,8 +61,7 @@
#pragma mark - View lifecyle
- (void)viewDidLoad {
- self.view.backgroundColor =
- [UIColor colorWithWhite:kToolbarBackgroundBrightness alpha:1.0];
+ self.view.backgroundColor = UIColorFromRGB(kToolbarBackgroundColor);
[self addChildViewController:self.locationBarViewController
toSubview:self.locationBarContainer];
[self setUpToolbarStackView];
@@ -162,6 +162,12 @@
[self.tabSwitchStripButton addTarget:nil
action:@selector(showTabStrip:)
forControlEvents:UIControlEventTouchUpInside];
+ [self.tabSwitchStripButton
+ setTitleColor:UIColorFromRGB(kToolbarButtonTitleNormalColor)
+ forState:UIControlStateNormal];
+ [self.tabSwitchStripButton
+ setTitleColor:UIColorFromRGB(kToolbarButtonTitleHighlightedColor)
+ forState:UIControlStateHighlighted];
// Tab switcher Grid button.
self.tabSwitchGridButton = [ToolbarButton tabSwitcherGridToolbarButton];
@@ -217,7 +223,7 @@
action:@selector(stop:)
forControlEvents:UIControlEventTouchUpInside];
- // // Set the buttons constraints priority to UILayoutPriorityDefaultHigh so
+ // Set the buttons constraints priority to UILayoutPriorityDefaultHigh so
marq (ping after 24h) 2017/05/30 09:47:04 Super nit: "button constraint priority" or "button
sczs 2017/05/30 18:14:12 Done. Thanks for pointing these comments mistakes
marq (ping after 24h) 2017/05/31 09:47:26 No problem; I know I can be picky about language (
sczs 2017/05/31 23:19:07 Please keep doing that, is the best way to learn :
// these are not broken when being hidden by the StackView.
[self activateConstraints:buttonConstraints
withPriority:UILayoutPriorityDefaultHigh];
@@ -229,8 +235,7 @@
locationBarContainer.backgroundColor = [UIColor whiteColor];
locationBarContainer.layer.borderWidth = kLocationBarBorderWidth;
locationBarContainer.layer.borderColor =
- [UIColor colorWithWhite:kLocationBarBorderColorBrightness alpha:1.0]
- .CGColor;
+ UIColorFromRGB(kLocationBarBorderColor).CGColor;
locationBarContainer.layer.shadowRadius = kLocationBarShadowRadius;
locationBarContainer.layer.shadowOpacity = kLocationBarShadowOpacity;
locationBarContainer.layer.shadowOffset = CGSizeMake(0.0f, 0.5f);
@@ -329,6 +334,38 @@
[self updateAllButtonsVisibility];
}
+- (void)setTabCount:(int)tabCount {
+ // Return if tabSwitchStripButton wasn't initialized.
+ if (!self.tabSwitchStripButton)
+ return;
+
+ // Update the text shown in the |stackButton_|. Note that the button's title
marq (ping after 24h) 2017/05/30 09:47:04 Update the comments and variable names to match th
sczs 2017/05/30 18:14:12 Done.
+ // may be empty or contain an easter egg, but the accessibility value will
+ // always be equal to |tabCount|.
+ NSString* stackButtonValue = [NSString stringWithFormat:@"%d", tabCount];
+ NSString* stackButtonTitle;
+ if (tabCount <= 0) {
+ stackButtonTitle = @"";
+ } else if (tabCount > kShowTabStripButtonMaxTabCount) {
+ stackButtonTitle = @":)";
+ [[self.tabSwitchStripButton titleLabel]
+ setFont:[self fontForSize:kFontSizeFewerThanTenTabs]];
+ } else {
+ stackButtonTitle = stackButtonValue;
+ if (tabCount < 10) {
+ [[self.tabSwitchStripButton titleLabel]
+ setFont:[self fontForSize:kFontSizeFewerThanTenTabs]];
+ } else {
+ [[self.tabSwitchStripButton titleLabel]
+ setFont:[self fontForSize:kFontSizeTenTabsOrMore]];
+ }
+ }
+
+ [self.tabSwitchStripButton setTitle:stackButtonTitle
+ forState:UIControlStateNormal];
+ [self.tabSwitchStripButton setAccessibilityValue:stackButtonValue];
+}
+
#pragma mark - ZoomTransitionDelegate
- (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view {
@@ -391,4 +428,8 @@
[NSLayoutConstraint activateConstraints:constraintsArray];
}
+- (UIFont*)fontForSize:(int)size {
marq (ping after 24h) 2017/05/30 09:47:04 What's the utility in this method?
sczs 2017/05/30 18:14:12 I guess the only utility is to change the font siz
marq (ping after 24h) 2017/05/31 09:47:26 Yeah, I think it's alway worth asking if utility m
sczs 2017/05/31 23:19:07 Acknowledged.
+ return [UIFont boldSystemFontOfSize:size];
+}
+
@end
« no previous file with comments | « ios/clean/chrome/browser/ui/toolbar/toolbar_mediator_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698