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

Unified Diff: ios/chrome/browser/ui/toolbar/toolbar_tools_menu_button.mm

Issue 2588733002: Upstream Chrome on iOS source code [9/11]. (Closed)
Patch Set: Created 4 years 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
Index: ios/chrome/browser/ui/toolbar/toolbar_tools_menu_button.mm
diff --git a/ios/chrome/browser/ui/toolbar/toolbar_tools_menu_button.mm b/ios/chrome/browser/ui/toolbar/toolbar_tools_menu_button.mm
new file mode 100644
index 0000000000000000000000000000000000000000..de0a523a038d7d80bd5906b9a8cd9b9f68023fe8
--- /dev/null
+++ b/ios/chrome/browser/ui/toolbar/toolbar_tools_menu_button.mm
@@ -0,0 +1,68 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/browser/ui/toolbar/toolbar_tools_menu_button.h"
+
+#include "ios/chrome/browser/ui/toolbar/toolbar_button_tints.h"
+#import "ios/chrome/browser/ui/uikit_ui_util.h"
+
+@interface ToolbarToolsMenuButton ()
+// Updates the tint configuration based on the button's situation, e.g. whether
+// the tools menu is visible or not.
+- (void)updateTintOfButton;
+@end
+
+@interface ToolbarToolsMenuButton () {
+ // The style of the toolbar the button is in.
+ ToolbarControllerStyle style_;
+ // Whether the tools menu is visible.
+ BOOL toolsMenuVisible_;
+ // Whether the reading list contains unread items.
+ BOOL readingListContainsUnreadItems_;
+}
+@end
+
+@implementation ToolbarToolsMenuButton
+
+- (instancetype)initWithFrame:(CGRect)frame
+ style:(ToolbarControllerStyle)style {
+ if (self = [super initWithFrame:frame]) {
+ style_ = style;
+
+ [self setTintColor:toolbar::NormalButtonTint(style_)
+ forState:UIControlStateNormal];
+ [self setTintColor:toolbar::HighlighButtonTint(style_)
+ forState:UIControlStateHighlighted];
+
+ [self setImageEdgeInsets:UIEdgeInsetsMakeDirected(0, -3, 0, 0)];
+ UIImage* image = [UIImage imageNamed:@"toolbar_tools"];
+ image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
+ [self setImage:image forState:UIControlStateNormal];
+ }
+ return self;
+}
+
+- (void)setToolsMenuIsVisible:(BOOL)toolsMenuVisible {
+ toolsMenuVisible_ = toolsMenuVisible;
+ [self updateTintOfButton];
+}
+
+- (void)setReadingListContainsUnreadItems:(BOOL)readingListContainsUnreadItems {
+ readingListContainsUnreadItems_ = readingListContainsUnreadItems;
+ [self updateTintOfButton];
+}
+
+#pragma mark - Private
+
+- (void)updateTintOfButton {
+ if (toolsMenuVisible_ || readingListContainsUnreadItems_) {
+ [self setTintColor:toolbar::HighlighButtonTint(style_)
+ forState:UIControlStateNormal];
+ } else {
+ [self setTintColor:toolbar::NormalButtonTint(style_)
+ forState:UIControlStateNormal];
+ }
+}
+
+@end
« no previous file with comments | « ios/chrome/browser/ui/toolbar/toolbar_tools_menu_button.h ('k') | ios/chrome/browser/ui/toolbar/toolbar_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698