Commit 782398d4 authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS][Dark Mode] Change tab switcher background color to black

This CL changes the tab switcher background color by adding a new
local color to the tab_grid resources. It also defines a constant
in tab_grid_constants to hold the name of this file and make sure that
anything that uses the color depends on the actual colorset.

It also deletes all the now-unused color constants. The only ones left
are those that are used for styling the recent tabs view on iOS 12
(where dark mode is not supported).

Bug: 998415
Change-Id: I9c7ac49360e36ad8681492ef7722436d9b5aa308
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1774278
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693324}
parent 7fbe7516
...@@ -106,7 +106,7 @@ const CGFloat kResizeFactor = 4; ...@@ -106,7 +106,7 @@ const CGFloat kResizeFactor = 4;
[[background bottomAnchor] constraintEqualToAnchor:self.bottomAnchor] [[background bottomAnchor] constraintEqualToAnchor:self.bottomAnchor]
]]; ]];
background.backgroundColor = UIColorFromRGB(kGridBackgroundColor); background.backgroundColor = [UIColor colorNamed:kGridBackgroundColor];
_rightCard = _rightCard =
[[SwipeView alloc] initWithFrame:CGRectZero topMargin:topMargin]; [[SwipeView alloc] initWithFrame:CGRectZero topMargin:topMargin];
......
...@@ -54,6 +54,10 @@ source_set("tab_grid_ui_constants") { ...@@ -54,6 +54,10 @@ source_set("tab_grid_ui_constants") {
"tab_grid_constants.h", "tab_grid_constants.h",
"tab_grid_constants.mm", "tab_grid_constants.mm",
] ]
deps = [
"resources:grid_background_color",
]
} }
source_set("tab_grid_ui") { source_set("tab_grid_ui") {
......
...@@ -354,10 +354,10 @@ void PositionView(UIView* view, CGPoint point) { ...@@ -354,10 +354,10 @@ void PositionView(UIView* view, CGPoint point) {
- (void)setupSelectedBackgroundView { - (void)setupSelectedBackgroundView {
self.selectedBackgroundView = [[UIView alloc] init]; self.selectedBackgroundView = [[UIView alloc] init];
self.selectedBackgroundView.backgroundColor = self.selectedBackgroundView.backgroundColor =
UIColorFromRGB(kGridBackgroundColor); [UIColor colorNamed:kGridBackgroundColor];
UIView* border = [[UIView alloc] init]; UIView* border = [[UIView alloc] init];
border.translatesAutoresizingMaskIntoConstraints = NO; border.translatesAutoresizingMaskIntoConstraints = NO;
border.backgroundColor = UIColorFromRGB(kGridBackgroundColor); border.backgroundColor = [UIColor colorNamed:kGridBackgroundColor];
border.layer.cornerRadius = kGridCellCornerRadius + border.layer.cornerRadius = kGridCellCornerRadius +
kGridCellSelectionRingGapWidth + kGridCellSelectionRingGapWidth +
kGridCellSelectionRingTintWidth; kGridCellSelectionRingTintWidth;
......
...@@ -17,12 +17,8 @@ extern NSString* const kGridCellIdentifierPrefix; ...@@ -17,12 +17,8 @@ extern NSString* const kGridCellIdentifierPrefix;
// Accessibility identifier for the close button in a grid cell. // Accessibility identifier for the close button in a grid cell.
extern NSString* const kGridCellCloseButtonIdentifier; extern NSString* const kGridCellCloseButtonIdentifier;
// All kxxxColor constants are RGB values stored in a Hex integer. These will be
// converted into UIColors using the UIColorFromRGB() function, from
// uikit_ui_util.h
// Grid styling. // Grid styling.
extern const int kGridBackgroundColor; extern NSString* const kGridBackgroundColor;
// GridLayout. // GridLayout.
// Extra-small screens require a slightly different layout configuration (e.g., // Extra-small screens require a slightly different layout configuration (e.g.,
...@@ -56,23 +52,12 @@ extern const CGFloat kReorderingInactiveCellOpacity; ...@@ -56,23 +52,12 @@ extern const CGFloat kReorderingInactiveCellOpacity;
extern const CGFloat kReorderingActiveCellScale; extern const CGFloat kReorderingActiveCellScale;
// GridCell styling. // GridCell styling.
// Common colors. // All kxxxColor constants after this are RGB values stored in a Hex integer.
extern const int kGridCellIconBackgroundColor; // These will be converted into UIColors using the UIColorFromRGB() function,
extern const int kGridCellSnapshotBackgroundColor; // from uikit_ui_util.h.
// Light theme colors. // TODO(crbug.com/981889): remove with iOS 12.
extern const int kGridLightThemeCellTitleColor;
extern const int kGridLightThemeCellHeaderColor;
extern const int kGridLightThemeCellSelectionColor;
extern const int kGridLightThemeCellCloseButtonTintColor;
// Dark theme colors.
extern const int kGridDarkThemeCellTitleColor;
extern const int kGridDarkThemeCellHeaderColor;
extern const int kGridDarkThemeCellSelectionColor;
extern const int kGridDarkThemeCellCloseButtonTintColor;
extern const CGFloat kGridDarkThemeCellHighlightColorAlpha;
extern const int kGridDarkThemeCellSeparatorColor;
// TODO (crbug.com/981889): remove with iOS 12.
// Extra dark theme colors until iOS 12 gets removed. // Extra dark theme colors until iOS 12 gets removed.
extern const int kGridDarkThemeCellTitleColor;
extern const int kGridDarkThemeCellDetailColor; extern const int kGridDarkThemeCellDetailColor;
extern const CGFloat kGridDarkThemeCellDetailAlpha; extern const CGFloat kGridDarkThemeCellDetailAlpha;
extern const int kGridDarkThemeCellTintColor; extern const int kGridDarkThemeCellTintColor;
......
...@@ -16,7 +16,7 @@ NSString* const kGridCellCloseButtonIdentifier = ...@@ -16,7 +16,7 @@ NSString* const kGridCellCloseButtonIdentifier =
@"GridCellCloseButtonIdentifier"; @"GridCellCloseButtonIdentifier";
// Grid styling. // Grid styling.
const int kGridBackgroundColor = 0x222222; NSString* const kGridBackgroundColor = @"grid_background_color";
// Definition of limited width for applicable size classes. The first refers to // Definition of limited width for applicable size classes. The first refers to
// the horizontal size class; the second to the vertical. // the horizontal size class; the second to the vertical.
...@@ -49,22 +49,9 @@ const CGFloat kReorderingInactiveCellOpacity = 0.80; ...@@ -49,22 +49,9 @@ const CGFloat kReorderingInactiveCellOpacity = 0.80;
const CGFloat kReorderingActiveCellScale = 1.15; const CGFloat kReorderingActiveCellScale = 1.15;
// GridCell styling. // GridCell styling.
// Common colors.
const int kGridCellIconBackgroundColor = 0xF1F3F4;
const int kGridCellSnapshotBackgroundColor = 0xE8EAED;
// Light theme colors.
const int kGridLightThemeCellTitleColor = 0x000000;
const int kGridLightThemeCellHeaderColor = 0xF8F9FA;
const int kGridLightThemeCellSelectionColor = 0x1A73E8;
const int kGridLightThemeCellCloseButtonTintColor = 0x3C4043;
// Dark theme colors. // Dark theme colors.
const int kGridDarkThemeCellTitleColor = 0xFFFFFF;
const int kGridDarkThemeCellHeaderColor = 0x5F6368;
const int kGridDarkThemeCellSelectionColor = 0x9AA0A6;
const int kGridDarkThemeCellCloseButtonTintColor = 0xFFFFFF;
const CGFloat kGridDarkThemeCellHighlightColorAlpha = 0.7;
const int kGridDarkThemeCellSeparatorColor = 0x535354;
// Extra dark theme colors until iOS 12 gets removed. // Extra dark theme colors until iOS 12 gets removed.
const int kGridDarkThemeCellTitleColor = 0xFFFFFF;
const int kGridDarkThemeCellDetailColor = 0xEBEBF5; const int kGridDarkThemeCellDetailColor = 0xEBEBF5;
const CGFloat kGridDarkThemeCellDetailAlpha = 0.6; const CGFloat kGridDarkThemeCellDetailAlpha = 0.6;
const int kGridDarkThemeCellTintColor = 0x8AB4F9; const int kGridDarkThemeCellTintColor = 0x8AB4F9;
......
...@@ -96,7 +96,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -96,7 +96,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
collectionView.delegate = self; collectionView.delegate = self;
collectionView.backgroundView = [[UIView alloc] init]; collectionView.backgroundView = [[UIView alloc] init];
collectionView.backgroundView.backgroundColor = collectionView.backgroundView.backgroundColor =
UIColorFromRGB(kGridBackgroundColor); [UIColor colorNamed:kGridBackgroundColor];
// CollectionView, in contrast to TableView, doesn’t inset the // CollectionView, in contrast to TableView, doesn’t inset the
// cell content to the safe area guide by default. We will just manage the // cell content to the safe area guide by default. We will just manage the
// collectionView contentInset manually to fit in the safe area instead. // collectionView contentInset manually to fit in the safe area instead.
......
...@@ -4,6 +4,12 @@ ...@@ -4,6 +4,12 @@
import("//build/config/ios/asset_catalog.gni") import("//build/config/ios/asset_catalog.gni")
colorset("grid_background_color") {
sources = [
"grid_background_color.colorset/Contents.json",
]
}
imageset("new_tab_floating_button") { imageset("new_tab_floating_button") {
sources = [ sources = [
"new_tab_floating_button.imageset/Contents.json", "new_tab_floating_button.imageset/Contents.json",
......
{
"info" : {
"version" : 1,
"author" : "xcode"
},
"colors" : [
{
"idiom" : "universal",
"color" : {
"color-space" : "display-p3",
"components" : {
"red" : "0x00",
"alpha" : "1.000",
"blue" : "0x00",
"green" : "0x00"
}
}
}
]
}
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#import "ios/chrome/browser/ui/util/rtl_geometry.h" #import "ios/chrome/browser/ui/util/rtl_geometry.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/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 "ios/web/public/thread/web_task_traits.h" #include "ios/web/public/thread/web_task_traits.h"
...@@ -159,7 +160,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -159,7 +160,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.view.backgroundColor = UIColorFromRGB(kGridBackgroundColor); self.view.backgroundColor = [UIColor colorNamed:kGridBackgroundColor];
[self setupScrollView]; [self setupScrollView];
[self setupIncognitoTabsViewController]; [self setupIncognitoTabsViewController];
[self setupRegularTabsViewController]; [self setupRegularTabsViewController];
...@@ -659,9 +660,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -659,9 +660,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
// TODO(crbug.com/804589) : Dark style on remote tabs. // TODO(crbug.com/804589) : Dark style on remote tabs.
// The styler must be set before the view controller is loaded. // The styler must be set before the view controller is loaded.
ChromeTableViewStyler* styler = [[ChromeTableViewStyler alloc] init]; ChromeTableViewStyler* styler = [[ChromeTableViewStyler alloc] init];
styler.tableViewBackgroundColor = UIColorFromRGB(kGridBackgroundColor); styler.tableViewBackgroundColor = [UIColor colorNamed:kGridBackgroundColor];
styler.cellHighlightColor =
[UIColor colorWithWhite:0 alpha:kGridDarkThemeCellHighlightColorAlpha];
// To make using the compile guards easier, use a separate method. // To make using the compile guards easier, use a separate method.
[self setupRemoteTabsViewControllerForDarkModeWithStyler:styler]; [self setupRemoteTabsViewControllerForDarkModeWithStyler:styler];
self.remoteTabsViewController.styler = styler; self.remoteTabsViewController.styler = styler;
...@@ -697,10 +696,13 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -697,10 +696,13 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
// override is not available on pre-iOS 13 devices, so the dark mode colors // override is not available on pre-iOS 13 devices, so the dark mode colors
// must be provided manually. // must be provided manually.
if (@available(iOS 13, *)) { if (@available(iOS 13, *)) {
styler.cellHighlightColor = [UIColor colorNamed:kTableViewRowHighlightColor];
self.remoteTabsViewController.overrideUserInterfaceStyle = self.remoteTabsViewController.overrideUserInterfaceStyle =
UIUserInterfaceStyleDark; UIUserInterfaceStyleDark;
return; return;
} }
styler.cellHighlightColor =
[UIColor colorNamed:kTableViewRowHighlightDarkColor];
styler.cellTitleColor = UIColorFromRGB(kGridDarkThemeCellTitleColor); styler.cellTitleColor = UIColorFromRGB(kGridDarkThemeCellTitleColor);
styler.headerFooterTitleColor = UIColorFromRGB(kGridDarkThemeCellTitleColor); styler.headerFooterTitleColor = UIColorFromRGB(kGridDarkThemeCellTitleColor);
styler.cellDetailColor = UIColorFromRGB(kGridDarkThemeCellDetailColor, styler.cellDetailColor = UIColorFromRGB(kGridDarkThemeCellDetailColor,
......
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