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;
// The current implementation is from before using a UITableViewCell.
[self.contentView addSubview:_appendButton];
// Leading icon is only displayed on iPad.
if (IsIPadIdiom()) {
_imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
_imageView.userInteractionEnabled = NO;
_imageView.contentMode = UIViewContentModeCenter;
if (IsUIRefreshPhase1Enabled()) {
_imageView.layer.cornerRadius = kImageViewCornerRadiusUIRefresh;
_imageView.backgroundColor =
incognito ? [UIColor colorWithWhite:1 alpha:0.05]
: [UIColor colorWithWhite:0 alpha:0.03];
_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];
// Before UI Refresh, the leading icon is only displayed on iPad. In UI
// Refresh, it's only in Regular x Regular size class.
// TODO(justincohen): Consider using the UITableViewCell's image view.
// The current implementation is from before using a UITableViewCell.
_imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
_imageView.userInteractionEnabled = NO;
_imageView.contentMode = UIViewContentModeCenter;
if (IsUIRefreshPhase1Enabled()) {
_imageView.layer.cornerRadius = kImageViewCornerRadiusUIRefresh;
_imageView.backgroundColor = incognito
? [UIColor colorWithWhite:1 alpha:0.05]
: [UIColor colorWithWhite:0 alpha:0.03];
_imageView.tintColor = incognito ? [UIColor colorWithWhite:1 alpha:0.4]
: [UIColor colorWithWhite:0 alpha:0.33];
}
_answerImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
......@@ -112,6 +108,11 @@ const CGFloat kAppendButtonSize = 48.0;
- (void)layoutSubviews {
[super layoutSubviews];
[self layoutAccessoryViews];
if ([self showsLeadingIcons]) {
[self.contentView addSubview:_imageView];
} else {
[_imageView removeFromSuperview];
}
}
- (void)layoutAccessoryViews {
......@@ -124,7 +125,9 @@ const CGFloat kAppendButtonSize = 48.0;
CGFloat imageViewSize = IsUIRefreshPhase1Enabled() ? kImageViewSizeUIRefresh
: kImageDimensionLength;
LayoutRect imageViewLayout = LayoutRectMake(
IsCompactTablet() ? kLeadingPaddingIpadCompact : kLeadingPaddingIpad,
([self showsLeadingIcons] && IsCompactTablet())
? kLeadingPaddingIpadCompact
: kLeadingPaddingIpad,
CGRectGetWidth(self.contentView.bounds),
floor((_rowHeight - imageViewSize) / 2), imageViewSize, imageViewSize);
_imageView.frame = LayoutRectGetRect(imageViewLayout);
......@@ -203,4 +206,12 @@ const CGFloat kAppendButtonSize = 48.0;
: _detailTruncatingLabel.attributedText.string;
}
- (BOOL)showsLeadingIcons {
if (IsUIRefreshPhase1Enabled()) {
return IsRegularXRegularSizeClass();
} else {
return IsIPadIdiom();
}
}
@end
......@@ -230,10 +230,10 @@ UIColor* BackgroundColorIncognito() {
- (void)updateRow:(OmniboxPopupRow*)row
withMatch:(id<AutocompleteSuggestion>)match {
CGFloat kTextCellLeadingPadding =
IsIPadIdiom() ? (!IsCompactTablet() ? 192 : 100) : 16;
[self showsLeadingIcons] ? ([self useRegularWidthOffset] ? 192 : 100)
: 16;
if (IsUIRefreshPhase1Enabled()) {
kTextCellLeadingPadding =
IsIPadIdiom() ? (!IsCompactTablet() ? 221 : 100) : 24;
kTextCellLeadingPadding = [self showsLeadingIcons] ? 221 : 24;
}
const CGFloat kTextCellTopPadding = 6;
......@@ -341,7 +341,7 @@ UIColor* BackgroundColorIncognito() {
// The leading image (e.g. magnifying glass, star, clock) is only shown on
// iPad.
if (IsIPadIdiom()) {
if ([self showsLeadingIcons]) {
UIImage* image = nil;
if (IsUIRefreshPhase1Enabled()) {
image = match.suggestionTypeIcon;
......@@ -377,7 +377,8 @@ UIColor* BackgroundColorIncognito() {
if (LTRTextInRTLLayout) {
// This is really a left padding, not a leading padding.
const CGFloat kLTRTextInRTLLayoutLeftPadding =
IsIPadIdiom() ? (!IsCompactTablet() ? 176 : 94) : 94;
[self showsLeadingIcons] ? ([self useRegularWidthOffset] ? 176 : 94)
: 94;
CGRect frame = textLabel.frame;
frame.size.width -= kLTRTextInRTLLayoutLeftPadding - frame.origin.x;
frame.origin.x = kLTRTextInRTLLayoutLeftPadding;
......@@ -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
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