Skip to content

Commit

Permalink
[iOS] Fix background color for IdentityButtonControl
Browse files Browse the repository at this point in the history
Related to:
crrev.com/c/3067351

Fixed: 1238293
Change-Id: I2b5ba57703e672e7180b2cc279c7276a651698e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3220793
Commit-Queue: Jérôme <jlebel@chromium.org>
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Auto-Submit: Jérôme <jlebel@chromium.org>
Reviewed-by: Nohemi Fernandez <fernandex@chromium.org>
Cr-Commit-Position: refs/heads/main@{#931063}
  • Loading branch information
jlebel authored and Chromium LUCI CQ committed Oct 13, 2021
1 parent 68e3a19 commit 659a582
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ - (void)viewDidLoad {
// Add IdentityButtonControl for the default identity.
self.identityButtonControl =
[[IdentityButtonControl alloc] initWithFrame:CGRectZero];
self.identityButtonControl.backgroundColor =
[UIColor colorNamed:kGroupedSecondaryBackgroundColor];
self.identityButtonControl.arrowDirection = IdentityButtonControlArrowRight;
self.identityButtonControl.identityViewStyle = IdentityViewStyleConsistency;
[self.identityButtonControl addTarget:self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
if (self) {
self.accessibilityIdentifier = kIdentityButtonControlIdentifier;
self.layer.cornerRadius = kIdentityButtonControlRadius;
self.backgroundColor = [UIColor colorNamed:kSecondaryBackgroundColor];
[self setUnhighlightedBackgroundColor];

// Adding view elements inside.
// Down or right arrow.
Expand Down Expand Up @@ -116,6 +116,8 @@ - (void)setArrowDirection:(IdentityButtonControlArrowDirection)arrowDirection {

- (void)setIdentityViewStyle:(IdentityViewStyle)style {
self.identityView.style = style;
if (!self.highlighted)
[self setUnhighlightedBackgroundColor];
}

- (IdentityViewStyle)identityViewStyle {
Expand All @@ -124,6 +126,21 @@ - (IdentityViewStyle)identityViewStyle {

#pragma mark - Private

// Sets the background color when not highlighted.
- (void)setUnhighlightedBackgroundColor {
DCHECK(!self.highlighted);
switch (self.identityView.style) {
case IdentityViewStyleDefault:
case IdentityViewStyleIdentityChooser:
self.backgroundColor = [UIColor colorNamed:kSecondaryBackgroundColor];
break;
case IdentityViewStyleConsistency:
self.backgroundColor =
[UIColor colorNamed:kGroupedSecondaryBackgroundColor];
break;
}
}

- (CGPoint)locationFromTouches:(NSSet*)touches {
UITouch* touch = [touches anyObject];
return [touch locationInView:self];
Expand Down Expand Up @@ -153,9 +170,8 @@ - (void)setHighlighted:(BOOL)highlighted {

if (highlighted) {
self.backgroundColor = [UIColor colorNamed:kGrey300Color];
} else if (self.identityViewStyle != IdentityViewStyleConsistency) {
// Background color for the consistency web sign-in is reset manually.
self.backgroundColor = [UIColor colorNamed:kSecondaryBackgroundColor];
} else {
[self setUnhighlightedBackgroundColor];
}
}

Expand Down

0 comments on commit 659a582

Please sign in to comment.