Commit 4e40c3a0 authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS][Dark Mode] Support Dark Mode in NTP tiles

Before, the color of the tiles wasn't updated in dark mode. Now, both
the most visited and the shortcut tiles have their colors updated.

The |+backgroundImage| class method can be removed because now, both
tiles use the background as a template image.

Bug: 991973, 976641
Change-Id: I3db5204ec7684f592e67c6b7fa6ff8944b5ac839
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1751328Reviewed-by: default avatarEric Noyau <noyau@chromium.org>
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Cr-Commit-Position: refs/heads/master@{#686609}
parent 694ff615
......@@ -4,6 +4,7 @@
#import "ios/chrome/browser/ui/ntp_tile_views/ntp_shortcut_tile_view.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/Typography/src/MaterialTypography.h"
......@@ -27,6 +28,7 @@ const CGFloat kIconSize = 56;
if (self) {
_iconView = [[UIImageView alloc] initWithFrame:self.bounds];
_iconView.translatesAutoresizingMaskIntoConstraints = NO;
_iconView.tintColor = [UIColor colorNamed:kBlueColor];
[self.imageContainerView addSubview:_iconView];
AddSameConstraints(self.imageContainerView, _iconView);
......@@ -36,7 +38,7 @@ const CGFloat kIconSize = 56;
]];
self.imageBackgroundView.tintColor =
[UIColor colorWithRed:0.91 green:0.95 blue:0.99 alpha:1.0];
[[UIColor colorNamed:kBlueColor] colorWithAlphaComponent:0.1];
}
return self;
}
......@@ -44,7 +46,7 @@ const CGFloat kIconSize = 56;
- (UILabel*)countLabel {
if (!_countLabel) {
_countContainer = [[UIView alloc] init];
_countContainer.backgroundColor = [UIColor whiteColor];
_countContainer.backgroundColor = [UIColor colorNamed:kBackgroundColor];
// Unfortunately, simply setting a CALayer borderWidth and borderColor
// on |_countContainer|, and setting a background color on |_countLabel|
// will result in the inner color bleeeding thru to the outside.
......@@ -54,10 +56,9 @@ const CGFloat kIconSize = 56;
_countLabel = [[UILabel alloc] init];
_countLabel.layer.cornerRadius = kCountWidth / 2;
_countLabel.layer.masksToBounds = YES;
_countLabel.textColor = [UIColor whiteColor];
_countLabel.textColor = [UIColor colorNamed:kSolidButtonTextColor];
_countLabel.textAlignment = NSTextAlignmentCenter;
_countLabel.backgroundColor =
[UIColor colorWithRed:0.10 green:0.45 blue:0.91 alpha:1.0];
_countLabel.backgroundColor = [UIColor colorNamed:kBlueColor];
_countContainer.translatesAutoresizingMaskIntoConstraints = NO;
_countLabel.translatesAutoresizingMaskIntoConstraints = NO;
......@@ -82,11 +83,4 @@ const CGFloat kIconSize = 56;
return _countLabel;
}
+ (UIImage*)backgroundImage {
// This subclass uses tintColor on the background view, so use template
// rendering mode.
return [[super backgroundImage]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
}
@end
......@@ -22,9 +22,6 @@
@property(nonatomic, strong, readonly, nonnull)
UIImageView* imageBackgroundView;
// Image to be used as the image background. The default is the grey squircle.
+ (nonnull UIImage*)backgroundImage;
@end
#endif // IOS_CHROME_BROWSER_UI_NTP_TILE_VIEWS_NTP_TILE_VIEW_H_
......@@ -6,6 +6,7 @@
#import "ios/chrome/browser/ui/util/dynamic_type_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"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -43,7 +44,10 @@ const CGFloat kPreferredMaxWidth = 73;
UIImageView* backgroundView =
[[UIImageView alloc] initWithFrame:self.bounds];
backgroundView.translatesAutoresizingMaskIntoConstraints = NO;
backgroundView.image = [[self class] backgroundImage];
UIImage* backgroundImage = [[UIImage imageNamed:@"ntp_most_visited_tile"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
backgroundView.image = backgroundImage;
backgroundView.tintColor = [UIColor colorNamed:kGrey100Color];
[self addSubview:backgroundView];
[self addSubview:_imageContainerView];
......@@ -75,10 +79,6 @@ const CGFloat kPreferredMaxWidth = 73;
UIContentSizeCategoryAccessibilityLarge);
}
+ (UIImage*)backgroundImage {
return [UIImage imageNamed:@"ntp_most_visited_tile"];
}
#pragma mark - UIView
- (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {
......
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