Commit 42418b4b authored by stkhapugin@chromium.org's avatar stkhapugin@chromium.org Committed by Commit Bot

[iOS] Make UI Refresh popup change appearance with size classes.

iPad multitasking UI should match iPhone or normal iPad depending on
size class:
 * in RxR size class, it should show the suggestion icons and align
to the icon in the omnibox
 * in other size classes, it should be left-aligned and have no
suggestion icons

However, pre-UI Refresh UI should remain the same.

Bug: 821817
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ibeed9ecf4f4b1058e80e7e4d45523b1d1f0d4ee8
Reviewed-on: https://chromium-review.googlesource.com/1118225
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571445}
parent 0107b105
...@@ -80,25 +80,21 @@ const CGFloat kAppendButtonSize = 48.0; ...@@ -80,25 +80,21 @@ const CGFloat kAppendButtonSize = 48.0;
// The current implementation is from before using a UITableViewCell. // The current implementation is from before using a UITableViewCell.
[self.contentView addSubview:_appendButton]; [self.contentView addSubview:_appendButton];
// Leading icon is only displayed on iPad. // Before UI Refresh, the leading icon is only displayed on iPad. In UI
if (IsIPadIdiom()) { // Refresh, it's only in Regular x Regular size class.
_imageView = [[UIImageView alloc] initWithFrame:CGRectZero]; // TODO(justincohen): Consider using the UITableViewCell's image view.
_imageView.userInteractionEnabled = NO; // The current implementation is from before using a UITableViewCell.
_imageView.contentMode = UIViewContentModeCenter; _imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
_imageView.userInteractionEnabled = NO;
if (IsUIRefreshPhase1Enabled()) { _imageView.contentMode = UIViewContentModeCenter;
_imageView.layer.cornerRadius = kImageViewCornerRadiusUIRefresh;
_imageView.backgroundColor = if (IsUIRefreshPhase1Enabled()) {
incognito ? [UIColor colorWithWhite:1 alpha:0.05] _imageView.layer.cornerRadius = kImageViewCornerRadiusUIRefresh;
: [UIColor colorWithWhite:0 alpha:0.03]; _imageView.backgroundColor = incognito
_imageView.tintColor = incognito ? [UIColor colorWithWhite:1 alpha:0.05]
? [UIColor colorWithWhite:1 alpha:0.4] : [UIColor colorWithWhite:0 alpha:0.03];
: [UIColor colorWithWhite:0 alpha:0.33]; _imageView.tintColor = incognito ? [UIColor colorWithWhite:1 alpha:0.4]
} : [UIColor colorWithWhite:0 alpha:0.33];
// TODO(justincohen): Consider using the UITableViewCell's image view.
// The current implementation is from before using a UITableViewCell.
[self.contentView addSubview:_imageView];
} }
_answerImageView = [[UIImageView alloc] initWithFrame:CGRectZero]; _answerImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
...@@ -112,6 +108,11 @@ const CGFloat kAppendButtonSize = 48.0; ...@@ -112,6 +108,11 @@ const CGFloat kAppendButtonSize = 48.0;
- (void)layoutSubviews { - (void)layoutSubviews {
[super layoutSubviews]; [super layoutSubviews];
[self layoutAccessoryViews]; [self layoutAccessoryViews];
if ([self showsLeadingIcons]) {
[self.contentView addSubview:_imageView];
} else {
[_imageView removeFromSuperview];
}
} }
- (void)layoutAccessoryViews { - (void)layoutAccessoryViews {
...@@ -124,7 +125,9 @@ const CGFloat kAppendButtonSize = 48.0; ...@@ -124,7 +125,9 @@ const CGFloat kAppendButtonSize = 48.0;
CGFloat imageViewSize = IsUIRefreshPhase1Enabled() ? kImageViewSizeUIRefresh CGFloat imageViewSize = IsUIRefreshPhase1Enabled() ? kImageViewSizeUIRefresh
: kImageDimensionLength; : kImageDimensionLength;
LayoutRect imageViewLayout = LayoutRectMake( LayoutRect imageViewLayout = LayoutRectMake(
IsCompactTablet() ? kLeadingPaddingIpadCompact : kLeadingPaddingIpad, ([self showsLeadingIcons] && IsCompactTablet())
? kLeadingPaddingIpadCompact
: kLeadingPaddingIpad,
CGRectGetWidth(self.contentView.bounds), CGRectGetWidth(self.contentView.bounds),
floor((_rowHeight - imageViewSize) / 2), imageViewSize, imageViewSize); floor((_rowHeight - imageViewSize) / 2), imageViewSize, imageViewSize);
_imageView.frame = LayoutRectGetRect(imageViewLayout); _imageView.frame = LayoutRectGetRect(imageViewLayout);
...@@ -203,4 +206,12 @@ const CGFloat kAppendButtonSize = 48.0; ...@@ -203,4 +206,12 @@ const CGFloat kAppendButtonSize = 48.0;
: _detailTruncatingLabel.attributedText.string; : _detailTruncatingLabel.attributedText.string;
} }
- (BOOL)showsLeadingIcons {
if (IsUIRefreshPhase1Enabled()) {
return IsRegularXRegularSizeClass();
} else {
return IsIPadIdiom();
}
}
@end @end
...@@ -230,10 +230,10 @@ UIColor* BackgroundColorIncognito() { ...@@ -230,10 +230,10 @@ UIColor* BackgroundColorIncognito() {
- (void)updateRow:(OmniboxPopupRow*)row - (void)updateRow:(OmniboxPopupRow*)row
withMatch:(id<AutocompleteSuggestion>)match { withMatch:(id<AutocompleteSuggestion>)match {
CGFloat kTextCellLeadingPadding = CGFloat kTextCellLeadingPadding =
IsIPadIdiom() ? (!IsCompactTablet() ? 192 : 100) : 16; [self showsLeadingIcons] ? ([self useRegularWidthOffset] ? 192 : 100)
: 16;
if (IsUIRefreshPhase1Enabled()) { if (IsUIRefreshPhase1Enabled()) {
kTextCellLeadingPadding = kTextCellLeadingPadding = [self showsLeadingIcons] ? 221 : 24;
IsIPadIdiom() ? (!IsCompactTablet() ? 221 : 100) : 24;
} }
const CGFloat kTextCellTopPadding = 6; const CGFloat kTextCellTopPadding = 6;
...@@ -341,7 +341,7 @@ UIColor* BackgroundColorIncognito() { ...@@ -341,7 +341,7 @@ UIColor* BackgroundColorIncognito() {
// The leading image (e.g. magnifying glass, star, clock) is only shown on // The leading image (e.g. magnifying glass, star, clock) is only shown on
// iPad. // iPad.
if (IsIPadIdiom()) { if ([self showsLeadingIcons]) {
UIImage* image = nil; UIImage* image = nil;
if (IsUIRefreshPhase1Enabled()) { if (IsUIRefreshPhase1Enabled()) {
image = match.suggestionTypeIcon; image = match.suggestionTypeIcon;
...@@ -377,7 +377,8 @@ UIColor* BackgroundColorIncognito() { ...@@ -377,7 +377,8 @@ UIColor* BackgroundColorIncognito() {
if (LTRTextInRTLLayout) { if (LTRTextInRTLLayout) {
// This is really a left padding, not a leading padding. // This is really a left padding, not a leading padding.
const CGFloat kLTRTextInRTLLayoutLeftPadding = const CGFloat kLTRTextInRTLLayoutLeftPadding =
IsIPadIdiom() ? (!IsCompactTablet() ? 176 : 94) : 94; [self showsLeadingIcons] ? ([self useRegularWidthOffset] ? 176 : 94)
: 94;
CGRect frame = textLabel.frame; CGRect frame = textLabel.frame;
frame.size.width -= kLTRTextInRTLLayoutLeftPadding - frame.origin.x; frame.size.width -= kLTRTextInRTLLayoutLeftPadding - frame.origin.x;
frame.origin.x = kLTRTextInRTLLayoutLeftPadding; frame.origin.x = kLTRTextInRTLLayoutLeftPadding;
...@@ -647,4 +648,18 @@ UIColor* BackgroundColorIncognito() { ...@@ -647,4 +648,18 @@ UIColor* BackgroundColorIncognito() {
} }
} }
#pragma mark - private
- (BOOL)showsLeadingIcons {
if (IsUIRefreshPhase1Enabled()) {
return IsRegularXRegularSizeClass();
} else {
return IsIPadIdiom();
}
}
- (BOOL)useRegularWidthOffset {
return [self showsLeadingIcons] && !IsCompactWidth();
}
@end @end
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