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

[iOS][Dark mode] Add dark mode colors when in incognito omnibox popup

This CL adds support for dark mode colors when in incognito mode.
Before, there were specific incognito colors. Now, in incognito mode,
the popup is forced into dark mode, so it will use the same colors.

Bug: 976662
Change-Id: I1ed6c506b284f82810b5a85686181fc04fe69d05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1738587Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Cr-Commit-Position: refs/heads/master@{#684304}
parent 96b23132
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ios/chrome/browser/ui/ui_feature_flags.h" #include "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/ui_util.h" #import "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/common/colors/UIColor+cr_semantic_colors.h" #import "ios/chrome/common/colors/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/colors/incognito_color_util.h"
#import "ios/chrome/common/colors/semantic_color_names.h" #import "ios/chrome/common/colors/semantic_color_names.h"
#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h" #import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
...@@ -24,26 +25,22 @@ ...@@ -24,26 +25,22 @@
namespace { namespace {
// The color of the main text of a suggest cell. // The color of the main text of a suggest cell.
UIColor* SuggestionTextColor() { UIColor* SuggestionTextColor(bool incognito) {
return [UIColor colorNamed:kTextPrimaryColor]; return color::IncognitoDynamicColor(
incognito, [UIColor colorNamed:kTextPrimaryColor],
[UIColor colorNamed:kTextPrimaryDarkColor]);
} }
// The color of the detail text of a suggest cell. // The color of the detail text of a suggest cell.
UIColor* SuggestionDetailTextColor() { UIColor* SuggestionDetailTextColor(bool incognito) {
return [UIColor colorNamed:kTextSecondaryColor]; return color::IncognitoDynamicColor(
} incognito, [UIColor colorNamed:kTextSecondaryColor],
// The color of the detail text of a suggest cell. [UIColor colorNamed:kTextSecondaryDarkColor]);
UIColor* SuggestionDetailTextColorIncognito() {
return [UIColor colorWithWhite:1 alpha:0.5];
} }
// The color of the text in the portion of a search suggestion that matches the // The color of the text in the portion of a search suggestion that matches the
// omnibox input text. // omnibox input text.
UIColor* DimColor() { UIColor* DimColor() {
return [UIColor colorWithWhite:(161 / 255.0) alpha:1.0]; return [UIColor colorWithWhite:(161 / 255.0) alpha:1.0];
} }
UIColor* SuggestionTextColorIncognito() {
return UIColor.whiteColor;
}
UIColor* DimColorIncognito() { UIColor* DimColorIncognito() {
return UIColor.whiteColor; return UIColor.whiteColor;
} }
...@@ -58,8 +55,6 @@ bool ShouldUseNewFormatting() { ...@@ -58,8 +55,6 @@ bool ShouldUseNewFormatting() {
@implementation AutocompleteMatchFormatter { @implementation AutocompleteMatchFormatter {
AutocompleteMatch _match; AutocompleteMatch _match;
} }
@synthesize incognito = _incognito;
@synthesize starred = _starred;
- (instancetype)initWithMatch:(const AutocompleteMatch&)match { - (instancetype)initWithMatch:(const AutocompleteMatch&)match {
self = [super init]; self = [super init];
...@@ -129,12 +124,9 @@ bool ShouldUseNewFormatting() { ...@@ -129,12 +124,9 @@ bool ShouldUseNewFormatting() {
// instead. // instead.
UIColor* suggestionDetailTextColor = nil; UIColor* suggestionDetailTextColor = nil;
if (_match.type == AutocompleteMatchType::SEARCH_SUGGEST_ENTITY) { if (_match.type == AutocompleteMatchType::SEARCH_SUGGEST_ENTITY) {
suggestionDetailTextColor = suggestionDetailTextColor = SuggestionTextColor(self.incognito);
_incognito ? SuggestionTextColorIncognito() : SuggestionTextColor();
} else { } else {
suggestionDetailTextColor = _incognito suggestionDetailTextColor = SuggestionDetailTextColor(self.incognito);
? SuggestionDetailTextColorIncognito()
: SuggestionDetailTextColor();
} }
DCHECK(suggestionDetailTextColor); DCHECK(suggestionDetailTextColor);
detailAttributedText = detailAttributedText =
...@@ -190,9 +182,8 @@ bool ShouldUseNewFormatting() { ...@@ -190,9 +182,8 @@ bool ShouldUseNewFormatting() {
} else { } else {
const ACMatchClassifications* textClassifications = const ACMatchClassifications* textClassifications =
!self.isURL ? &_match.contents_class : &_match.description_class; !self.isURL ? &_match.contents_class : &_match.description_class;
UIColor* suggestionTextColor = UIColor* suggestionTextColor = SuggestionTextColor(self.incognito);
_incognito ? SuggestionTextColorIncognito() : SuggestionTextColor(); UIColor* dimColor = self.incognito ? DimColorIncognito() : DimColor();
UIColor* dimColor = _incognito ? DimColorIncognito() : DimColor();
attributedText = [self attributedStringWithString:text attributedText = [self attributedStringWithString:text
classifications:textClassifications classifications:textClassifications
...@@ -317,13 +308,13 @@ bool ShouldUseNewFormatting() { ...@@ -317,13 +308,13 @@ bool ShouldUseNewFormatting() {
(int)type { (int)type {
DCHECK(!ShouldUseNewFormatting()); DCHECK(!ShouldUseNewFormatting());
// Answer types, sizes and colors specified at http://goto.google.com/ais_api. // Answer types, sizes and colors specified at http://goto.google.com/ais_api.
UIColor* detailTextColor = SuggestionDetailTextColor(self.incognito);
switch (type) { switch (type) {
case SuggestionAnswer::TOP_ALIGNED: case SuggestionAnswer::TOP_ALIGNED:
return @{ return @{
NSFontAttributeName : [UIFont systemFontOfSize:12], NSFontAttributeName : [UIFont systemFontOfSize:12],
NSBaselineOffsetAttributeName : @10.0f, NSBaselineOffsetAttributeName : @10.0f,
NSForegroundColorAttributeName : NSForegroundColorAttributeName : detailTextColor,
[UIColor colorNamed:kTextSecondaryColor],
}; };
case SuggestionAnswer::DESCRIPTION_POSITIVE: case SuggestionAnswer::DESCRIPTION_POSITIVE:
return @{ return @{
...@@ -343,33 +334,29 @@ bool ShouldUseNewFormatting() { ...@@ -343,33 +334,29 @@ bool ShouldUseNewFormatting() {
return @{ return @{
NSFontAttributeName : [UIFont systemFontOfSize:20], NSFontAttributeName : [UIFont systemFontOfSize:20],
NSForegroundColorAttributeName : NSForegroundColorAttributeName : detailTextColor,
[UIColor colorNamed:kTextSecondaryColor],
}; };
case SuggestionAnswer::ANSWER_TEXT_LARGE: case SuggestionAnswer::ANSWER_TEXT_LARGE:
return @{ return @{
NSFontAttributeName : [UIFont systemFontOfSize:24], NSFontAttributeName : [UIFont systemFontOfSize:24],
NSForegroundColorAttributeName : NSForegroundColorAttributeName : detailTextColor,
[UIColor colorNamed:kTextSecondaryColor],
}; };
case SuggestionAnswer::SUGGESTION_SECONDARY_TEXT_SMALL: case SuggestionAnswer::SUGGESTION_SECONDARY_TEXT_SMALL:
return @{ return @{
NSFontAttributeName : [UIFont systemFontOfSize:12], NSFontAttributeName : [UIFont systemFontOfSize:12],
NSForegroundColorAttributeName : NSForegroundColorAttributeName : detailTextColor,
[UIColor colorNamed:kTextSecondaryColor],
}; };
case SuggestionAnswer::SUGGESTION_SECONDARY_TEXT_MEDIUM: case SuggestionAnswer::SUGGESTION_SECONDARY_TEXT_MEDIUM:
return @{ return @{
NSFontAttributeName : [UIFont systemFontOfSize:14], NSFontAttributeName : [UIFont systemFontOfSize:14],
NSForegroundColorAttributeName : NSForegroundColorAttributeName : detailTextColor,
[UIColor colorNamed:kTextSecondaryColor],
}; };
case SuggestionAnswer::SUGGESTION: case SuggestionAnswer::SUGGESTION:
// Fall through. // Fall through.
default: default:
return @{ return @{
NSFontAttributeName : [UIFont systemFontOfSize:16], NSFontAttributeName : [UIFont systemFontOfSize:16],
NSForegroundColorAttributeName : [UIColor colorNamed:kTextPrimaryColor], NSForegroundColorAttributeName : SuggestionTextColor(self.incognito),
}; };
} }
} }
...@@ -391,8 +378,8 @@ bool ShouldUseNewFormatting() { ...@@ -391,8 +378,8 @@ bool ShouldUseNewFormatting() {
: [UIFontDescriptor : [UIFontDescriptor
preferredFontDescriptorWithTextStyle:UIFontTextStyleBody]; preferredFontDescriptorWithTextStyle:UIFontTextStyleBody];
UIColor* defaultColor = useDeemphasizedStyling UIColor* defaultColor = useDeemphasizedStyling
? [UIColor colorNamed:kTextSecondaryColor] ? SuggestionDetailTextColor(self.incognito)
: [UIColor colorNamed:kTextPrimaryColor]; : SuggestionTextColor(self.incognito);
switch (style) { switch (style) {
case SuggestionAnswer::TextStyle::NORMAL: case SuggestionAnswer::TextStyle::NORMAL:
......
...@@ -24,6 +24,7 @@ group("resources") { ...@@ -24,6 +24,7 @@ group("resources") {
":text_primary_color", ":text_primary_color",
":text_primary_dark_color", ":text_primary_dark_color",
":text_secondary_color", ":text_secondary_color",
":text_secondary_dark_color",
":textfield_background_color", ":textfield_background_color",
":textfield_background_dark_color", ":textfield_background_dark_color",
":textfield_placeholder_color", ":textfield_placeholder_color",
...@@ -139,6 +140,12 @@ colorset("text_secondary_color") { ...@@ -139,6 +140,12 @@ colorset("text_secondary_color") {
] ]
} }
colorset("text_secondary_dark_color") {
sources = [
"text_secondary_dark_color.colorset/Contents.json",
]
}
colorset("textfield_placeholder_color") { colorset("textfield_placeholder_color") {
sources = [ sources = [
"textfield_placeholder_color.colorset/Contents.json", "textfield_placeholder_color.colorset/Contents.json",
......
{
"info" : {
"version" : 1,
"author" : "xcode"
},
"colors" : [
{
"idiom" : "universal",
"color" : {
"color-space" : "display-p3",
"components" : {
"red" : "0x9A",
"alpha" : "1.000",
"blue" : "0xA6",
"green" : "0x9F"
}
}
}
]
}
...@@ -41,6 +41,7 @@ extern NSString* const kRedColor; ...@@ -41,6 +41,7 @@ extern NSString* const kRedColor;
extern NSString* const kBackgroundDarkColor; extern NSString* const kBackgroundDarkColor;
extern NSString* const kTableViewRowHighlightDarkColor; extern NSString* const kTableViewRowHighlightDarkColor;
extern NSString* const kTextPrimaryDarkColor; extern NSString* const kTextPrimaryDarkColor;
extern NSString* const kTextSecondaryDarkColor;
extern NSString* const kTextfieldBackgroundDarkColor; extern NSString* const kTextfieldBackgroundDarkColor;
extern NSString* const kTextfieldPlaceholderDarkColor; extern NSString* const kTextfieldPlaceholderDarkColor;
......
...@@ -32,6 +32,7 @@ NSString* const kBackgroundDarkColor = @"background_dark_color"; ...@@ -32,6 +32,7 @@ NSString* const kBackgroundDarkColor = @"background_dark_color";
NSString* const kTableViewRowHighlightDarkColor = NSString* const kTableViewRowHighlightDarkColor =
@"table_view_row_highlight_dark_color"; @"table_view_row_highlight_dark_color";
NSString* const kTextPrimaryDarkColor = @"text_primary_dark_color"; NSString* const kTextPrimaryDarkColor = @"text_primary_dark_color";
NSString* const kTextSecondaryDarkColor = @"text_secondary_dark_color";
NSString* const kTextfieldBackgroundDarkColor = NSString* const kTextfieldBackgroundDarkColor =
@"textfield_background_dark_color"; @"textfield_background_dark_color";
NSString* const kTextfieldPlaceholderDarkColor = NSString* const kTextfieldPlaceholderDarkColor =
......
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