Commit d2eba608 authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS] Add dark mode row highlight colors to the omnibox popup

The code in OmniboxPopupRow wasn't actually doing anything. The default
UIKit method of row highlighting is to insert a view in the table
cell's subviews at index 0, so the cell's background color is always
covered. Setting selectedBackgroundView is the modern way of
controlling this color.

Bug: 976662
Change-Id: If0d18fc3edc82f6cb2eda0324dabe23e9ba9a085
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1735164
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#684276}
parent cc779af3
......@@ -55,6 +55,10 @@ const CGFloat kLeadingPaddingIpadCompact = 71;
if (self) {
self.isAccessibilityElement = YES;
self.backgroundColor = UIColor.clearColor;
self.selectedBackgroundView = [[UIView alloc] initWithFrame:CGRectZero];
self.selectedBackgroundView.backgroundColor = color::IncognitoDynamicColor(
_incognito, [UIColor colorNamed:kTableViewRowHighlightColor],
[UIColor colorNamed:kTableViewRowHighlightDarkColor]);
_incognito = incognito;
......@@ -143,27 +147,6 @@ const CGFloat kLeadingPaddingIpadCompact = 71;
_imageView.frame = frame;
}
- (void)updateHighlightBackground:(BOOL)highlighted {
// Set the background color to match the color of selected table view cells
// when their selection style is UITableViewCellSelectionStyleGray.
if (highlighted) {
self.backgroundColor = _incognito ? [UIColor colorWithWhite:1 alpha:0.1]
: [UIColor colorWithWhite:0 alpha:0.05];
} else {
self.backgroundColor = [UIColor clearColor];
}
}
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
[super setHighlighted:highlighted animated:animated];
[self updateHighlightBackground:highlighted];
}
- (void)setHighlighted:(BOOL)highlighted {
[super setHighlighted:highlighted];
[self updateHighlightBackground:highlighted];
}
- (void)setTabMatch:(BOOL)tabMatch {
_tabMatch = tabMatch;
[self updateTrailingButtonImages];
......
......@@ -66,6 +66,11 @@ NSString* const kOmniboxPopupRowSwitchTabAccessibilityIdentifier =
reuseIdentifier:(NSString*)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.selectedBackgroundView = [[UIView alloc] initWithFrame:CGRectZero];
self.selectedBackgroundView.backgroundColor = color::IncognitoDynamicColor(
_incognito, [UIColor colorNamed:kTableViewRowHighlightColor],
[UIColor colorNamed:kTableViewRowHighlightDarkColor]);
_textTruncatingLabel =
[[OmniboxPopupTruncatingLabel alloc] initWithFrame:CGRectZero];
_textTruncatingLabel.translatesAutoresizingMaskIntoConstraints = NO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment