| 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
|
|
|