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 @@
#include "ios/chrome/browser/ui/ui_feature_flags.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/incognito_color_util.h"
#import "ios/chrome/common/colors/semantic_color_names.h"
#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
......@@ -24,26 +25,22 @@
namespace {
// The color of the main text of a suggest cell.
UIColor* SuggestionTextColor() {
return [UIColor colorNamed:kTextPrimaryColor];
UIColor* SuggestionTextColor(bool incognito) {
return color::IncognitoDynamicColor(
incognito, [UIColor colorNamed:kTextPrimaryColor],
[UIColor colorNamed:kTextPrimaryDarkColor]);
}
// The color of the detail text of a suggest cell.
UIColor* SuggestionDetailTextColor() {
return [UIColor colorNamed:kTextSecondaryColor];
}
// The color of the detail text of a suggest cell.
UIColor* SuggestionDetailTextColorIncognito() {
return [UIColor colorWithWhite:1 alpha:0.5];
UIColor* SuggestionDetailTextColor(bool incognito) {
return color::IncognitoDynamicColor(
incognito, [UIColor colorNamed:kTextSecondaryColor],
[UIColor colorNamed:kTextSecondaryDarkColor]);
}
// The color of the text in the portion of a search suggestion that matches the
// omnibox input text.
UIColor* DimColor() {
return [UIColor colorWithWhite:(161 / 255.0) alpha:1.0];
}
UIColor* SuggestionTextColorIncognito() {
return UIColor.whiteColor;
}
UIColor* DimColorIncognito() {
return UIColor.whiteColor;
}
......@@ -58,8 +55,6 @@ bool ShouldUseNewFormatting() {
@implementation AutocompleteMatchFormatter {
AutocompleteMatch _match;
}
@synthesize incognito = _incognito;
@synthesize starred = _starred;
- (instancetype)initWithMatch:(const AutocompleteMatch&)match {
self = [super init];
......@@ -129,12 +124,9 @@ bool ShouldUseNewFormatting() {
// instead.
UIColor* suggestionDetailTextColor = nil;
if (_match.type == AutocompleteMatchType::SEARCH_SUGGEST_ENTITY) {
suggestionDetailTextColor =
_incognito ? SuggestionTextColorIncognito() : SuggestionTextColor();
suggestionDetailTextColor = SuggestionTextColor(self.incognito);
} else {
suggestionDetailTextColor = _incognito
? SuggestionDetailTextColorIncognito()
: SuggestionDetailTextColor();
suggestionDetailTextColor = SuggestionDetailTextColor(self.incognito);
}
DCHECK(suggestionDetailTextColor);
detailAttributedText =
......@@ -190,9 +182,8 @@ bool ShouldUseNewFormatting() {
} else {
const ACMatchClassifications* textClassifications =
!self.isURL ? &_match.contents_class : &_match.description_class;
UIColor* suggestionTextColor =
_incognito ? SuggestionTextColorIncognito() : SuggestionTextColor();
UIColor* dimColor = _incognito ? DimColorIncognito() : DimColor();
UIColor* suggestionTextColor = SuggestionTextColor(self.incognito);
UIColor* dimColor = self.incognito ? DimColorIncognito() : DimColor();
attributedText = [self attributedStringWithString:text
classifications:textClassifications
......@@ -317,13 +308,13 @@ bool ShouldUseNewFormatting() {
(int)type {
DCHECK(!ShouldUseNewFormatting());
// Answer types, sizes and colors specified at http://goto.google.com/ais_api.
UIColor* detailTextColor = SuggestionDetailTextColor(self.incognito);
switch (type) {
case SuggestionAnswer::TOP_ALIGNED:
return @{
NSFontAttributeName : [UIFont systemFontOfSize:12],
NSBaselineOffsetAttributeName : @10.0f,
NSForegroundColorAttributeName :
[UIColor colorNamed:kTextSecondaryColor],
NSForegroundColorAttributeName : detailTextColor,
};
case SuggestionAnswer::DESCRIPTION_POSITIVE:
return @{
......@@ -343,33 +334,29 @@ bool ShouldUseNewFormatting() {
return @{
NSFontAttributeName : [UIFont systemFontOfSize:20],
NSForegroundColorAttributeName :
[UIColor colorNamed:kTextSecondaryColor],
NSForegroundColorAttributeName : detailTextColor,
};
case SuggestionAnswer::ANSWER_TEXT_LARGE:
return @{
NSFontAttributeName : [UIFont systemFontOfSize:24],
NSForegroundColorAttributeName :
[UIColor colorNamed:kTextSecondaryColor],
NSForegroundColorAttributeName : detailTextColor,
};
case SuggestionAnswer::SUGGESTION_SECONDARY_TEXT_SMALL:
return @{
NSFontAttributeName : [UIFont systemFontOfSize:12],
NSForegroundColorAttributeName :
[UIColor colorNamed:kTextSecondaryColor],
NSForegroundColorAttributeName : detailTextColor,
};
case SuggestionAnswer::SUGGESTION_SECONDARY_TEXT_MEDIUM:
return @{
NSFontAttributeName : [UIFont systemFontOfSize:14],
NSForegroundColorAttributeName :
[UIColor colorNamed:kTextSecondaryColor],
NSForegroundColorAttributeName : detailTextColor,
};
case SuggestionAnswer::SUGGESTION:
// Fall through.
default:
return @{
NSFontAttributeName : [UIFont systemFontOfSize:16],
NSForegroundColorAttributeName : [UIColor colorNamed:kTextPrimaryColor],
NSForegroundColorAttributeName : SuggestionTextColor(self.incognito),
};
}
}
......@@ -391,8 +378,8 @@ bool ShouldUseNewFormatting() {
: [UIFontDescriptor
preferredFontDescriptorWithTextStyle:UIFontTextStyleBody];
UIColor* defaultColor = useDeemphasizedStyling
? [UIColor colorNamed:kTextSecondaryColor]
: [UIColor colorNamed:kTextPrimaryColor];
? SuggestionDetailTextColor(self.incognito)
: SuggestionTextColor(self.incognito);
switch (style) {
case SuggestionAnswer::TextStyle::NORMAL:
......
......@@ -24,6 +24,7 @@ group("resources") {
":text_primary_color",
":text_primary_dark_color",
":text_secondary_color",
":text_secondary_dark_color",
":textfield_background_color",
":textfield_background_dark_color",
":textfield_placeholder_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") {
sources = [
"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;
extern NSString* const kBackgroundDarkColor;
extern NSString* const kTableViewRowHighlightDarkColor;
extern NSString* const kTextPrimaryDarkColor;
extern NSString* const kTextSecondaryDarkColor;
extern NSString* const kTextfieldBackgroundDarkColor;
extern NSString* const kTextfieldPlaceholderDarkColor;
......
......@@ -32,6 +32,7 @@ NSString* const kBackgroundDarkColor = @"background_dark_color";
NSString* const kTableViewRowHighlightDarkColor =
@"table_view_row_highlight_dark_color";
NSString* const kTextPrimaryDarkColor = @"text_primary_dark_color";
NSString* const kTextSecondaryDarkColor = @"text_secondary_dark_color";
NSString* const kTextfieldBackgroundDarkColor =
@"textfield_background_dark_color";
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