Commit 69cfe36a authored by edchin's avatar edchin Committed by Commit Bot

[ios] Clean up and polish colors in GridCell

This CL cleans up GridCell and updates the colors.

Bug: 818198
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Id080667cf704af3d33745ab9019f1556693f80e5
Reviewed-on: https://chromium-review.googlesource.com/963724Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Commit-Queue: edchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543477}
parent 66d1e9a8
...@@ -27,7 +27,6 @@ const CGFloat kBorderWidth = 6.0f; ...@@ -27,7 +27,6 @@ const CGFloat kBorderWidth = 6.0f;
@interface GridCell () @interface GridCell ()
// Visual components of the cell. // Visual components of the cell.
@property(nonatomic, weak) UIView* topBar; @property(nonatomic, weak) UIView* topBar;
@property(nonatomic, weak) UIView* line;
@property(nonatomic, weak) UIImageView* iconView; @property(nonatomic, weak) UIImageView* iconView;
@property(nonatomic, weak) TopAlignedImageView* snapshotView; @property(nonatomic, weak) TopAlignedImageView* snapshotView;
@property(nonatomic, weak) UILabel* titleLabel; @property(nonatomic, weak) UILabel* titleLabel;
...@@ -45,7 +44,6 @@ const CGFloat kBorderWidth = 6.0f; ...@@ -45,7 +44,6 @@ const CGFloat kBorderWidth = 6.0f;
@synthesize title = _title; @synthesize title = _title;
// Private properties. // Private properties.
@synthesize topBar = _topBar; @synthesize topBar = _topBar;
@synthesize line = _line;
@synthesize iconView = _iconView; @synthesize iconView = _iconView;
@synthesize snapshotView = _snapshotView; @synthesize snapshotView = _snapshotView;
@synthesize titleLabel = _titleLabel; @synthesize titleLabel = _titleLabel;
...@@ -62,15 +60,11 @@ const CGFloat kBorderWidth = 6.0f; ...@@ -62,15 +60,11 @@ const CGFloat kBorderWidth = 6.0f;
contentView.layer.cornerRadius = 11.0f; contentView.layer.cornerRadius = 11.0f;
contentView.layer.masksToBounds = YES; contentView.layer.masksToBounds = YES;
UIView* topBar = [self setupTopBar]; UIView* topBar = [self setupTopBar];
UIView* line = [[UIView alloc] init];
line.translatesAutoresizingMaskIntoConstraints = NO;
TopAlignedImageView* snapshotView = [[TopAlignedImageView alloc] init]; TopAlignedImageView* snapshotView = [[TopAlignedImageView alloc] init];
snapshotView.translatesAutoresizingMaskIntoConstraints = NO; snapshotView.translatesAutoresizingMaskIntoConstraints = NO;
[contentView addSubview:topBar]; [contentView addSubview:topBar];
[contentView addSubview:line];
[contentView addSubview:snapshotView]; [contentView addSubview:snapshotView];
_topBar = topBar; _topBar = topBar;
_line = line;
_snapshotView = snapshotView; _snapshotView = snapshotView;
NSArray* constraints = @[ NSArray* constraints = @[
[topBar.topAnchor constraintEqualToAnchor:contentView.topAnchor], [topBar.topAnchor constraintEqualToAnchor:contentView.topAnchor],
...@@ -78,11 +72,7 @@ const CGFloat kBorderWidth = 6.0f; ...@@ -78,11 +72,7 @@ const CGFloat kBorderWidth = 6.0f;
[topBar.trailingAnchor [topBar.trailingAnchor
constraintEqualToAnchor:contentView.trailingAnchor], constraintEqualToAnchor:contentView.trailingAnchor],
[topBar.heightAnchor constraintEqualToConstant:kTopBarHeight], [topBar.heightAnchor constraintEqualToConstant:kTopBarHeight],
[line.topAnchor constraintEqualToAnchor:topBar.bottomAnchor], [snapshotView.topAnchor constraintEqualToAnchor:topBar.bottomAnchor],
[line.leadingAnchor constraintEqualToAnchor:contentView.leadingAnchor],
[line.trailingAnchor constraintEqualToAnchor:contentView.trailingAnchor],
[line.heightAnchor constraintEqualToConstant:0.5f],
[snapshotView.topAnchor constraintEqualToAnchor:line.bottomAnchor],
[snapshotView.leadingAnchor [snapshotView.leadingAnchor
constraintEqualToAnchor:contentView.leadingAnchor], constraintEqualToAnchor:contentView.leadingAnchor],
[snapshotView.trailingAnchor [snapshotView.trailingAnchor
...@@ -125,33 +115,27 @@ const CGFloat kBorderWidth = 6.0f; ...@@ -125,33 +115,27 @@ const CGFloat kBorderWidth = 6.0f;
- (void)setTheme:(GridTheme)theme { - (void)setTheme:(GridTheme)theme {
if (_theme == theme) if (_theme == theme)
return; return;
self.iconView.backgroundColor = UIColorFromRGB(kGridCellIconBackgroundColor);
self.snapshotView.backgroundColor =
UIColorFromRGB(kGridCellSnapshotBackgroundColor);
switch (theme) { switch (theme) {
case GridThemeLight: case GridThemeLight:
self.topBar.backgroundColor = [UIColor whiteColor]; self.topBar.backgroundColor =
self.iconView.backgroundColor = [UIColor colorWithWhite:0.9f alpha:1.0f]; UIColorFromRGB(kGridLightThemeCellHeaderColor);
self.titleLabel.textColor = [UIColor blackColor]; self.titleLabel.textColor = UIColorFromRGB(kGridLightThemeCellTitleColor);
self.line.backgroundColor = [UIColor colorWithWhite:0.6f alpha:1.0f];
self.snapshotView.backgroundColor = [UIColor whiteColor];
self.closeButton.tintColor = self.closeButton.tintColor =
UIColorFromRGB(kGridLightThemeCellCloseButtonTintColor); UIColorFromRGB(kGridLightThemeCellCloseButtonTintColor);
self.tintColor = self.border.layer.borderColor =
[UIColor colorWithRed:0.0 green:122.0 / 255.0 blue:1.0 alpha:1.0]; UIColorFromRGB(kGridLightThemeCellSelectionColor).CGColor;
self.border.layer.borderColor = self.tintColor.CGColor;
break; break;
case GridThemeDark: case GridThemeDark:
self.topBar.backgroundColor = [UIColor colorWithWhite:0.2f alpha:1.0f]; self.topBar.backgroundColor =
self.iconView.backgroundColor = [UIColor colorWithWhite:0.9f alpha:1.0f]; UIColorFromRGB(kGridDarkThemeCellHeaderColor);
self.titleLabel.textColor = [UIColor whiteColor]; self.titleLabel.textColor = UIColorFromRGB(kGridDarkThemeCellTitleColor);
self.line.backgroundColor = [UIColor colorWithWhite:0.2f alpha:1.0f];
self.snapshotView.backgroundColor =
[UIColor colorWithWhite:0.4f alpha:1.0f];
self.closeButton.tintColor = self.closeButton.tintColor =
UIColorFromRGB(kGridDarkThemeCellCloseButtonTintColor); UIColorFromRGB(kGridDarkThemeCellCloseButtonTintColor);
self.tintColor = [UIColor colorWithWhite:0.9f alpha:1.0f]; self.border.layer.borderColor =
self.border.layer.borderColor = self.tintColor.CGColor; UIColorFromRGB(kGridDarkThemeCellSelectionColor).CGColor;
break;
default:
NOTREACHED() << "Invalid GridTheme.";
break; break;
} }
_theme = theme; _theme = theme;
......
...@@ -21,7 +21,18 @@ extern NSString* const kGridCellCloseButtonIdentifier; ...@@ -21,7 +21,18 @@ extern NSString* const kGridCellCloseButtonIdentifier;
// uikit_ui_util.h // uikit_ui_util.h
// GridCell styling. // GridCell styling.
// Common colors.
extern const CGFloat kGridCellIconBackgroundColor;
extern const CGFloat kGridCellSnapshotBackgroundColor;
// Light theme colors.
extern const CGFloat kGridLightThemeCellTitleColor;
extern const CGFloat kGridLightThemeCellHeaderColor;
extern const CGFloat kGridLightThemeCellSelectionColor;
extern const CGFloat kGridLightThemeCellCloseButtonTintColor; extern const CGFloat kGridLightThemeCellCloseButtonTintColor;
// Dark theme colors.
extern const CGFloat kGridDarkThemeCellTitleColor;
extern const CGFloat kGridDarkThemeCellHeaderColor;
extern const CGFloat kGridDarkThemeCellSelectionColor;
extern const CGFloat kGridDarkThemeCellCloseButtonTintColor; extern const CGFloat kGridDarkThemeCellCloseButtonTintColor;
#endif // IOS_CHROME_BROWSER_UI_TAB_GRID_GRID_CONSTANTS_H_ #endif // IOS_CHROME_BROWSER_UI_TAB_GRID_GRID_CONSTANTS_H_
...@@ -16,5 +16,16 @@ NSString* const kGridCellCloseButtonIdentifier = ...@@ -16,5 +16,16 @@ NSString* const kGridCellCloseButtonIdentifier =
@"GridCellCloseButtonIdentifier"; @"GridCellCloseButtonIdentifier";
// GridCell styling. // GridCell styling.
// Common colors.
const CGFloat kGridCellIconBackgroundColor = 0xF1F3F4;
const CGFloat kGridCellSnapshotBackgroundColor = 0xE8EAED;
// Light theme colors.
const CGFloat kGridLightThemeCellTitleColor = 0x000000;
const CGFloat kGridLightThemeCellHeaderColor = 0xF8F9FA;
const CGFloat kGridLightThemeCellSelectionColor = 0x1A73E8;
const CGFloat kGridLightThemeCellCloseButtonTintColor = 0x3C4043; const CGFloat kGridLightThemeCellCloseButtonTintColor = 0x3C4043;
// Dark theme colors.
const CGFloat kGridDarkThemeCellTitleColor = 0xFFFFFF;
const CGFloat kGridDarkThemeCellHeaderColor = 0x5F6368;
const CGFloat kGridDarkThemeCellSelectionColor = 0x9AA0A6;
const CGFloat kGridDarkThemeCellCloseButtonTintColor = 0xFFFFFF; const CGFloat kGridDarkThemeCellCloseButtonTintColor = 0xFFFFFF;
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
// Theme describing the look of the grid. // Theme describing the look of the grid.
typedef NS_ENUM(NSUInteger, GridTheme) { typedef NS_ENUM(NSUInteger, GridTheme) {
GridThemeInvalid = 0, GridThemeLight = 1,
GridThemeLight,
GridThemeDark, GridThemeDark,
}; };
......
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