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

Unified Diff: ios/chrome/browser/ui/fancy_ui/colored_button.mm

Issue 2934463002: [iOS] Add experimental new keyboard accessory view. (Closed)
Patch Set: Rebased. Created 3 years, 6 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/chrome/browser/ui/fancy_ui/colored_button.h ('k') | ios/chrome/browser/ui/fancy_ui/tinted_button.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/fancy_ui/colored_button.mm
diff --git a/ios/chrome/browser/ui/fancy_ui/tinted_button.mm b/ios/chrome/browser/ui/fancy_ui/colored_button.mm
similarity index 54%
rename from ios/chrome/browser/ui/fancy_ui/tinted_button.mm
rename to ios/chrome/browser/ui/fancy_ui/colored_button.mm
index b0c06a608926d0828dde8e096bd77eeb9b319fb9..e5daa5455d25e12ff7572f78b2ab7bef8ac092a2 100644
--- a/ios/chrome/browser/ui/fancy_ui/tinted_button.mm
+++ b/ios/chrome/browser/ui/fancy_ui/colored_button.mm
@@ -2,23 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ios/chrome/browser/ui/fancy_ui/tinted_button.h"
+#include "ios/chrome/browser/ui/fancy_ui/colored_button.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
-@interface TintedButton () {
+@interface ColoredButton () {
UIColor* normalStateTint_;
UIColor* highlightedTint_;
+ UIColor* normalStateBackgroundColor_;
+ UIColor* highlightedBackgroundColor_;
}
// Makes the button's tint color reflect its current state.
- (void)updateTint;
+// Makes the button's background color reflect its current state.
+- (void)updateBackgroundColor;
+
@end
-@implementation TintedButton
+@implementation ColoredButton
- (void)setTintColor:(UIColor*)color forState:(UIControlState)state {
switch (state) {
@@ -39,11 +44,27 @@ - (void)setTintColor:(UIColor*)color forState:(UIControlState)state {
[self updateTint];
}
+- (void)setBackgroundColor:(UIColor*)color forState:(UIControlState)state {
+ switch (state) {
+ case UIControlStateNormal:
+ normalStateBackgroundColor_ = [color copy];
+ break;
+ case UIControlStateHighlighted:
+ highlightedBackgroundColor_ = [color copy];
+ break;
+ default:
+ return;
+ }
+
+ [self updateBackgroundColor];
+}
+
#pragma mark - UIControl
- (void)setHighlighted:(BOOL)highlighted {
[super setHighlighted:highlighted];
[self updateTint];
+ [self updateBackgroundColor];
}
#pragma mark - Private
@@ -64,4 +85,20 @@ - (void)updateTint {
self.tintColor = newTint;
}
+- (void)updateBackgroundColor {
+ UIColor* newBackgroundColor = nil;
+ switch (self.state) {
+ case UIControlStateNormal:
+ newBackgroundColor = normalStateBackgroundColor_;
+ break;
+ case UIControlStateHighlighted:
+ newBackgroundColor = highlightedBackgroundColor_;
+ break;
+ default:
+ newBackgroundColor = normalStateBackgroundColor_;
+ break;
+ }
+ self.backgroundColor = newBackgroundColor;
+}
+
@end
« no previous file with comments | « ios/chrome/browser/ui/fancy_ui/colored_button.h ('k') | ios/chrome/browser/ui/fancy_ui/tinted_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698