Commit 1f105940 authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS] Support dark mode on content suggestions/NTP

This does not change the color on the placeholder background + icon
for when a suggestion has no image because that will be removed before
dark mode is finished.

Bug: 976641
Change-Id: I0bf0e26e7ce087917c38017d15a85c0a2ecbf6b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1706431
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678266}
parent de729294
...@@ -135,6 +135,7 @@ source_set("content_suggestions_ui") { ...@@ -135,6 +135,7 @@ source_set("content_suggestions_ui") {
"//ios/chrome/browser/ui/toolbar/public", "//ios/chrome/browser/ui/toolbar/public",
"//ios/chrome/browser/ui/toolbar/resources:tab_toolbar_shadow_color", "//ios/chrome/browser/ui/toolbar/resources:tab_toolbar_shadow_color",
"//ios/chrome/browser/ui/util:util", "//ios/chrome/browser/ui/util:util",
"//ios/chrome/common/colors",
"//ios/chrome/common/favicon", "//ios/chrome/common/favicon",
"//ios/chrome/common/ui_util", "//ios/chrome/common/ui_util",
"//ios/web/common", "//ios/web/common",
......
...@@ -63,6 +63,7 @@ source_set("cells_ui") { ...@@ -63,6 +63,7 @@ source_set("cells_ui") {
"//ios/chrome/browser/ui/ntp_tile_views:constants", "//ios/chrome/browser/ui/ntp_tile_views:constants",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/common", "//ios/chrome/common",
"//ios/chrome/common/colors",
"//ios/chrome/common/favicon", "//ios/chrome/common/favicon",
"//ios/chrome/common/ui_util", "//ios/chrome/common/ui_util",
"//ui/base", "//ui/base",
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_articles_header_item.h" #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_articles_header_item.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/colors/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/colors/semantic_color_names.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h" #import "ios/chrome/common/ui_util/constraints_ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -16,8 +18,6 @@ ...@@ -16,8 +18,6 @@
namespace { namespace {
// Leading and trailing margin for label and button. // Leading and trailing margin for label and button.
const CGFloat kTextMargin = 13; const CGFloat kTextMargin = 13;
// Color for label text.
const int kLabelColorRGB = 0x6D6D72;
} }
#pragma mark - ContentSuggestionsArticlesHeaderItem #pragma mark - ContentSuggestionsArticlesHeaderItem
...@@ -90,11 +90,12 @@ const int kLabelColorRGB = 0x6D6D72; ...@@ -90,11 +90,12 @@ const int kLabelColorRGB = 0x6D6D72;
_label = [[UILabel alloc] init]; _label = [[UILabel alloc] init];
_label.translatesAutoresizingMaskIntoConstraints = NO; _label.translatesAutoresizingMaskIntoConstraints = NO;
_label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]; _label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
_label.textColor = UIColorFromRGB(kLabelColorRGB, 1.0); _label.textColor = UIColor.cr_secondaryLabelColor;
_label.adjustsFontForContentSizeCategory = YES; _label.adjustsFontForContentSizeCategory = YES;
_label.adjustsFontSizeToFitWidth = YES; _label.adjustsFontSizeToFitWidth = YES;
_button = [UIButton buttonWithType:UIButtonTypeSystem]; _button = [UIButton buttonWithType:UIButtonTypeSystem];
_button.tintColor = [UIColor colorNamed:kTintColor];
_button.translatesAutoresizingMaskIntoConstraints = NO; _button.translatesAutoresizingMaskIntoConstraints = NO;
_button.titleLabel.font = _button.titleLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]; [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#import "ios/chrome/browser/ui/util/i18n_string.h" #import "ios/chrome/browser/ui/util/i18n_string.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/colors/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/favicon/favicon_view.h" #import "ios/chrome/common/favicon/favicon_view.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h" #import "ios/chrome/common/ui_util/constraints_ui_util.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"
...@@ -113,8 +114,7 @@ const CGFloat kAnimationDuration = 0.3; ...@@ -113,8 +114,7 @@ const CGFloat kAnimationDuration = 0.3;
[[self class] configureTitleLabel:_titleLabel]; [[self class] configureTitleLabel:_titleLabel];
_additionalInformationLabel.font = [[self class] additionalInformationFont]; _additionalInformationLabel.font = [[self class] additionalInformationFont];
_faviconView.font = [[MDCTypography fontLoader] mediumFontOfSize:10]; _faviconView.font = [[MDCTypography fontLoader] mediumFontOfSize:10];
_additionalInformationLabel.textColor = _additionalInformationLabel.textColor = UIColor.cr_secondaryLabelColor;
[UIColor colorWithWhite:0 alpha:0.54];
[self applyConstraints]; [self applyConstraints];
} }
...@@ -374,7 +374,7 @@ const CGFloat kAnimationDuration = 0.3; ...@@ -374,7 +374,7 @@ const CGFloat kAnimationDuration = 0.3;
// Configures the |titleLabel|. // Configures the |titleLabel|.
+ (void)configureTitleLabel:(UILabel*)titleLabel { + (void)configureTitleLabel:(UILabel*)titleLabel {
titleLabel.textColor = [UIColor colorWithWhite:0 alpha:0.8]; titleLabel.textColor = UIColor.cr_labelColor;
UIFontDescriptor* descriptor = [[UIFontDescriptor UIFontDescriptor* descriptor = [[UIFontDescriptor
preferredFontDescriptorWithTextStyle:UIFontTextStyleSubheadline] preferredFontDescriptorWithTextStyle:UIFontTextStyleSubheadline]
fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold]; fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold];
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/common/colors/semantic_color_names.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h" #import "ios/chrome/common/ui_util/constraints_ui_util.h"
#import "ios/third_party/material_components_ios/src/components/ActivityIndicator/src/MaterialActivityIndicator.h" #import "ios/third_party/material_components_ios/src/components/ActivityIndicator/src/MaterialActivityIndicator.h"
...@@ -84,9 +85,10 @@ const CGFloat kButtonPadding = 16; ...@@ -84,9 +85,10 @@ const CGFloat kButtonPadding = 16;
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
_activityIndicator = [[MDCActivityIndicator alloc] init]; _activityIndicator = [[MDCActivityIndicator alloc] init];
_activityIndicator.cycleColors = @[ [[MDCPalette cr_bluePalette] tint500] ]; _activityIndicator.cycleColors = @[ [UIColor colorNamed:kTintColor] ];
_activityIndicator.translatesAutoresizingMaskIntoConstraints = NO; _activityIndicator.translatesAutoresizingMaskIntoConstraints = NO;
_button = [UIButton buttonWithType:UIButtonTypeSystem]; _button = [UIButton buttonWithType:UIButtonTypeSystem];
_button.tintColor = [UIColor colorNamed:kTintColor];
_button.translatesAutoresizingMaskIntoConstraints = NO; _button.translatesAutoresizingMaskIntoConstraints = NO;
_button.titleLabel.font = _button.titleLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]; [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#import "ios/chrome/browser/ui/toolbar/public/toolbar_utils.h" #import "ios/chrome/browser/ui/toolbar/public/toolbar_utils.h"
#import "ios/chrome/browser/ui/ui_feature_flags.h" #import "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/colors/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h" #import "ios/chrome/common/ui_util/constraints_ui_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -469,8 +470,17 @@ NSString* const kContentSuggestionsMostVisitedAccessibilityIdentifierPrefix = ...@@ -469,8 +470,17 @@ NSString* const kContentSuggestionsMostVisitedAccessibilityIdentifierPrefix =
cellBackgroundColorAtIndexPath:(nonnull NSIndexPath*)indexPath { cellBackgroundColorAtIndexPath:(nonnull NSIndexPath*)indexPath {
if ([self.collectionUpdater if ([self.collectionUpdater
shouldUseCustomStyleForSection:indexPath.section]) { shouldUseCustomStyleForSection:indexPath.section]) {
return [UIColor clearColor]; return UIColor.clearColor;
} }
// MDCCollectionView doesn't support dynamic colors, so they have to be
// resolved now.
// TODO(crbug.com/984928): Clean up once dynamic color support is added.
#if defined(__IPHONE_13_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0)
if (@available(iOS 13, *)) {
return [ntp_home::kNTPBackgroundColor()
resolvedColorWithTraitCollection:self.traitCollection];
}
#endif
return ntp_home::kNTPBackgroundColor(); return ntp_home::kNTPBackgroundColor();
} }
......
...@@ -23,6 +23,7 @@ source_set("ntp_tile_views") { ...@@ -23,6 +23,7 @@ source_set("ntp_tile_views") {
"resources:ntp_recent_icon", "resources:ntp_recent_icon",
"//base", "//base",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/common/colors",
"//ios/chrome/common/favicon", "//ios/chrome/common/favicon",
"//ios/chrome/common/ui_util", "//ios/chrome/common/ui_util",
"//ios/third_party/material_components_ios", "//ios/third_party/material_components_ios",
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#import "ios/chrome/browser/ui/ntp_tile_views/ntp_tile_view.h" #import "ios/chrome/browser/ui/ntp_tile_views/ntp_tile_view.h"
#import "ios/chrome/browser/ui/util/dynamic_type_util.h" #import "ios/chrome/browser/ui/util/dynamic_type_util.h"
#import "ios/chrome/common/colors/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h" #import "ios/chrome/common/ui_util/constraints_ui_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -16,7 +17,6 @@ namespace { ...@@ -16,7 +17,6 @@ namespace {
const NSInteger kLabelNumLines = 2; const NSInteger kLabelNumLines = 2;
const CGFloat kSpaceIconTitle = 10; const CGFloat kSpaceIconTitle = 10;
const CGFloat kIconSize = 56; const CGFloat kIconSize = 56;
const CGFloat kTitleAlpha = 0.54;
const CGFloat kPreferredMaxWidth = 73; const CGFloat kPreferredMaxWidth = 73;
} // namespace } // namespace
...@@ -27,7 +27,7 @@ const CGFloat kPreferredMaxWidth = 73; ...@@ -27,7 +27,7 @@ const CGFloat kPreferredMaxWidth = 73;
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
_titleLabel = [[UILabel alloc] init]; _titleLabel = [[UILabel alloc] init];
_titleLabel.textColor = [UIColor colorWithWhite:0 alpha:kTitleAlpha]; _titleLabel.textColor = UIColor.cr_secondaryLabelColor;
_titleLabel.font = [self titleLabelFont]; _titleLabel.font = [self titleLabelFont];
_titleLabel.textAlignment = NSTextAlignmentCenter; _titleLabel.textAlignment = NSTextAlignmentCenter;
_titleLabel.preferredMaxLayoutWidth = kPreferredMaxWidth; _titleLabel.preferredMaxLayoutWidth = kPreferredMaxWidth;
......
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