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") {
"//ios/chrome/browser/ui/toolbar/public",
"//ios/chrome/browser/ui/toolbar/resources:tab_toolbar_shadow_color",
"//ios/chrome/browser/ui/util:util",
"//ios/chrome/common/colors",
"//ios/chrome/common/favicon",
"//ios/chrome/common/ui_util",
"//ios/web/common",
......
......@@ -63,6 +63,7 @@ source_set("cells_ui") {
"//ios/chrome/browser/ui/ntp_tile_views:constants",
"//ios/chrome/browser/ui/util",
"//ios/chrome/common",
"//ios/chrome/common/colors",
"//ios/chrome/common/favicon",
"//ios/chrome/common/ui_util",
"//ui/base",
......
......@@ -5,6 +5,8 @@
#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/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"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -16,8 +18,6 @@
namespace {
// Leading and trailing margin for label and button.
const CGFloat kTextMargin = 13;
// Color for label text.
const int kLabelColorRGB = 0x6D6D72;
}
#pragma mark - ContentSuggestionsArticlesHeaderItem
......@@ -90,11 +90,12 @@ const int kLabelColorRGB = 0x6D6D72;
_label = [[UILabel alloc] init];
_label.translatesAutoresizingMaskIntoConstraints = NO;
_label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
_label.textColor = UIColorFromRGB(kLabelColorRGB, 1.0);
_label.textColor = UIColor.cr_secondaryLabelColor;
_label.adjustsFontForContentSizeCategory = YES;
_label.adjustsFontSizeToFitWidth = YES;
_button = [UIButton buttonWithType:UIButtonTypeSystem];
_button.tintColor = [UIColor colorNamed:kTintColor];
_button.translatesAutoresizingMaskIntoConstraints = NO;
_button.titleLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
......
......@@ -8,6 +8,7 @@
#import "ios/chrome/browser/ui/util/i18n_string.h"
#include "ios/chrome/browser/ui/util/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/ui_util/constraints_ui_util.h"
#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
......@@ -113,8 +114,7 @@ const CGFloat kAnimationDuration = 0.3;
[[self class] configureTitleLabel:_titleLabel];
_additionalInformationLabel.font = [[self class] additionalInformationFont];
_faviconView.font = [[MDCTypography fontLoader] mediumFontOfSize:10];
_additionalInformationLabel.textColor =
[UIColor colorWithWhite:0 alpha:0.54];
_additionalInformationLabel.textColor = UIColor.cr_secondaryLabelColor;
[self applyConstraints];
}
......@@ -374,7 +374,7 @@ const CGFloat kAnimationDuration = 0.3;
// Configures the |titleLabel|.
+ (void)configureTitleLabel:(UILabel*)titleLabel {
titleLabel.textColor = [UIColor colorWithWhite:0 alpha:0.8];
titleLabel.textColor = UIColor.cr_labelColor;
UIFontDescriptor* descriptor = [[UIFontDescriptor
preferredFontDescriptorWithTextStyle:UIFontTextStyleSubheadline]
fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold];
......
......@@ -6,6 +6,7 @@
#import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.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/third_party/material_components_ios/src/components/ActivityIndicator/src/MaterialActivityIndicator.h"
......@@ -84,9 +85,10 @@ const CGFloat kButtonPadding = 16;
self = [super initWithFrame:frame];
if (self) {
_activityIndicator = [[MDCActivityIndicator alloc] init];
_activityIndicator.cycleColors = @[ [[MDCPalette cr_bluePalette] tint500] ];
_activityIndicator.cycleColors = @[ [UIColor colorNamed:kTintColor] ];
_activityIndicator.translatesAutoresizingMaskIntoConstraints = NO;
_button = [UIButton buttonWithType:UIButtonTypeSystem];
_button.tintColor = [UIColor colorNamed:kTintColor];
_button.translatesAutoresizingMaskIntoConstraints = NO;
_button.titleLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
......
......@@ -27,6 +27,7 @@
#import "ios/chrome/browser/ui/toolbar/public/toolbar_utils.h"
#import "ios/chrome/browser/ui/ui_feature_flags.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"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -469,8 +470,17 @@ NSString* const kContentSuggestionsMostVisitedAccessibilityIdentifierPrefix =
cellBackgroundColorAtIndexPath:(nonnull NSIndexPath*)indexPath {
if ([self.collectionUpdater
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();
}
......
......@@ -23,6 +23,7 @@ source_set("ntp_tile_views") {
"resources:ntp_recent_icon",
"//base",
"//ios/chrome/browser/ui/util",
"//ios/chrome/common/colors",
"//ios/chrome/common/favicon",
"//ios/chrome/common/ui_util",
"//ios/third_party/material_components_ios",
......
......@@ -5,6 +5,7 @@
#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/common/colors/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -16,7 +17,6 @@ namespace {
const NSInteger kLabelNumLines = 2;
const CGFloat kSpaceIconTitle = 10;
const CGFloat kIconSize = 56;
const CGFloat kTitleAlpha = 0.54;
const CGFloat kPreferredMaxWidth = 73;
} // namespace
......@@ -27,7 +27,7 @@ const CGFloat kPreferredMaxWidth = 73;
self = [super initWithFrame:frame];
if (self) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.textColor = [UIColor colorWithWhite:0 alpha:kTitleAlpha];
_titleLabel.textColor = UIColor.cr_secondaryLabelColor;
_titleLabel.font = [self titleLabelFont];
_titleLabel.textAlignment = NSTextAlignmentCenter;
_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