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;
[[background bottomAnchor] constraintEqualToAnchor:self.bottomAnchor]
]];
background.backgroundColor = UIColorFromRGB(kGridBackgroundColor);
background.backgroundColor = [UIColor colorNamed:kGridBackgroundColor];
_rightCard =
[[SwipeView alloc] initWithFrame:CGRectZero topMargin:topMargin];
......
......@@ -54,6 +54,10 @@ source_set("tab_grid_ui_constants") {
"tab_grid_constants.h",
"tab_grid_constants.mm",
]
deps = [
"resources:grid_background_color",
]
}
source_set("tab_grid_ui") {
......
......@@ -354,10 +354,10 @@ void PositionView(UIView* view, CGPoint point) {
- (void)setupSelectedBackgroundView {
self.selectedBackgroundView = [[UIView alloc] init];
self.selectedBackgroundView.backgroundColor =
UIColorFromRGB(kGridBackgroundColor);
[UIColor colorNamed:kGridBackgroundColor];
UIView* border = [[UIView alloc] init];
border.translatesAutoresizingMaskIntoConstraints = NO;
border.backgroundColor = UIColorFromRGB(kGridBackgroundColor);
border.backgroundColor = [UIColor colorNamed:kGridBackgroundColor];
border.layer.cornerRadius = kGridCellCornerRadius +
kGridCellSelectionRingGapWidth +
kGridCellSelectionRingTintWidth;
......
......@@ -17,12 +17,8 @@ extern NSString* const kGridCellIdentifierPrefix;
// Accessibility identifier for the close button in a grid cell.
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.
extern const int kGridBackgroundColor;
extern NSString* const kGridBackgroundColor;
// GridLayout.
// Extra-small screens require a slightly different layout configuration (e.g.,
......@@ -56,23 +52,12 @@ extern const CGFloat kReorderingInactiveCellOpacity;
extern const CGFloat kReorderingActiveCellScale;
// GridCell styling.
// Common colors.
extern const int kGridCellIconBackgroundColor;
extern const int kGridCellSnapshotBackgroundColor;
// Light theme colors.
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.
// All kxxxColor constants after this are RGB values stored in a Hex integer.
// These will be converted into UIColors using the UIColorFromRGB() function,
// from uikit_ui_util.h.
// TODO(crbug.com/981889): remove with iOS 12.
// Extra dark theme colors until iOS 12 gets removed.
extern const int kGridDarkThemeCellTitleColor;
extern const int kGridDarkThemeCellDetailColor;
extern const CGFloat kGridDarkThemeCellDetailAlpha;
extern const int kGridDarkThemeCellTintColor;
......
......@@ -16,7 +16,7 @@ NSString* const kGridCellCloseButtonIdentifier =
@"GridCellCloseButtonIdentifier";
// Grid styling.
const int kGridBackgroundColor = 0x222222;
NSString* const kGridBackgroundColor = @"grid_background_color";
// Definition of limited width for applicable size classes. The first refers to
// the horizontal size class; the second to the vertical.
......@@ -49,22 +49,9 @@ const CGFloat kReorderingInactiveCellOpacity = 0.80;
const CGFloat kReorderingActiveCellScale = 1.15;
// 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.
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.
const int kGridDarkThemeCellTitleColor = 0xFFFFFF;
const int kGridDarkThemeCellDetailColor = 0xEBEBF5;
const CGFloat kGridDarkThemeCellDetailAlpha = 0.6;
const int kGridDarkThemeCellTintColor = 0x8AB4F9;
......
......@@ -96,7 +96,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
collectionView.delegate = self;
collectionView.backgroundView = [[UIView alloc] init];
collectionView.backgroundView.backgroundColor =
UIColorFromRGB(kGridBackgroundColor);
[UIColor colorNamed:kGridBackgroundColor];
// CollectionView, in contrast to TableView, doesn’t inset 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.
......
......@@ -4,6 +4,12 @@
import("//build/config/ios/asset_catalog.gni")
colorset("grid_background_color") {
sources = [
"grid_background_color.colorset/Contents.json",
]
}
imageset("new_tab_floating_button") {
sources = [
"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 @@
#import "ios/chrome/browser/ui/util/rtl_geometry.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/semantic_color_names.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ios/web/public/thread/web_task_traits.h"
......@@ -159,7 +160,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = UIColorFromRGB(kGridBackgroundColor);
self.view.backgroundColor = [UIColor colorNamed:kGridBackgroundColor];
[self setupScrollView];
[self setupIncognitoTabsViewController];
[self setupRegularTabsViewController];
......@@ -659,9 +660,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
// TODO(crbug.com/804589) : Dark style on remote tabs.
// The styler must be set before the view controller is loaded.
ChromeTableViewStyler* styler = [[ChromeTableViewStyler alloc] init];
styler.tableViewBackgroundColor = UIColorFromRGB(kGridBackgroundColor);
styler.cellHighlightColor =
[UIColor colorWithWhite:0 alpha:kGridDarkThemeCellHighlightColorAlpha];
styler.tableViewBackgroundColor = [UIColor colorNamed:kGridBackgroundColor];
// To make using the compile guards easier, use a separate method.
[self setupRemoteTabsViewControllerForDarkModeWithStyler:styler];
self.remoteTabsViewController.styler = styler;
......@@ -697,10 +696,13 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
// override is not available on pre-iOS 13 devices, so the dark mode colors
// must be provided manually.
if (@available(iOS 13, *)) {
styler.cellHighlightColor = [UIColor colorNamed:kTableViewRowHighlightColor];
self.remoteTabsViewController.overrideUserInterfaceStyle =
UIUserInterfaceStyleDark;
return;
}
styler.cellHighlightColor =
[UIColor colorNamed:kTableViewRowHighlightDarkColor];
styler.cellTitleColor = UIColorFromRGB(kGridDarkThemeCellTitleColor);
styler.headerFooterTitleColor = UIColorFromRGB(kGridDarkThemeCellTitleColor);
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