Commit 1a769197 authored by Mark Cogan's avatar Mark Cogan Committed by Commit Bot

[iOS] Update tab grid control assets.

This CL updates the tab grid selector control assets, and removes the
programatic scaling effect now that the assets are scaled. Tinting is
also now done in code.

Bug: 849645
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I48e9a3e72cad8609ad14a2940733a02140d89005
Reviewed-on: https://chromium-review.googlesource.com/1099070
Commit-Queue: Mark Cogan <marq@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567194}
parent bafb0d97
...@@ -100,8 +100,8 @@ const int kSliderColor = 0xF8F9FA; ...@@ -100,8 +100,8 @@ const int kSliderColor = 0xF8F9FA;
const int kBackgroundColor = 0x5F6368; const int kBackgroundColor = 0x5F6368;
// Alpha for the background view. // Alpha for the background view.
const CGFloat kBackgroundAlpha = 1.0; const CGFloat kBackgroundAlpha = 1.0;
// Color for the regular tab count label // Color for the regular tab count label and icons.
const CGFloat kSelectedLabelColor = 0x3C4043; const CGFloat kSelectedColor = 0x3C4043;
// Returns the point that's at the center of |rect|. // Returns the point that's at the center of |rect|.
CGPoint RectCenter(CGRect rect) { CGPoint RectCenter(CGRect rect) {
...@@ -116,6 +116,17 @@ NSString* StringForItemCount(long count) { ...@@ -116,6 +116,17 @@ NSString* StringForItemCount(long count) {
return @":-)"; return @":-)";
return [NSString stringWithFormat:@"%ld", count]; return [NSString stringWithFormat:@"%ld", count];
} }
// Convenience method that composes an asset name and returns the correct image
// (in template rendering mode) based on the segment name (one of "regular",
// "incognito, "remote") and whether the selected state image is needed or not.
UIImage* ImageForSegment(NSString* segment, BOOL selected) {
NSString* asset =
[NSString stringWithFormat:@"page_control_%@_tabs%@", segment,
selected ? @"_selected" : @""];
return [[UIImage imageNamed:asset]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
}
} }
// View class used for the background of this control; it draws the grey // View class used for the background of this control; it draws the grey
...@@ -476,20 +487,15 @@ NSString* StringForItemCount(long count) { ...@@ -476,20 +487,15 @@ NSString* StringForItemCount(long count) {
[self.sliderView addSubview:selectedImageView]; [self.sliderView addSubview:selectedImageView];
self.selectedImageView = selectedImageView; self.selectedImageView = selectedImageView;
// Scale the selected images, since the current assets don't have a larger
// size for the selected state.
// TODO(crbug.com/804500): Remove this once the correct assets are available.
CGFloat scale = kSelectedLabelSize / kLabelSize;
CGAffineTransform scaleTransform = CGAffineTransformMakeScale(scale, scale);
// Icons and labels for the regular tabs. // Icons and labels for the regular tabs.
UIImageView* regularIcon = [[UIImageView alloc] UIImageView* regularIcon =
initWithImage:[UIImage imageNamed:@"page_control_regular_tabs"]]; [[UIImageView alloc] initWithImage:ImageForSegment(@"regular", NO)];
regularIcon.tintColor = UIColorFromRGB(kSliderColor);
[self insertSubview:regularIcon belowSubview:self.sliderView]; [self insertSubview:regularIcon belowSubview:self.sliderView];
self.regularIcon = regularIcon; self.regularIcon = regularIcon;
UIImageView* regularSelectedIcon = [[UIImageView alloc] UIImageView* regularSelectedIcon =
initWithImage:[UIImage imageNamed:@"page_control_regular_tabs_selected"]]; [[UIImageView alloc] initWithImage:ImageForSegment(@"regular", YES)];
regularSelectedIcon.transform = scaleTransform; regularSelectedIcon.tintColor = UIColorFromRGB(kSelectedColor);
[self.selectedImageView addSubview:regularSelectedIcon]; [self.selectedImageView addSubview:regularSelectedIcon];
self.regularSelectedIcon = regularSelectedIcon; self.regularSelectedIcon = regularSelectedIcon;
UILabel* regularLabel = [self labelSelected:NO]; UILabel* regularLabel = [self labelSelected:NO];
...@@ -500,25 +506,26 @@ NSString* StringForItemCount(long count) { ...@@ -500,25 +506,26 @@ NSString* StringForItemCount(long count) {
self.regularSelectedLabel = regularSelectedLabel; self.regularSelectedLabel = regularSelectedLabel;
// Icons for the incognito tabs section. // Icons for the incognito tabs section.
UIImageView* incognitoIcon = [[UIImageView alloc] UIImageView* incognitoIcon =
initWithImage:[UIImage imageNamed:@"page_control_incognito_tabs"]]; [[UIImageView alloc] initWithImage:ImageForSegment(@"incognito", NO)];
incognitoIcon.tintColor = UIColorFromRGB(kSliderColor);
[self insertSubview:incognitoIcon belowSubview:self.sliderView]; [self insertSubview:incognitoIcon belowSubview:self.sliderView];
self.incognitoIcon = incognitoIcon; self.incognitoIcon = incognitoIcon;
UIImageView* incognitoSelectedIcon = [[UIImageView alloc] UIImageView* incognitoSelectedIcon =
initWithImage:[UIImage [[UIImageView alloc] initWithImage:ImageForSegment(@"incognito", YES)];
imageNamed:@"page_control_incognito_tabs_selected"]]; incognitoSelectedIcon.tintColor = UIColorFromRGB(kSelectedColor);
incognitoSelectedIcon.transform = scaleTransform;
[self.selectedImageView addSubview:incognitoSelectedIcon]; [self.selectedImageView addSubview:incognitoSelectedIcon];
self.incognitoSelectedIcon = incognitoSelectedIcon; self.incognitoSelectedIcon = incognitoSelectedIcon;
// Icons for the remote tabs section. // Icons for the remote tabs section.
UIImageView* remoteIcon = [[UIImageView alloc] UIImageView* remoteIcon =
initWithImage:[UIImage imageNamed:@"page_control_remote_tabs"]]; [[UIImageView alloc] initWithImage:ImageForSegment(@"remote", NO)];
remoteIcon.tintColor = UIColorFromRGB(kSliderColor);
[self insertSubview:remoteIcon belowSubview:self.sliderView]; [self insertSubview:remoteIcon belowSubview:self.sliderView];
self.remoteIcon = remoteIcon; self.remoteIcon = remoteIcon;
UIImageView* remoteSelectedIcon = [[UIImageView alloc] UIImageView* remoteSelectedIcon =
initWithImage:[UIImage imageNamed:@"page_control_remote_tabs_selected"]]; [[UIImageView alloc] initWithImage:ImageForSegment(@"remote", YES)];
remoteSelectedIcon.transform = scaleTransform; remoteSelectedIcon.tintColor = UIColorFromRGB(kSelectedColor);
[self.selectedImageView addSubview:remoteSelectedIcon]; [self.selectedImageView addSubview:remoteSelectedIcon];
self.remoteSelectedIcon = remoteSelectedIcon; self.remoteSelectedIcon = remoteSelectedIcon;
...@@ -543,8 +550,8 @@ NSString* StringForItemCount(long count) { ...@@ -543,8 +550,8 @@ NSString* StringForItemCount(long count) {
// Selected labels use a different size and are black. // Selected labels use a different size and are black.
- (UILabel*)labelSelected:(BOOL)selected { - (UILabel*)labelSelected:(BOOL)selected {
CGFloat size = selected ? kSelectedLabelSize : kLabelSize; CGFloat size = selected ? kSelectedLabelSize : kLabelSize;
UIColor* color = selected ? UIColorFromRGB(kSelectedLabelColor) UIColor* color =
: UIColorFromRGB(kSliderColor); selected ? UIColorFromRGB(kSelectedColor) : UIColorFromRGB(kSliderColor);
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, size, size)]; UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, size, size)];
label.backgroundColor = UIColor.clearColor; label.backgroundColor = UIColor.clearColor;
label.textAlignment = NSTextAlignmentCenter; label.textAlignment = NSTextAlignmentCenter;
......
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